fix: Fixes getting inbound connections.
This commit is contained in:
parent
bcf97fde6d
commit
8ba0424512
4 changed files with 23 additions and 2 deletions
|
@ -206,6 +206,10 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
totalSize += len(connectionsArray[connIndex]) + 1
|
||||
}
|
||||
|
||||
if totalSize == 0 {
|
||||
totalSize = 1
|
||||
}
|
||||
|
||||
connectionCommandArray := make([]byte, totalSize+1)
|
||||
connectionCommandArray[0] = ProxyConnectionsResponseID
|
||||
|
||||
|
@ -463,6 +467,10 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
totalSize += len(proxyArray[proxyIndex]) + 1
|
||||
}
|
||||
|
||||
if totalSize == 0 {
|
||||
totalSize = 1
|
||||
}
|
||||
|
||||
connectionCommandArray := make([]byte, totalSize+1)
|
||||
connectionCommandArray[0] = ProxyInstanceResponseID
|
||||
|
||||
|
@ -475,6 +483,7 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
|||
}
|
||||
|
||||
connectionCommandArray[totalSize] = '\n'
|
||||
|
||||
return connectionCommandArray, nil
|
||||
case "proxyInstanceRequest":
|
||||
_, ok := command.(*ProxyInstanceRequest)
|
||||
|
|
|
@ -20,6 +20,8 @@ func unmarshalIndividualConnectionStruct(conn io.Reader) (*ProxyClientConnection
|
|||
serverIPSize = IPv4Size
|
||||
} else if serverIPVersion[0] == 6 {
|
||||
serverIPSize = IPv6Size
|
||||
} else if serverIPVersion[0] == '\n' {
|
||||
return nil, fmt.Errorf("no data found")
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid server IP version recieved")
|
||||
}
|
||||
|
@ -92,6 +94,8 @@ func unmarshalIndividualProxyStruct(conn io.Reader) (*ProxyInstance, error) {
|
|||
ipSize = IPv4Size
|
||||
} else if ipVersion[0] == 6 {
|
||||
ipSize = IPv6Size
|
||||
} else if ipVersion[0] == '\n' {
|
||||
return nil, fmt.Errorf("no data found")
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid IP version recieved")
|
||||
}
|
||||
|
@ -293,6 +297,10 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
connection, err := unmarshalIndividualConnectionStruct(conn)
|
||||
|
||||
if err != nil {
|
||||
if err.Error() == "no data found" {
|
||||
break
|
||||
}
|
||||
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
|
@ -619,6 +627,10 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
|||
proxy, err := unmarshalIndividualProxyStruct(conn)
|
||||
|
||||
if err != nil {
|
||||
if err.Error() == "no data found" {
|
||||
break
|
||||
}
|
||||
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue