chore: Rename structs to be more clear.
This commit is contained in:
parent
0b6e40a944
commit
b30d8150f3
9 changed files with 136 additions and 126 deletions
|
@ -3,25 +3,25 @@ package commonbackend
|
|||
// TODO (imterah): Rename AddConnectionCommand/RemoveConnectionCommand to AddProxyCommand/RemoveProxyCommand
|
||||
// and their associated function calls
|
||||
|
||||
type StartCommand struct {
|
||||
type Start struct {
|
||||
Type string // Will be 'start' always
|
||||
Arguments []byte
|
||||
}
|
||||
|
||||
type StopCommand struct {
|
||||
type Stop struct {
|
||||
Type string // Will be 'stop' always
|
||||
}
|
||||
|
||||
type AddConnectionCommand struct {
|
||||
Type string // Will be 'addConnection' always
|
||||
type AddProxy struct {
|
||||
Type string // Will be 'addProxy' always
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
DestPort uint16
|
||||
Protocol string // Will be either 'tcp' or 'udp'
|
||||
}
|
||||
|
||||
type RemoveConnectionCommand struct {
|
||||
Type string // Will be 'removeConnection' always
|
||||
type RemoveProxy struct {
|
||||
Type string // Will be 'removeProxy' always
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
DestPort uint16
|
||||
|
@ -45,25 +45,25 @@ type ProxyStatusResponse struct {
|
|||
IsActive bool
|
||||
}
|
||||
|
||||
type ProxyConnection struct {
|
||||
type ProxyInstance struct {
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
DestPort uint16
|
||||
Protocol string // Will be either 'tcp' or 'udp'
|
||||
}
|
||||
|
||||
type ProxyConnectionResponse struct {
|
||||
Type string // Will be 'proxyConnectionResponse' always
|
||||
Proxies []*ProxyConnection // List of connections
|
||||
type ProxyInstanceResponse struct {
|
||||
Type string // Will be 'proxyConnectionResponse' always
|
||||
Proxies []*ProxyInstance // List of connections
|
||||
}
|
||||
|
||||
type ProxyConnectionRequest struct {
|
||||
type ProxyInstanceRequest struct {
|
||||
Type string // Will be 'proxyConnectionRequest' always
|
||||
}
|
||||
|
||||
type BackendStatusResponse struct {
|
||||
Type string // Will be 'backendStatusResponse' always
|
||||
IsRunning bool // Can be either for 'start' or 'stop'
|
||||
IsRunning bool // True if running, false if not running
|
||||
StatusCode int // Either the 'Success' or 'Failure' constant
|
||||
Message string // String message from the client (ex. failed to dial TCP)
|
||||
}
|
||||
|
@ -72,11 +72,12 @@ type BackendStatusRequest struct {
|
|||
Type string // Will be 'backendStatusRequest' always
|
||||
}
|
||||
|
||||
type GetAllConnectionsRequest struct {
|
||||
Type string // Will be 'getAllConnectionsRequest' always
|
||||
type ProxyConnectionsRequest struct {
|
||||
Type string // Will be 'proxyConnectionsRequest' always
|
||||
}
|
||||
|
||||
type ClientConnection struct {
|
||||
// Client's connection to a specific proxy
|
||||
type ProxyClientConnection struct {
|
||||
SourceIP string
|
||||
SourcePort uint16
|
||||
DestPort uint16
|
||||
|
@ -84,9 +85,9 @@ type ClientConnection struct {
|
|||
ClientPort uint16
|
||||
}
|
||||
|
||||
type ConnectionsResponse struct {
|
||||
Type string // Will be 'connectionsResponse' always
|
||||
Connections []*ClientConnection // List of connections
|
||||
type ProxyConnectionsResponse struct {
|
||||
Type string // Will be 'proxyConnectionsResponse' always
|
||||
Connections []*ProxyClientConnection // List of connections
|
||||
}
|
||||
|
||||
type CheckClientParameters struct {
|
||||
|
@ -111,22 +112,21 @@ type CheckParametersResponse struct {
|
|||
}
|
||||
|
||||
const (
|
||||
StartCommandID = iota
|
||||
StopCommandID
|
||||
AddConnectionCommandID
|
||||
RemoveConnectionCommandID
|
||||
ClientConnectionID
|
||||
GetAllConnectionsID
|
||||
StartID = iota
|
||||
StopID
|
||||
AddProxyID
|
||||
RemoveProxyID
|
||||
ProxyConnectionsResponseID
|
||||
CheckClientParametersID
|
||||
CheckServerParametersID
|
||||
CheckParametersResponseID
|
||||
GetAllConnectionsRequestID
|
||||
ProxyConnectionsRequestID
|
||||
BackendStatusResponseID
|
||||
BackendStatusRequestID
|
||||
ProxyStatusRequestID
|
||||
ProxyStatusResponseID
|
||||
ProxyConnectionResponseID
|
||||
ProxyConnectionRequestID
|
||||
ProxyInstanceResponseID
|
||||
ProxyInstanceRequestID
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net"
|
||||
)
|
||||
|
||||
func marshalIndividualConnectionStruct(conn *ClientConnection) []byte {
|
||||
func marshalIndividualConnectionStruct(conn *ProxyClientConnection) []byte {
|
||||
sourceIPOriginal := net.ParseIP(conn.SourceIP)
|
||||
clientIPOriginal := net.ParseIP(conn.ClientIP)
|
||||
|
||||
|
@ -47,7 +47,7 @@ func marshalIndividualConnectionStruct(conn *ClientConnection) []byte {
|
|||
return connectionBlock
|
||||
}
|
||||
|
||||
func marshalIndividualProxyStruct(conn *ProxyConnection) ([]byte, error) {
|
||||
func marshalIndividualProxyStruct(conn *ProxyInstance) ([]byte, error) {
|
||||
sourceIPOriginal := net.ParseIP(conn.SourceIP)
|
||||
|
||||
var sourceIPVer uint8
|
||||
|
@ -87,28 +87,28 @@ func marshalIndividualProxyStruct(conn *ProxyConnection) ([]byte, error) {
|
|||
func Marshal(commandType string, command interface{}) ([]byte, error) {
|
||||
switch commandType {
|
||||
case "start":
|
||||
startCommand, ok := command.(*StartCommand)
|
||||
startCommand, ok := command.(*Start)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
}
|
||||
|
||||
startCommandBytes := make([]byte, 1+2+len(startCommand.Arguments))
|
||||
startCommandBytes[0] = StartCommandID
|
||||
startCommandBytes[0] = StartID
|
||||
binary.BigEndian.PutUint16(startCommandBytes[1:3], uint16(len(startCommand.Arguments)))
|
||||
copy(startCommandBytes[3:], startCommand.Arguments)
|
||||
|
||||
return startCommandBytes, nil
|
||||
case "stop":
|
||||
_, ok := command.(*StopCommand)
|
||||
_, ok := command.(*Stop)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
}
|
||||
|
||||
return []byte{StopCommandID}, nil
|
||||
case "addConnection":
|
||||
addConnectionCommand, ok := command.(*AddConnectionCommand)
|
||||
return []byte{StopID}, nil
|
||||
case "addProxy":
|
||||
addConnectionCommand, ok := command.(*AddProxy)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
|
@ -129,7 +129,7 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
|
||||
addConnectionBytes := make([]byte, 1+1+len(ipBytes)+2+2+1)
|
||||
|
||||
addConnectionBytes[0] = AddConnectionCommandID
|
||||
addConnectionBytes[0] = AddProxyID
|
||||
addConnectionBytes[1] = ipVer
|
||||
|
||||
copy(addConnectionBytes[2:2+len(ipBytes)], ipBytes)
|
||||
|
@ -150,8 +150,8 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
addConnectionBytes[6+len(ipBytes)] = protocol
|
||||
|
||||
return addConnectionBytes, nil
|
||||
case "removeConnection":
|
||||
removeConnectionCommand, ok := command.(*RemoveConnectionCommand)
|
||||
case "removeProxy":
|
||||
removeConnectionCommand, ok := command.(*RemoveProxy)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
|
@ -172,7 +172,7 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
|
||||
removeConnectionBytes := make([]byte, 1+1+len(ipBytes)+2+2+1)
|
||||
|
||||
removeConnectionBytes[0] = RemoveConnectionCommandID
|
||||
removeConnectionBytes[0] = RemoveProxyID
|
||||
removeConnectionBytes[1] = ipVer
|
||||
copy(removeConnectionBytes[2:2+len(ipBytes)], ipBytes)
|
||||
binary.BigEndian.PutUint16(removeConnectionBytes[2+len(ipBytes):4+len(ipBytes)], removeConnectionCommand.SourcePort)
|
||||
|
@ -191,8 +191,8 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
removeConnectionBytes[6+len(ipBytes)] = protocol
|
||||
|
||||
return removeConnectionBytes, nil
|
||||
case "connectionsResponse":
|
||||
allConnectionsCommand, ok := command.(*ConnectionsResponse)
|
||||
case "proxyConnectionsResponse":
|
||||
allConnectionsCommand, ok := command.(*ProxyConnectionsResponse)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
|
@ -207,7 +207,7 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
}
|
||||
|
||||
connectionCommandArray := make([]byte, totalSize+1)
|
||||
connectionCommandArray[0] = GetAllConnectionsID
|
||||
connectionCommandArray[0] = ProxyConnectionsResponseID
|
||||
|
||||
currentPosition := 1
|
||||
|
||||
|
@ -442,8 +442,8 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
proxyStatusResponseBytes[7+len(ipBytes)] = isActive
|
||||
|
||||
return proxyStatusResponseBytes, nil
|
||||
case "proxyConnectionResponse":
|
||||
proxyConectionResponse, ok := command.(*ProxyConnectionResponse)
|
||||
case "proxyInstanceResponse":
|
||||
proxyConectionResponse, ok := command.(*ProxyInstanceResponse)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
|
@ -464,7 +464,7 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
}
|
||||
|
||||
connectionCommandArray := make([]byte, totalSize+1)
|
||||
connectionCommandArray[0] = ProxyConnectionResponseID
|
||||
connectionCommandArray[0] = ProxyInstanceResponseID
|
||||
|
||||
currentPosition := 1
|
||||
|
||||
|
@ -476,23 +476,23 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
|
||||
connectionCommandArray[totalSize] = '\n'
|
||||
return connectionCommandArray, nil
|
||||
case "proxyConnectionRequest":
|
||||
_, ok := command.(*ProxyConnectionRequest)
|
||||
case "proxyInstanceRequest":
|
||||
_, ok := command.(*ProxyInstanceRequest)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
}
|
||||
|
||||
return []byte{ProxyConnectionRequestID}, nil
|
||||
case "getAllConnectionsRequest":
|
||||
_, ok := command.(*GetAllConnectionsRequest)
|
||||
return []byte{ProxyInstanceRequestID}, nil
|
||||
case "proxyConnectionsRequest":
|
||||
_, ok := command.(*ProxyConnectionsRequest)
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to typecast")
|
||||
}
|
||||
|
||||
return []byte{GetAllConnectionsRequestID}, nil
|
||||
return []byte{ProxyConnectionsRequestID}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("couldn't match command")
|
||||
return nil, fmt.Errorf("couldn't match command name")
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
var logLevel = os.Getenv("NEXTNET_LOG_LEVEL")
|
||||
|
||||
func TestStartCommandMarshalSupport(t *testing.T) {
|
||||
commandInput := &StartCommand{
|
||||
commandInput := &Start{
|
||||
Type: "start",
|
||||
Arguments: []byte("Hello from automated testing"),
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func TestStartCommandMarshalSupport(t *testing.T) {
|
|||
log.Print("command type does not match up!")
|
||||
}
|
||||
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*StartCommand)
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*Start)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("failed typecast")
|
||||
|
@ -54,7 +54,7 @@ func TestStartCommandMarshalSupport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStopCommandMarshalSupport(t *testing.T) {
|
||||
commandInput := &StopCommand{
|
||||
commandInput := &Stop{
|
||||
Type: "stop",
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ func TestStopCommandMarshalSupport(t *testing.T) {
|
|||
log.Print("command type does not match up!")
|
||||
}
|
||||
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*StopCommand)
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*Stop)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("failed typecast")
|
||||
|
@ -93,8 +93,8 @@ func TestStopCommandMarshalSupport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAddConnectionCommandMarshalSupport(t *testing.T) {
|
||||
commandInput := &AddConnectionCommand{
|
||||
Type: "addConnection",
|
||||
commandInput := &AddProxy{
|
||||
Type: "addProxy",
|
||||
SourceIP: "192.168.0.139",
|
||||
SourcePort: 19132,
|
||||
DestPort: 19132,
|
||||
|
@ -123,7 +123,7 @@ func TestAddConnectionCommandMarshalSupport(t *testing.T) {
|
|||
log.Print("command type does not match up!")
|
||||
}
|
||||
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*AddConnectionCommand)
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*AddProxy)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("failed typecast")
|
||||
|
@ -156,8 +156,8 @@ func TestAddConnectionCommandMarshalSupport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveConnectionCommandMarshalSupport(t *testing.T) {
|
||||
commandInput := &RemoveConnectionCommand{
|
||||
Type: "removeConnection",
|
||||
commandInput := &RemoveProxy{
|
||||
Type: "removeProxy",
|
||||
SourceIP: "192.168.0.139",
|
||||
SourcePort: 19132,
|
||||
DestPort: 19132,
|
||||
|
@ -186,7 +186,7 @@ func TestRemoveConnectionCommandMarshalSupport(t *testing.T) {
|
|||
log.Print("command type does not match up!")
|
||||
}
|
||||
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*RemoveConnectionCommand)
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*RemoveProxy)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("failed typecast")
|
||||
|
@ -219,9 +219,9 @@ func TestRemoveConnectionCommandMarshalSupport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAllConnectionsCommandMarshalSupport(t *testing.T) {
|
||||
commandInput := &ConnectionsResponse{
|
||||
Type: "connectionsResponse",
|
||||
Connections: []*ClientConnection{
|
||||
commandInput := &ProxyConnectionsResponse{
|
||||
Type: "proxyConnectionsResponse",
|
||||
Connections: []*ProxyClientConnection{
|
||||
{
|
||||
SourceIP: "127.0.0.1",
|
||||
SourcePort: 19132,
|
||||
|
@ -268,7 +268,7 @@ func TestGetAllConnectionsCommandMarshalSupport(t *testing.T) {
|
|||
log.Print("command type does not match up!")
|
||||
}
|
||||
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ConnectionsResponse)
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyConnectionsResponse)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("failed typecast")
|
||||
|
@ -702,8 +702,8 @@ func TestProxyStatusResponseMarshalSupport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProxyConnectionRequestMarshalSupport(t *testing.T) {
|
||||
commandInput := &ProxyConnectionRequest{
|
||||
Type: "proxyConnectionRequest",
|
||||
commandInput := &ProxyInstanceRequest{
|
||||
Type: "proxyInstanceRequest",
|
||||
}
|
||||
|
||||
commandMarshalled, err := Marshal(commandInput.Type, commandInput)
|
||||
|
@ -728,7 +728,7 @@ func TestProxyConnectionRequestMarshalSupport(t *testing.T) {
|
|||
log.Print("command type does not match up!")
|
||||
}
|
||||
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyConnectionRequest)
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyInstanceRequest)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("failed typecast")
|
||||
|
@ -741,9 +741,9 @@ func TestProxyConnectionRequestMarshalSupport(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProxyConnectionResponseMarshalSupport(t *testing.T) {
|
||||
commandInput := &ProxyConnectionResponse{
|
||||
Type: "proxyConnectionResponse",
|
||||
Proxies: []*ProxyConnection{
|
||||
commandInput := &ProxyInstanceResponse{
|
||||
Type: "proxyInstanceResponse",
|
||||
Proxies: []*ProxyInstance{
|
||||
{
|
||||
SourceIP: "192.168.0.168",
|
||||
SourcePort: 25565,
|
||||
|
@ -787,7 +787,7 @@ func TestProxyConnectionResponseMarshalSupport(t *testing.T) {
|
|||
log.Print("command type does not match up!")
|
||||
}
|
||||
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyConnectionResponse)
|
||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyInstanceResponse)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("failed typecast")
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"net"
|
||||
)
|
||||
|
||||
func unmarshalIndividualConnectionStruct(conn io.Reader) (*ClientConnection, error) {
|
||||
func unmarshalIndividualConnectionStruct(conn io.Reader) (*ProxyClientConnection, error) {
|
||||
serverIPVersion := make([]byte, 1)
|
||||
|
||||
if _, err := conn.Read(serverIPVersion); err != nil {
|
||||
|
@ -70,7 +70,7 @@ func unmarshalIndividualConnectionStruct(conn io.Reader) (*ClientConnection, err
|
|||
return nil, fmt.Errorf("couldn't read source port")
|
||||
}
|
||||
|
||||
return &ClientConnection{
|
||||
return &ProxyClientConnection{
|
||||
SourceIP: serverIP.String(),
|
||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||
DestPort: binary.BigEndian.Uint16(destinationPort),
|
||||
|
@ -79,7 +79,7 @@ func unmarshalIndividualConnectionStruct(conn io.Reader) (*ClientConnection, err
|
|||
}, nil
|
||||
}
|
||||
|
||||
func unmarshalIndividualProxyStruct(conn io.Reader) (*ProxyConnection, error) {
|
||||
func unmarshalIndividualProxyStruct(conn io.Reader) (*ProxyInstance, error) {
|
||||
ipVersion := make([]byte, 1)
|
||||
|
||||
if _, err := conn.Read(ipVersion); err != nil {
|
||||
|
@ -130,7 +130,7 @@ func unmarshalIndividualProxyStruct(conn io.Reader) (*ProxyConnection, error) {
|
|||
return nil, fmt.Errorf("invalid protocol")
|
||||
}
|
||||
|
||||
return &ProxyConnection{
|
||||
return &ProxyInstance{
|
||||
SourceIP: ip.String(),
|
||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||
DestPort: binary.BigEndian.Uint16(destPort),
|
||||
|
@ -146,7 +146,7 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
}
|
||||
|
||||
switch commandType[0] {
|
||||
case StartCommandID:
|
||||
case StartID:
|
||||
argumentsLength := make([]byte, 2)
|
||||
|
||||
if _, err := conn.Read(argumentsLength); err != nil {
|
||||
|
@ -159,15 +159,15 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
return "", nil, fmt.Errorf("couldn't read arguments")
|
||||
}
|
||||
|
||||
return "start", &StartCommand{
|
||||
return "start", &Start{
|
||||
Type: "start",
|
||||
Arguments: arguments,
|
||||
}, nil
|
||||
case StopCommandID:
|
||||
return "stop", &StopCommand{
|
||||
case StopID:
|
||||
return "stop", &Stop{
|
||||
Type: "stop",
|
||||
}, nil
|
||||
case AddConnectionCommandID:
|
||||
case AddProxyID:
|
||||
ipVersion := make([]byte, 1)
|
||||
|
||||
if _, err := conn.Read(ipVersion); err != nil {
|
||||
|
@ -218,14 +218,14 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
return "", nil, fmt.Errorf("invalid protocol")
|
||||
}
|
||||
|
||||
return "addConnection", &AddConnectionCommand{
|
||||
Type: "addConnection",
|
||||
return "addProxy", &AddProxy{
|
||||
Type: "addProxy",
|
||||
SourceIP: ip.String(),
|
||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||
DestPort: binary.BigEndian.Uint16(destPort),
|
||||
Protocol: protocol,
|
||||
}, nil
|
||||
case RemoveConnectionCommandID:
|
||||
case RemoveProxyID:
|
||||
ipVersion := make([]byte, 1)
|
||||
|
||||
if _, err := conn.Read(ipVersion); err != nil {
|
||||
|
@ -276,15 +276,15 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
return "", nil, fmt.Errorf("invalid protocol")
|
||||
}
|
||||
|
||||
return "removeConnection", &RemoveConnectionCommand{
|
||||
Type: "removeConnection",
|
||||
return "removeProxy", &RemoveProxy{
|
||||
Type: "removeProxy",
|
||||
SourceIP: ip.String(),
|
||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||
DestPort: binary.BigEndian.Uint16(destPort),
|
||||
Protocol: protocol,
|
||||
}, nil
|
||||
case GetAllConnectionsID:
|
||||
connections := []*ClientConnection{}
|
||||
case ProxyConnectionsResponseID:
|
||||
connections := []*ProxyClientConnection{}
|
||||
delimiter := make([]byte, 1)
|
||||
var errorReturn error
|
||||
|
||||
|
@ -313,8 +313,8 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return "connectionsResponse", &ConnectionsResponse{
|
||||
Type: "connectionsResponse",
|
||||
return "proxyConnectionsResponse", &ProxyConnectionsResponse{
|
||||
Type: "proxyConnectionsResponse",
|
||||
Connections: connections,
|
||||
}, errorReturn
|
||||
case CheckClientParametersID:
|
||||
|
@ -605,12 +605,12 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
Protocol: protocol,
|
||||
IsActive: isActive[0] == 1,
|
||||
}, nil
|
||||
case ProxyConnectionRequestID:
|
||||
return "proxyConnectionRequest", &ProxyConnectionRequest{
|
||||
Type: "proxyConnectionRequest",
|
||||
case ProxyInstanceRequestID:
|
||||
return "proxyInstanceRequest", &ProxyInstanceRequest{
|
||||
Type: "proxyInstanceRequest",
|
||||
}, nil
|
||||
case ProxyConnectionResponseID:
|
||||
proxies := []*ProxyConnection{}
|
||||
case ProxyInstanceResponseID:
|
||||
proxies := []*ProxyInstance{}
|
||||
delimiter := make([]byte, 1)
|
||||
var errorReturn error
|
||||
|
||||
|
@ -639,15 +639,15 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return "proxyConnectionResponse", &ProxyConnectionResponse{
|
||||
Type: "proxyConnectionResponse",
|
||||
return "proxyInstanceResponse", &ProxyInstanceResponse{
|
||||
Type: "proxyInstanceResponse",
|
||||
Proxies: proxies,
|
||||
}, errorReturn
|
||||
case GetAllConnectionsRequestID:
|
||||
return "getAllConnectionsRequest", &GetAllConnectionsRequest{
|
||||
Type: "getAllConnectionsRequest",
|
||||
case ProxyConnectionsRequestID:
|
||||
return "proxyConnectionsRequest", &ProxyConnectionsRequest{
|
||||
Type: "proxyConnectionsRequest",
|
||||
}, nil
|
||||
}
|
||||
|
||||
return "", nil, fmt.Errorf("couldn't match command")
|
||||
return "", nil, fmt.Errorf("couldn't match command ID")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue