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
|
@ -17,6 +17,9 @@ type BackendApplicationHelper struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (helper *BackendApplicationHelper) Start() error {
|
func (helper *BackendApplicationHelper) Start() error {
|
||||||
|
log.Debug("BackendApplicationHelper is starting")
|
||||||
|
log.Debug("Currently waiting for Unix socket connection...")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
helper.socket, err = net.Dial("unix", helper.SocketPath)
|
helper.socket, err = net.Dial("unix", helper.SocketPath)
|
||||||
|
|
||||||
|
@ -24,6 +27,8 @@ func (helper *BackendApplicationHelper) Start() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debug("Sucessfully connected")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
commandType, commandRaw, err := commonbackend.Unmarshal(helper.socket)
|
commandType, commandRaw, err := commonbackend.Unmarshal(helper.socket)
|
||||||
|
|
||||||
|
@ -34,7 +39,7 @@ func (helper *BackendApplicationHelper) Start() error {
|
||||||
switch commandType {
|
switch commandType {
|
||||||
case "start":
|
case "start":
|
||||||
// TODO: implement response logic
|
// TODO: implement response logic
|
||||||
command, ok := commandRaw.(*commonbackend.StartCommand)
|
command, ok := commandRaw.(*commonbackend.Start)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("failed to typecast")
|
return fmt.Errorf("failed to typecast")
|
||||||
|
@ -44,33 +49,33 @@ func (helper *BackendApplicationHelper) Start() error {
|
||||||
_, _ = helper.Backend.StartBackend(command.Arguments)
|
_, _ = helper.Backend.StartBackend(command.Arguments)
|
||||||
case "stop":
|
case "stop":
|
||||||
// TODO: implement response logic
|
// TODO: implement response logic
|
||||||
_, ok := commandRaw.(*commonbackend.StopCommand)
|
_, ok := commandRaw.(*commonbackend.Stop)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("failed to typecast")
|
return fmt.Errorf("failed to typecast")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = helper.Backend.StopBackend()
|
_, _ = helper.Backend.StopBackend()
|
||||||
case "addConnection":
|
case "addProxy":
|
||||||
// TODO: implement response logic
|
// TODO: implement response logic
|
||||||
command, ok := commandRaw.(*commonbackend.AddConnectionCommand)
|
command, ok := commandRaw.(*commonbackend.AddProxy)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("failed to typecast")
|
return fmt.Errorf("failed to typecast")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = helper.Backend.StartProxy(command)
|
_, _ = helper.Backend.StartProxy(command)
|
||||||
case "removeConnection":
|
case "removeProxy":
|
||||||
// TODO: implement response logic
|
// TODO: implement response logic
|
||||||
command, ok := commandRaw.(*commonbackend.RemoveConnectionCommand)
|
command, ok := commandRaw.(*commonbackend.RemoveProxy)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("failed to typecast")
|
return fmt.Errorf("failed to typecast")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = helper.Backend.StopProxy(command)
|
_, _ = helper.Backend.StopProxy(command)
|
||||||
case "getAllConnections":
|
case "proxyConnectionsRequest":
|
||||||
_, ok := commandRaw.(*commonbackend.AddConnectionCommand)
|
_, ok := commandRaw.(*commonbackend.ProxyConnectionsRequest)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("failed to typecast")
|
return fmt.Errorf("failed to typecast")
|
||||||
|
@ -78,8 +83,8 @@ func (helper *BackendApplicationHelper) Start() error {
|
||||||
|
|
||||||
connections := helper.Backend.GetAllClientConnections()
|
connections := helper.Backend.GetAllClientConnections()
|
||||||
|
|
||||||
serverParams := &commonbackend.ConnectionsResponse{
|
serverParams := &commonbackend.ProxyConnectionsResponse{
|
||||||
Type: "connectionsResponse",
|
Type: "proxyConnectionsResponse",
|
||||||
Connections: connections,
|
Connections: connections,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ import "git.greysoh.dev/imterah/nextnet/commonbackend"
|
||||||
type BackendInterface interface {
|
type BackendInterface interface {
|
||||||
StartBackend(arguments []byte) (bool, error)
|
StartBackend(arguments []byte) (bool, error)
|
||||||
StopBackend() (bool, error)
|
StopBackend() (bool, error)
|
||||||
StartProxy(command *commonbackend.AddConnectionCommand) (bool, error)
|
StartProxy(command *commonbackend.AddProxy) (bool, error)
|
||||||
StopProxy(command *commonbackend.RemoveConnectionCommand) (bool, error)
|
StopProxy(command *commonbackend.RemoveProxy) (bool, error)
|
||||||
GetAllClientConnections() []*commonbackend.ClientConnection
|
GetAllClientConnections() []*commonbackend.ProxyClientConnection
|
||||||
CheckParametersForConnections(clientParameters *commonbackend.CheckClientParameters) *commonbackend.CheckParametersResponse
|
CheckParametersForConnections(clientParameters *commonbackend.CheckClientParameters) *commonbackend.CheckParametersResponse
|
||||||
CheckParametersForBackend(arguments []byte) *commonbackend.CheckParametersResponse
|
CheckParametersForBackend(arguments []byte) *commonbackend.CheckParametersResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,25 @@ package commonbackend
|
||||||
// TODO (imterah): Rename AddConnectionCommand/RemoveConnectionCommand to AddProxyCommand/RemoveProxyCommand
|
// TODO (imterah): Rename AddConnectionCommand/RemoveConnectionCommand to AddProxyCommand/RemoveProxyCommand
|
||||||
// and their associated function calls
|
// and their associated function calls
|
||||||
|
|
||||||
type StartCommand struct {
|
type Start struct {
|
||||||
Type string // Will be 'start' always
|
Type string // Will be 'start' always
|
||||||
Arguments []byte
|
Arguments []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type StopCommand struct {
|
type Stop struct {
|
||||||
Type string // Will be 'stop' always
|
Type string // Will be 'stop' always
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddConnectionCommand struct {
|
type AddProxy struct {
|
||||||
Type string // Will be 'addConnection' always
|
Type string // Will be 'addProxy' always
|
||||||
SourceIP string
|
SourceIP string
|
||||||
SourcePort uint16
|
SourcePort uint16
|
||||||
DestPort uint16
|
DestPort uint16
|
||||||
Protocol string // Will be either 'tcp' or 'udp'
|
Protocol string // Will be either 'tcp' or 'udp'
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoveConnectionCommand struct {
|
type RemoveProxy struct {
|
||||||
Type string // Will be 'removeConnection' always
|
Type string // Will be 'removeProxy' always
|
||||||
SourceIP string
|
SourceIP string
|
||||||
SourcePort uint16
|
SourcePort uint16
|
||||||
DestPort uint16
|
DestPort uint16
|
||||||
|
@ -45,25 +45,25 @@ type ProxyStatusResponse struct {
|
||||||
IsActive bool
|
IsActive bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProxyConnection struct {
|
type ProxyInstance struct {
|
||||||
SourceIP string
|
SourceIP string
|
||||||
SourcePort uint16
|
SourcePort uint16
|
||||||
DestPort uint16
|
DestPort uint16
|
||||||
Protocol string // Will be either 'tcp' or 'udp'
|
Protocol string // Will be either 'tcp' or 'udp'
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProxyConnectionResponse struct {
|
type ProxyInstanceResponse struct {
|
||||||
Type string // Will be 'proxyConnectionResponse' always
|
Type string // Will be 'proxyConnectionResponse' always
|
||||||
Proxies []*ProxyConnection // List of connections
|
Proxies []*ProxyInstance // List of connections
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProxyConnectionRequest struct {
|
type ProxyInstanceRequest struct {
|
||||||
Type string // Will be 'proxyConnectionRequest' always
|
Type string // Will be 'proxyConnectionRequest' always
|
||||||
}
|
}
|
||||||
|
|
||||||
type BackendStatusResponse struct {
|
type BackendStatusResponse struct {
|
||||||
Type string // Will be 'backendStatusResponse' always
|
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
|
StatusCode int // Either the 'Success' or 'Failure' constant
|
||||||
Message string // String message from the client (ex. failed to dial TCP)
|
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 string // Will be 'backendStatusRequest' always
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetAllConnectionsRequest struct {
|
type ProxyConnectionsRequest struct {
|
||||||
Type string // Will be 'getAllConnectionsRequest' always
|
Type string // Will be 'proxyConnectionsRequest' always
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientConnection struct {
|
// Client's connection to a specific proxy
|
||||||
|
type ProxyClientConnection struct {
|
||||||
SourceIP string
|
SourceIP string
|
||||||
SourcePort uint16
|
SourcePort uint16
|
||||||
DestPort uint16
|
DestPort uint16
|
||||||
|
@ -84,9 +85,9 @@ type ClientConnection struct {
|
||||||
ClientPort uint16
|
ClientPort uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConnectionsResponse struct {
|
type ProxyConnectionsResponse struct {
|
||||||
Type string // Will be 'connectionsResponse' always
|
Type string // Will be 'proxyConnectionsResponse' always
|
||||||
Connections []*ClientConnection // List of connections
|
Connections []*ProxyClientConnection // List of connections
|
||||||
}
|
}
|
||||||
|
|
||||||
type CheckClientParameters struct {
|
type CheckClientParameters struct {
|
||||||
|
@ -111,22 +112,21 @@ type CheckParametersResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StartCommandID = iota
|
StartID = iota
|
||||||
StopCommandID
|
StopID
|
||||||
AddConnectionCommandID
|
AddProxyID
|
||||||
RemoveConnectionCommandID
|
RemoveProxyID
|
||||||
ClientConnectionID
|
ProxyConnectionsResponseID
|
||||||
GetAllConnectionsID
|
|
||||||
CheckClientParametersID
|
CheckClientParametersID
|
||||||
CheckServerParametersID
|
CheckServerParametersID
|
||||||
CheckParametersResponseID
|
CheckParametersResponseID
|
||||||
GetAllConnectionsRequestID
|
ProxyConnectionsRequestID
|
||||||
BackendStatusResponseID
|
BackendStatusResponseID
|
||||||
BackendStatusRequestID
|
BackendStatusRequestID
|
||||||
ProxyStatusRequestID
|
ProxyStatusRequestID
|
||||||
ProxyStatusResponseID
|
ProxyStatusResponseID
|
||||||
ProxyConnectionResponseID
|
ProxyInstanceResponseID
|
||||||
ProxyConnectionRequestID
|
ProxyInstanceRequestID
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
func marshalIndividualConnectionStruct(conn *ClientConnection) []byte {
|
func marshalIndividualConnectionStruct(conn *ProxyClientConnection) []byte {
|
||||||
sourceIPOriginal := net.ParseIP(conn.SourceIP)
|
sourceIPOriginal := net.ParseIP(conn.SourceIP)
|
||||||
clientIPOriginal := net.ParseIP(conn.ClientIP)
|
clientIPOriginal := net.ParseIP(conn.ClientIP)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func marshalIndividualConnectionStruct(conn *ClientConnection) []byte {
|
||||||
return connectionBlock
|
return connectionBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalIndividualProxyStruct(conn *ProxyConnection) ([]byte, error) {
|
func marshalIndividualProxyStruct(conn *ProxyInstance) ([]byte, error) {
|
||||||
sourceIPOriginal := net.ParseIP(conn.SourceIP)
|
sourceIPOriginal := net.ParseIP(conn.SourceIP)
|
||||||
|
|
||||||
var sourceIPVer uint8
|
var sourceIPVer uint8
|
||||||
|
@ -87,28 +87,28 @@ func marshalIndividualProxyStruct(conn *ProxyConnection) ([]byte, error) {
|
||||||
func Marshal(commandType string, command interface{}) ([]byte, error) {
|
func Marshal(commandType string, command interface{}) ([]byte, error) {
|
||||||
switch commandType {
|
switch commandType {
|
||||||
case "start":
|
case "start":
|
||||||
startCommand, ok := command.(*StartCommand)
|
startCommand, ok := command.(*Start)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
return nil, fmt.Errorf("failed to typecast")
|
||||||
}
|
}
|
||||||
|
|
||||||
startCommandBytes := make([]byte, 1+2+len(startCommand.Arguments))
|
startCommandBytes := make([]byte, 1+2+len(startCommand.Arguments))
|
||||||
startCommandBytes[0] = StartCommandID
|
startCommandBytes[0] = StartID
|
||||||
binary.BigEndian.PutUint16(startCommandBytes[1:3], uint16(len(startCommand.Arguments)))
|
binary.BigEndian.PutUint16(startCommandBytes[1:3], uint16(len(startCommand.Arguments)))
|
||||||
copy(startCommandBytes[3:], startCommand.Arguments)
|
copy(startCommandBytes[3:], startCommand.Arguments)
|
||||||
|
|
||||||
return startCommandBytes, nil
|
return startCommandBytes, nil
|
||||||
case "stop":
|
case "stop":
|
||||||
_, ok := command.(*StopCommand)
|
_, ok := command.(*Stop)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
return nil, fmt.Errorf("failed to typecast")
|
||||||
}
|
}
|
||||||
|
|
||||||
return []byte{StopCommandID}, nil
|
return []byte{StopID}, nil
|
||||||
case "addConnection":
|
case "addProxy":
|
||||||
addConnectionCommand, ok := command.(*AddConnectionCommand)
|
addConnectionCommand, ok := command.(*AddProxy)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
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 := make([]byte, 1+1+len(ipBytes)+2+2+1)
|
||||||
|
|
||||||
addConnectionBytes[0] = AddConnectionCommandID
|
addConnectionBytes[0] = AddProxyID
|
||||||
addConnectionBytes[1] = ipVer
|
addConnectionBytes[1] = ipVer
|
||||||
|
|
||||||
copy(addConnectionBytes[2:2+len(ipBytes)], ipBytes)
|
copy(addConnectionBytes[2:2+len(ipBytes)], ipBytes)
|
||||||
|
@ -150,8 +150,8 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
||||||
addConnectionBytes[6+len(ipBytes)] = protocol
|
addConnectionBytes[6+len(ipBytes)] = protocol
|
||||||
|
|
||||||
return addConnectionBytes, nil
|
return addConnectionBytes, nil
|
||||||
case "removeConnection":
|
case "removeProxy":
|
||||||
removeConnectionCommand, ok := command.(*RemoveConnectionCommand)
|
removeConnectionCommand, ok := command.(*RemoveProxy)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
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 := make([]byte, 1+1+len(ipBytes)+2+2+1)
|
||||||
|
|
||||||
removeConnectionBytes[0] = RemoveConnectionCommandID
|
removeConnectionBytes[0] = RemoveProxyID
|
||||||
removeConnectionBytes[1] = ipVer
|
removeConnectionBytes[1] = ipVer
|
||||||
copy(removeConnectionBytes[2:2+len(ipBytes)], ipBytes)
|
copy(removeConnectionBytes[2:2+len(ipBytes)], ipBytes)
|
||||||
binary.BigEndian.PutUint16(removeConnectionBytes[2+len(ipBytes):4+len(ipBytes)], removeConnectionCommand.SourcePort)
|
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
|
removeConnectionBytes[6+len(ipBytes)] = protocol
|
||||||
|
|
||||||
return removeConnectionBytes, nil
|
return removeConnectionBytes, nil
|
||||||
case "connectionsResponse":
|
case "proxyConnectionsResponse":
|
||||||
allConnectionsCommand, ok := command.(*ConnectionsResponse)
|
allConnectionsCommand, ok := command.(*ProxyConnectionsResponse)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
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 := make([]byte, totalSize+1)
|
||||||
connectionCommandArray[0] = GetAllConnectionsID
|
connectionCommandArray[0] = ProxyConnectionsResponseID
|
||||||
|
|
||||||
currentPosition := 1
|
currentPosition := 1
|
||||||
|
|
||||||
|
@ -442,8 +442,8 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
||||||
proxyStatusResponseBytes[7+len(ipBytes)] = isActive
|
proxyStatusResponseBytes[7+len(ipBytes)] = isActive
|
||||||
|
|
||||||
return proxyStatusResponseBytes, nil
|
return proxyStatusResponseBytes, nil
|
||||||
case "proxyConnectionResponse":
|
case "proxyInstanceResponse":
|
||||||
proxyConectionResponse, ok := command.(*ProxyConnectionResponse)
|
proxyConectionResponse, ok := command.(*ProxyInstanceResponse)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
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 := make([]byte, totalSize+1)
|
||||||
connectionCommandArray[0] = ProxyConnectionResponseID
|
connectionCommandArray[0] = ProxyInstanceResponseID
|
||||||
|
|
||||||
currentPosition := 1
|
currentPosition := 1
|
||||||
|
|
||||||
|
@ -476,23 +476,23 @@ func Marshal(commandType string, command interface{}) ([]byte, error) {
|
||||||
|
|
||||||
connectionCommandArray[totalSize] = '\n'
|
connectionCommandArray[totalSize] = '\n'
|
||||||
return connectionCommandArray, nil
|
return connectionCommandArray, nil
|
||||||
case "proxyConnectionRequest":
|
case "proxyInstanceRequest":
|
||||||
_, ok := command.(*ProxyConnectionRequest)
|
_, ok := command.(*ProxyInstanceRequest)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
return nil, fmt.Errorf("failed to typecast")
|
||||||
}
|
}
|
||||||
|
|
||||||
return []byte{ProxyConnectionRequestID}, nil
|
return []byte{ProxyInstanceRequestID}, nil
|
||||||
case "getAllConnectionsRequest":
|
case "proxyConnectionsRequest":
|
||||||
_, ok := command.(*GetAllConnectionsRequest)
|
_, ok := command.(*ProxyConnectionsRequest)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to typecast")
|
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")
|
var logLevel = os.Getenv("NEXTNET_LOG_LEVEL")
|
||||||
|
|
||||||
func TestStartCommandMarshalSupport(t *testing.T) {
|
func TestStartCommandMarshalSupport(t *testing.T) {
|
||||||
commandInput := &StartCommand{
|
commandInput := &Start{
|
||||||
Type: "start",
|
Type: "start",
|
||||||
Arguments: []byte("Hello from automated testing"),
|
Arguments: []byte("Hello from automated testing"),
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func TestStartCommandMarshalSupport(t *testing.T) {
|
||||||
log.Print("command type does not match up!")
|
log.Print("command type does not match up!")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*StartCommand)
|
commandUnmarshalled, ok := commandUnmarshalledRaw.(*Start)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed typecast")
|
t.Fatal("failed typecast")
|
||||||
|
@ -54,7 +54,7 @@ func TestStartCommandMarshalSupport(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStopCommandMarshalSupport(t *testing.T) {
|
func TestStopCommandMarshalSupport(t *testing.T) {
|
||||||
commandInput := &StopCommand{
|
commandInput := &Stop{
|
||||||
Type: "stop",
|
Type: "stop",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ func TestStopCommandMarshalSupport(t *testing.T) {
|
||||||
log.Print("command type does not match up!")
|
log.Print("command type does not match up!")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*StopCommand)
|
commandUnmarshalled, ok := commandUnmarshalledRaw.(*Stop)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed typecast")
|
t.Fatal("failed typecast")
|
||||||
|
@ -93,8 +93,8 @@ func TestStopCommandMarshalSupport(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddConnectionCommandMarshalSupport(t *testing.T) {
|
func TestAddConnectionCommandMarshalSupport(t *testing.T) {
|
||||||
commandInput := &AddConnectionCommand{
|
commandInput := &AddProxy{
|
||||||
Type: "addConnection",
|
Type: "addProxy",
|
||||||
SourceIP: "192.168.0.139",
|
SourceIP: "192.168.0.139",
|
||||||
SourcePort: 19132,
|
SourcePort: 19132,
|
||||||
DestPort: 19132,
|
DestPort: 19132,
|
||||||
|
@ -123,7 +123,7 @@ func TestAddConnectionCommandMarshalSupport(t *testing.T) {
|
||||||
log.Print("command type does not match up!")
|
log.Print("command type does not match up!")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*AddConnectionCommand)
|
commandUnmarshalled, ok := commandUnmarshalledRaw.(*AddProxy)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed typecast")
|
t.Fatal("failed typecast")
|
||||||
|
@ -156,8 +156,8 @@ func TestAddConnectionCommandMarshalSupport(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemoveConnectionCommandMarshalSupport(t *testing.T) {
|
func TestRemoveConnectionCommandMarshalSupport(t *testing.T) {
|
||||||
commandInput := &RemoveConnectionCommand{
|
commandInput := &RemoveProxy{
|
||||||
Type: "removeConnection",
|
Type: "removeProxy",
|
||||||
SourceIP: "192.168.0.139",
|
SourceIP: "192.168.0.139",
|
||||||
SourcePort: 19132,
|
SourcePort: 19132,
|
||||||
DestPort: 19132,
|
DestPort: 19132,
|
||||||
|
@ -186,7 +186,7 @@ func TestRemoveConnectionCommandMarshalSupport(t *testing.T) {
|
||||||
log.Print("command type does not match up!")
|
log.Print("command type does not match up!")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*RemoveConnectionCommand)
|
commandUnmarshalled, ok := commandUnmarshalledRaw.(*RemoveProxy)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed typecast")
|
t.Fatal("failed typecast")
|
||||||
|
@ -219,9 +219,9 @@ func TestRemoveConnectionCommandMarshalSupport(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAllConnectionsCommandMarshalSupport(t *testing.T) {
|
func TestGetAllConnectionsCommandMarshalSupport(t *testing.T) {
|
||||||
commandInput := &ConnectionsResponse{
|
commandInput := &ProxyConnectionsResponse{
|
||||||
Type: "connectionsResponse",
|
Type: "proxyConnectionsResponse",
|
||||||
Connections: []*ClientConnection{
|
Connections: []*ProxyClientConnection{
|
||||||
{
|
{
|
||||||
SourceIP: "127.0.0.1",
|
SourceIP: "127.0.0.1",
|
||||||
SourcePort: 19132,
|
SourcePort: 19132,
|
||||||
|
@ -268,7 +268,7 @@ func TestGetAllConnectionsCommandMarshalSupport(t *testing.T) {
|
||||||
log.Print("command type does not match up!")
|
log.Print("command type does not match up!")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ConnectionsResponse)
|
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyConnectionsResponse)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed typecast")
|
t.Fatal("failed typecast")
|
||||||
|
@ -702,8 +702,8 @@ func TestProxyStatusResponseMarshalSupport(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProxyConnectionRequestMarshalSupport(t *testing.T) {
|
func TestProxyConnectionRequestMarshalSupport(t *testing.T) {
|
||||||
commandInput := &ProxyConnectionRequest{
|
commandInput := &ProxyInstanceRequest{
|
||||||
Type: "proxyConnectionRequest",
|
Type: "proxyInstanceRequest",
|
||||||
}
|
}
|
||||||
|
|
||||||
commandMarshalled, err := Marshal(commandInput.Type, commandInput)
|
commandMarshalled, err := Marshal(commandInput.Type, commandInput)
|
||||||
|
@ -728,7 +728,7 @@ func TestProxyConnectionRequestMarshalSupport(t *testing.T) {
|
||||||
log.Print("command type does not match up!")
|
log.Print("command type does not match up!")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyConnectionRequest)
|
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyInstanceRequest)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed typecast")
|
t.Fatal("failed typecast")
|
||||||
|
@ -741,9 +741,9 @@ func TestProxyConnectionRequestMarshalSupport(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProxyConnectionResponseMarshalSupport(t *testing.T) {
|
func TestProxyConnectionResponseMarshalSupport(t *testing.T) {
|
||||||
commandInput := &ProxyConnectionResponse{
|
commandInput := &ProxyInstanceResponse{
|
||||||
Type: "proxyConnectionResponse",
|
Type: "proxyInstanceResponse",
|
||||||
Proxies: []*ProxyConnection{
|
Proxies: []*ProxyInstance{
|
||||||
{
|
{
|
||||||
SourceIP: "192.168.0.168",
|
SourceIP: "192.168.0.168",
|
||||||
SourcePort: 25565,
|
SourcePort: 25565,
|
||||||
|
@ -787,7 +787,7 @@ func TestProxyConnectionResponseMarshalSupport(t *testing.T) {
|
||||||
log.Print("command type does not match up!")
|
log.Print("command type does not match up!")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyConnectionResponse)
|
commandUnmarshalled, ok := commandUnmarshalledRaw.(*ProxyInstanceResponse)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed typecast")
|
t.Fatal("failed typecast")
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
func unmarshalIndividualConnectionStruct(conn io.Reader) (*ClientConnection, error) {
|
func unmarshalIndividualConnectionStruct(conn io.Reader) (*ProxyClientConnection, error) {
|
||||||
serverIPVersion := make([]byte, 1)
|
serverIPVersion := make([]byte, 1)
|
||||||
|
|
||||||
if _, err := conn.Read(serverIPVersion); err != nil {
|
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 nil, fmt.Errorf("couldn't read source port")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ClientConnection{
|
return &ProxyClientConnection{
|
||||||
SourceIP: serverIP.String(),
|
SourceIP: serverIP.String(),
|
||||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||||
DestPort: binary.BigEndian.Uint16(destinationPort),
|
DestPort: binary.BigEndian.Uint16(destinationPort),
|
||||||
|
@ -79,7 +79,7 @@ func unmarshalIndividualConnectionStruct(conn io.Reader) (*ClientConnection, err
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmarshalIndividualProxyStruct(conn io.Reader) (*ProxyConnection, error) {
|
func unmarshalIndividualProxyStruct(conn io.Reader) (*ProxyInstance, error) {
|
||||||
ipVersion := make([]byte, 1)
|
ipVersion := make([]byte, 1)
|
||||||
|
|
||||||
if _, err := conn.Read(ipVersion); err != nil {
|
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 nil, fmt.Errorf("invalid protocol")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ProxyConnection{
|
return &ProxyInstance{
|
||||||
SourceIP: ip.String(),
|
SourceIP: ip.String(),
|
||||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||||
DestPort: binary.BigEndian.Uint16(destPort),
|
DestPort: binary.BigEndian.Uint16(destPort),
|
||||||
|
@ -146,7 +146,7 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch commandType[0] {
|
switch commandType[0] {
|
||||||
case StartCommandID:
|
case StartID:
|
||||||
argumentsLength := make([]byte, 2)
|
argumentsLength := make([]byte, 2)
|
||||||
|
|
||||||
if _, err := conn.Read(argumentsLength); err != nil {
|
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 "", nil, fmt.Errorf("couldn't read arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
return "start", &StartCommand{
|
return "start", &Start{
|
||||||
Type: "start",
|
Type: "start",
|
||||||
Arguments: arguments,
|
Arguments: arguments,
|
||||||
}, nil
|
}, nil
|
||||||
case StopCommandID:
|
case StopID:
|
||||||
return "stop", &StopCommand{
|
return "stop", &Stop{
|
||||||
Type: "stop",
|
Type: "stop",
|
||||||
}, nil
|
}, nil
|
||||||
case AddConnectionCommandID:
|
case AddProxyID:
|
||||||
ipVersion := make([]byte, 1)
|
ipVersion := make([]byte, 1)
|
||||||
|
|
||||||
if _, err := conn.Read(ipVersion); err != nil {
|
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 "", nil, fmt.Errorf("invalid protocol")
|
||||||
}
|
}
|
||||||
|
|
||||||
return "addConnection", &AddConnectionCommand{
|
return "addProxy", &AddProxy{
|
||||||
Type: "addConnection",
|
Type: "addProxy",
|
||||||
SourceIP: ip.String(),
|
SourceIP: ip.String(),
|
||||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||||
DestPort: binary.BigEndian.Uint16(destPort),
|
DestPort: binary.BigEndian.Uint16(destPort),
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
}, nil
|
}, nil
|
||||||
case RemoveConnectionCommandID:
|
case RemoveProxyID:
|
||||||
ipVersion := make([]byte, 1)
|
ipVersion := make([]byte, 1)
|
||||||
|
|
||||||
if _, err := conn.Read(ipVersion); err != nil {
|
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 "", nil, fmt.Errorf("invalid protocol")
|
||||||
}
|
}
|
||||||
|
|
||||||
return "removeConnection", &RemoveConnectionCommand{
|
return "removeProxy", &RemoveProxy{
|
||||||
Type: "removeConnection",
|
Type: "removeProxy",
|
||||||
SourceIP: ip.String(),
|
SourceIP: ip.String(),
|
||||||
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
SourcePort: binary.BigEndian.Uint16(sourcePort),
|
||||||
DestPort: binary.BigEndian.Uint16(destPort),
|
DestPort: binary.BigEndian.Uint16(destPort),
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
}, nil
|
}, nil
|
||||||
case GetAllConnectionsID:
|
case ProxyConnectionsResponseID:
|
||||||
connections := []*ClientConnection{}
|
connections := []*ProxyClientConnection{}
|
||||||
delimiter := make([]byte, 1)
|
delimiter := make([]byte, 1)
|
||||||
var errorReturn error
|
var errorReturn error
|
||||||
|
|
||||||
|
@ -313,8 +313,8 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "connectionsResponse", &ConnectionsResponse{
|
return "proxyConnectionsResponse", &ProxyConnectionsResponse{
|
||||||
Type: "connectionsResponse",
|
Type: "proxyConnectionsResponse",
|
||||||
Connections: connections,
|
Connections: connections,
|
||||||
}, errorReturn
|
}, errorReturn
|
||||||
case CheckClientParametersID:
|
case CheckClientParametersID:
|
||||||
|
@ -605,12 +605,12 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
IsActive: isActive[0] == 1,
|
IsActive: isActive[0] == 1,
|
||||||
}, nil
|
}, nil
|
||||||
case ProxyConnectionRequestID:
|
case ProxyInstanceRequestID:
|
||||||
return "proxyConnectionRequest", &ProxyConnectionRequest{
|
return "proxyInstanceRequest", &ProxyInstanceRequest{
|
||||||
Type: "proxyConnectionRequest",
|
Type: "proxyInstanceRequest",
|
||||||
}, nil
|
}, nil
|
||||||
case ProxyConnectionResponseID:
|
case ProxyInstanceResponseID:
|
||||||
proxies := []*ProxyConnection{}
|
proxies := []*ProxyInstance{}
|
||||||
delimiter := make([]byte, 1)
|
delimiter := make([]byte, 1)
|
||||||
var errorReturn error
|
var errorReturn error
|
||||||
|
|
||||||
|
@ -639,15 +639,15 @@ func Unmarshal(conn io.Reader) (string, interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "proxyConnectionResponse", &ProxyConnectionResponse{
|
return "proxyInstanceResponse", &ProxyInstanceResponse{
|
||||||
Type: "proxyConnectionResponse",
|
Type: "proxyInstanceResponse",
|
||||||
Proxies: proxies,
|
Proxies: proxies,
|
||||||
}, errorReturn
|
}, errorReturn
|
||||||
case GetAllConnectionsRequestID:
|
case ProxyConnectionsRequestID:
|
||||||
return "getAllConnectionsRequest", &GetAllConnectionsRequest{
|
return "proxyConnectionsRequest", &ProxyConnectionsRequest{
|
||||||
Type: "getAllConnectionsRequest",
|
Type: "proxyConnectionsRequest",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", nil, fmt.Errorf("couldn't match command")
|
return "", nil, fmt.Errorf("couldn't match command ID")
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,16 @@ func (backend *DummyBackend) StopBackend() (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *DummyBackend) StartProxy(command *commonbackend.AddConnectionCommand) (bool, error) {
|
func (backend *DummyBackend) StartProxy(command *commonbackend.AddProxy) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *DummyBackend) StopProxy(command *commonbackend.RemoveConnectionCommand) (bool, error) {
|
func (backend *DummyBackend) StopProxy(command *commonbackend.RemoveProxy) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *DummyBackend) GetAllClientConnections() []*commonbackend.ClientConnection {
|
func (backend *DummyBackend) GetAllClientConnections() []*commonbackend.ProxyClientConnection {
|
||||||
return []*commonbackend.ClientConnection{}
|
return []*commonbackend.ProxyClientConnection{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *DummyBackend) CheckParametersForConnections(clientParameters *commonbackend.CheckClientParameters) *commonbackend.CheckParametersResponse {
|
func (backend *DummyBackend) CheckParametersForConnections(clientParameters *commonbackend.CheckClientParameters) *commonbackend.CheckParametersResponse {
|
||||||
|
|
|
@ -19,6 +19,10 @@ func (writer WriteLogger) Write(p []byte) (n int, err error) {
|
||||||
logSplit := strings.Split(string(p), "\n")
|
logSplit := strings.Split(string(p), "\n")
|
||||||
|
|
||||||
for _, line := range logSplit {
|
for _, line := range logSplit {
|
||||||
|
if line == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if writer.UseError {
|
if writer.UseError {
|
||||||
log.Errorf("application: %s", line)
|
log.Errorf("application: %s", line)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,7 @@ type SSHListener struct {
|
||||||
type SSHBackend struct {
|
type SSHBackend struct {
|
||||||
config SSHBackendData
|
config SSHBackendData
|
||||||
conn *ssh.Client
|
conn *ssh.Client
|
||||||
clients []*commonbackend.ClientConnection
|
clients []*commonbackend.ProxyClientConnection
|
||||||
proxies []*SSHListener
|
proxies []*SSHListener
|
||||||
arrayPropMutex sync.Mutex
|
arrayPropMutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ type SSHBackendData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *SSHBackend) StartBackend(bytes []byte) (bool, error) {
|
func (backend *SSHBackend) StartBackend(bytes []byte) (bool, error) {
|
||||||
|
log.Info("SSHBackend is initializing...")
|
||||||
var backendData SSHBackendData
|
var backendData SSHBackendData
|
||||||
|
|
||||||
err := json.Unmarshal(bytes, &backendData)
|
err := json.Unmarshal(bytes, &backendData)
|
||||||
|
@ -77,6 +78,7 @@ func (backend *SSHBackend) StartBackend(bytes []byte) (bool, error) {
|
||||||
|
|
||||||
backend.conn = conn
|
backend.conn = conn
|
||||||
|
|
||||||
|
log.Info("SSHBackend has initialized successfully.")
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +92,7 @@ func (backend *SSHBackend) StopBackend() (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *SSHBackend) StartProxy(command *commonbackend.AddConnectionCommand) (bool, error) {
|
func (backend *SSHBackend) StartProxy(command *commonbackend.AddProxy) (bool, error) {
|
||||||
listenerObject := &SSHListener{
|
listenerObject := &SSHListener{
|
||||||
SourceIP: command.SourceIP,
|
SourceIP: command.SourceIP,
|
||||||
SourcePort: command.SourcePort,
|
SourcePort: command.SourcePort,
|
||||||
|
@ -131,7 +133,7 @@ func (backend *SSHBackend) StartProxy(command *commonbackend.AddConnectionComman
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceConn, err := net.Dial("tcp", command.SourceIP+":"+string(command.SourcePort))
|
sourceConn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", command.SourceIP, command.SourcePort))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("failed to dial source connection: %s", err.Error())
|
log.Warnf("failed to dial source connection: %s", err.Error())
|
||||||
|
@ -146,7 +148,7 @@ func (backend *SSHBackend) StartProxy(command *commonbackend.AddConnectionComman
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
advertisedConn := &commonbackend.ClientConnection{
|
advertisedConn := &commonbackend.ProxyClientConnection{
|
||||||
SourceIP: command.SourceIP,
|
SourceIP: command.SourceIP,
|
||||||
SourcePort: command.SourcePort,
|
SourcePort: command.SourcePort,
|
||||||
DestPort: command.DestPort,
|
DestPort: command.DestPort,
|
||||||
|
@ -241,7 +243,7 @@ func (backend *SSHBackend) StartProxy(command *commonbackend.AddConnectionComman
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *SSHBackend) StopProxy(command *commonbackend.RemoveConnectionCommand) (bool, error) {
|
func (backend *SSHBackend) StopProxy(command *commonbackend.RemoveProxy) (bool, error) {
|
||||||
defer backend.arrayPropMutex.Unlock()
|
defer backend.arrayPropMutex.Unlock()
|
||||||
backend.arrayPropMutex.Lock()
|
backend.arrayPropMutex.Lock()
|
||||||
|
|
||||||
|
@ -270,7 +272,7 @@ func (backend *SSHBackend) StopProxy(command *commonbackend.RemoveConnectionComm
|
||||||
return false, fmt.Errorf("could not find the proxy")
|
return false, fmt.Errorf("could not find the proxy")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *SSHBackend) GetAllClientConnections() []*commonbackend.ClientConnection {
|
func (backend *SSHBackend) GetAllClientConnections() []*commonbackend.ProxyClientConnection {
|
||||||
defer backend.arrayPropMutex.Unlock()
|
defer backend.arrayPropMutex.Unlock()
|
||||||
backend.arrayPropMutex.Lock()
|
backend.arrayPropMutex.Lock()
|
||||||
|
|
||||||
|
@ -306,7 +308,6 @@ func (backend *SSHBackend) CheckParametersForBackend(arguments []byte) *commonba
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// When using logging, you should use charmbracelet/log, because that's what everything else uses in this ecosystem of a project. - imterah
|
|
||||||
logLevel := os.Getenv("NEXTNET_LOG_LEVEL")
|
logLevel := os.Getenv("NEXTNET_LOG_LEVEL")
|
||||||
|
|
||||||
if logLevel != "" {
|
if logLevel != "" {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue