fix: Fixes getting inbound connections.

This commit is contained in:
Tera << 8 2024-12-23 21:45:26 -05:00
parent bcf97fde6d
commit 8ba0424512
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
4 changed files with 23 additions and 2 deletions

View file

@ -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)

View file

@ -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
}