feature: Adds more commands and adds an example.
This commit is contained in:
parent
0d0f16174b
commit
3cb9526716
9 changed files with 352 additions and 41 deletions
|
@ -1,5 +1,17 @@
|
|||
package commonbackend
|
||||
|
||||
// Not all of these structs are implemented commands.
|
||||
// Currently unimplemented commands:
|
||||
// GetAllConnectionsRequest
|
||||
// BackendStatusResponse
|
||||
// BackendStatusRequest
|
||||
// ProxyStatusRequest
|
||||
// ProxyStatusResponse
|
||||
// GetAllConnectionsRequest
|
||||
|
||||
// TODO (imterah): Rename AddConnectionCommand/RemoveConnectionCommand to AddProxyCommand/RemoveProxyCommand
|
||||
// and their associated function calls
|
||||
|
||||
type StartCommand struct {
|
||||
Type string // Will be 'start' always
|
||||
Arguments []byte
|
||||
|
@ -25,6 +37,51 @@ type RemoveConnectionCommand struct {
|
|||
Protocol string // Will be either 'tcp' or 'udp'
|
||||
}
|
||||
|
||||
type GetProxyStatus struct {
|
||||
Type string // Will be 'getProxyStatus' always
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
DestPort uint16
|
||||
Protocol string // Will be either 'tcp' or 'udp'
|
||||
}
|
||||
|
||||
type ProxyStatusResponse struct {
|
||||
Type string // Will be 'proxyStatusResponse' always
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
DestPort uint16
|
||||
Protocol string // Will be either 'tcp' or 'udp'
|
||||
IsActive bool
|
||||
}
|
||||
|
||||
type ProxyConnection struct {
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
DestPort uint16
|
||||
Protocol string // Will be either 'tcp' or 'udp'
|
||||
}
|
||||
|
||||
type ProxyConnectionResponse struct {
|
||||
Type string // Will be 'proxyConnectionResponse' always
|
||||
Connections []*ProxyConnection // List of connections
|
||||
}
|
||||
|
||||
type BackendStatusResponse struct {
|
||||
Type string // Will be 'backendStatusResponse' always
|
||||
InResponseTo string // Can be either for 'start' or 'stop'
|
||||
StatusCode int // Either the 'Success' or 'Failure' constant
|
||||
Message string // String message from the client (ex. failed to dial TCP)
|
||||
}
|
||||
|
||||
type BackendStatusRequest struct {
|
||||
Type string // Will be 'backendStatusRequest' always
|
||||
ForProperty string // Can be either for 'start' or 'stop'
|
||||
}
|
||||
|
||||
type GetAllConnectionsRequest struct {
|
||||
Type string // Will be 'getAllConnectionsRequest' always
|
||||
}
|
||||
|
||||
type ClientConnection struct {
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
|
@ -33,8 +90,8 @@ type ClientConnection struct {
|
|||
ClientPort uint16
|
||||
}
|
||||
|
||||
type GetAllConnections struct {
|
||||
Type string // Will be 'getAllConnections' always
|
||||
type ConnectionsResponse struct {
|
||||
Type string // Will be 'connectionsResponse' always
|
||||
Connections []*ClientConnection // List of connections
|
||||
}
|
||||
|
||||
|
@ -53,10 +110,10 @@ type CheckServerParameters struct {
|
|||
|
||||
// Sent as a response to either CheckClientParameters or CheckBackendParameters
|
||||
type CheckParametersResponse struct {
|
||||
Type string // Will be 'checkParametersResponse' always
|
||||
InReplyTo string // Will be either 'checkClientParameters' or 'checkServerParameters'
|
||||
IsValid bool // If true, valid, and if false, invalid
|
||||
Message string // String message from the client (ex. failed to unmarshal JSON: x is not defined)
|
||||
Type string // Will be 'checkParametersResponse' always
|
||||
InResponseTo string // Will be either 'checkClientParameters' or 'checkServerParameters'
|
||||
IsValid bool // If true, valid, and if false, invalid
|
||||
Message string // String message from the client (ex. failed to unmarshal JSON: x is not defined)
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -74,10 +131,19 @@ const (
|
|||
const (
|
||||
TCP = iota
|
||||
UDP
|
||||
)
|
||||
|
||||
const (
|
||||
StatusSuccess = iota
|
||||
StatusFailure
|
||||
)
|
||||
|
||||
const (
|
||||
// IP versions
|
||||
IPv4 = 4
|
||||
IPv6 = 6
|
||||
|
||||
// TODO: net has these constants defined already. We should switch to these
|
||||
IPv4Size = 4
|
||||
IPv6Size = 16
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue