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 totalSize += len(connectionsArray[connIndex]) + 1
} }
if totalSize == 0 {
totalSize = 1
}
connectionCommandArray := make([]byte, totalSize+1) connectionCommandArray := make([]byte, totalSize+1)
connectionCommandArray[0] = ProxyConnectionsResponseID connectionCommandArray[0] = ProxyConnectionsResponseID
@ -463,6 +467,10 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
totalSize += len(proxyArray[proxyIndex]) + 1 totalSize += len(proxyArray[proxyIndex]) + 1
} }
if totalSize == 0 {
totalSize = 1
}
connectionCommandArray := make([]byte, totalSize+1) connectionCommandArray := make([]byte, totalSize+1)
connectionCommandArray[0] = ProxyInstanceResponseID connectionCommandArray[0] = ProxyInstanceResponseID
@ -475,6 +483,7 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
} }
connectionCommandArray[totalSize] = '\n' connectionCommandArray[totalSize] = '\n'
return connectionCommandArray, nil return connectionCommandArray, nil
case "proxyInstanceRequest": case "proxyInstanceRequest":
_, ok := command.(*ProxyInstanceRequest) _, ok := command.(*ProxyInstanceRequest)

View file

@ -20,6 +20,8 @@ func unmarshalIndividualConnectionStruct(conn io.Reader) (*ProxyClientConnection
serverIPSize = IPv4Size serverIPSize = IPv4Size
} else if serverIPVersion[0] == 6 { } else if serverIPVersion[0] == 6 {
serverIPSize = IPv6Size serverIPSize = IPv6Size
} else if serverIPVersion[0] == '\n' {
return nil, fmt.Errorf("no data found")
} else { } else {
return nil, fmt.Errorf("invalid server IP version recieved") return nil, fmt.Errorf("invalid server IP version recieved")
} }
@ -92,6 +94,8 @@ func unmarshalIndividualProxyStruct(conn io.Reader) (*ProxyInstance, error) {
ipSize = IPv4Size ipSize = IPv4Size
} else if ipVersion[0] == 6 { } else if ipVersion[0] == 6 {
ipSize = IPv6Size ipSize = IPv6Size
} else if ipVersion[0] == '\n' {
return nil, fmt.Errorf("no data found")
} else { } else {
return nil, fmt.Errorf("invalid IP version recieved") return nil, fmt.Errorf("invalid IP version recieved")
} }
@ -293,6 +297,10 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
connection, err := unmarshalIndividualConnectionStruct(conn) connection, err := unmarshalIndividualConnectionStruct(conn)
if err != nil { if err != nil {
if err.Error() == "no data found" {
break
}
return "", nil, err return "", nil, err
} }
@ -619,6 +627,10 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
proxy, err := unmarshalIndividualProxyStruct(conn) proxy, err := unmarshalIndividualProxyStruct(conn)
if err != nil { if err != nil {
if err.Error() == "no data found" {
break
}
return "", nil, err return "", nil, err
} }

View file

@ -13,6 +13,6 @@ post {
body:json { body:json {
{ {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY",
"id": 1 "id": 2
} }
} }

View file

@ -13,6 +13,6 @@ post {
body:json { body:json {
{ {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY",
"id": 1 "id": 2
} }
} }