feature: Adds remote implementation of code.
This commit is contained in:
parent
cf90ddb104
commit
432d457ad7
4 changed files with 396 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
|||
package backendutil_custom
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
|
@ -33,6 +34,8 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
return err
|
||||
}
|
||||
|
||||
helper.Backend.OnSocketConnection(helper.socket)
|
||||
|
||||
log.Debug("Sucessfully connected")
|
||||
|
||||
for {
|
||||
|
@ -84,6 +87,46 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
}
|
||||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case *datacommands.ProxyInformationRequest:
|
||||
response := helper.Backend.ResolveProxy(command.ProxyID)
|
||||
responseMarshalled, err := datacommands.Marshal(response)
|
||||
|
||||
if err != nil {
|
||||
log.Error("failed to marshal response: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case *datacommands.ProxyConnectionInformationRequest:
|
||||
response := helper.Backend.ResolveConnection(command.ProxyID, command.ConnectionID)
|
||||
responseMarshalled, err := datacommands.Marshal(response)
|
||||
|
||||
if err != nil {
|
||||
log.Error("failed to marshal response: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case *datacommands.TCPConnectionClosed:
|
||||
helper.Backend.OnTCPConnectionClosed(command.ProxyID, command.ConnectionID)
|
||||
case *datacommands.TCPProxyData:
|
||||
bytes := make([]byte, command.DataLength)
|
||||
_, err := io.ReadFull(helper.socket, bytes)
|
||||
|
||||
if err != nil {
|
||||
log.Warn("failed to read TCP data")
|
||||
}
|
||||
|
||||
helper.Backend.HandleTCPMessage(command, bytes)
|
||||
case *datacommands.UDPProxyData:
|
||||
bytes := make([]byte, command.DataLength)
|
||||
_, err := io.ReadFull(helper.socket, bytes)
|
||||
|
||||
if err != nil {
|
||||
log.Warn("failed to read TCP data")
|
||||
}
|
||||
|
||||
helper.Backend.HandleUDPMessage(command, bytes)
|
||||
default:
|
||||
commandRaw, err := commonbackend.Unmarshal(helper.socket)
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package backendutil_custom
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"git.terah.dev/imterah/hermes/backend/commonbackend"
|
||||
"git.terah.dev/imterah/hermes/backend/sshappbackend/datacommands"
|
||||
)
|
||||
|
@ -14,9 +16,11 @@ type BackendInterface interface {
|
|||
GetAllProxies() []uint16
|
||||
ResolveProxy(proxyID uint16) *datacommands.ProxyInformationResponse
|
||||
GetAllClientConnections(proxyID uint16) []uint16
|
||||
ResolveConnection(connectionID uint16) *datacommands.ProxyConnectionsResponse
|
||||
ResolveConnection(proxyID, connectionID uint16) *datacommands.ProxyConnectionInformationResponse
|
||||
CheckParametersForConnections(clientParameters *commonbackend.CheckClientParameters) *commonbackend.CheckParametersResponse
|
||||
CheckParametersForBackend(arguments []byte) *commonbackend.CheckParametersResponse
|
||||
OnTCPConnectionClosed(proxyID, connectionID uint16)
|
||||
HandleTCPMessage(message *datacommands.TCPProxyData, data []byte)
|
||||
HandleUDPMessage(message *datacommands.UDPProxyData, data []byte)
|
||||
OnSocketConnection(sock net.Conn)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue