fix: Fixes API routes.
This commit is contained in:
parent
fe8980b265
commit
bcf97fde6d
15 changed files with 284 additions and 132 deletions
|
@ -38,7 +38,6 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
|
||||
switch commandType {
|
||||
case "start":
|
||||
// TODO: implement response logic
|
||||
command, ok := commandRaw.(*commonbackend.Start)
|
||||
|
||||
if !ok {
|
||||
|
@ -75,7 +74,6 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case "stop":
|
||||
// TODO: implement response logic
|
||||
_, ok := commandRaw.(*commonbackend.Stop)
|
||||
|
||||
if !ok {
|
||||
|
@ -112,7 +110,6 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case "addProxy":
|
||||
// TODO: implement response logic
|
||||
command, ok := commandRaw.(*commonbackend.AddProxy)
|
||||
|
||||
if !ok {
|
||||
|
@ -148,14 +145,40 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case "removeProxy":
|
||||
// TODO: implement response logic
|
||||
command, ok := commandRaw.(*commonbackend.RemoveProxy)
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to typecast")
|
||||
}
|
||||
|
||||
_, _ = helper.Backend.StopProxy(command)
|
||||
ok, err = helper.Backend.StopProxy(command)
|
||||
var hasAnyFailed bool
|
||||
|
||||
if !ok {
|
||||
log.Warnf("failed to remove proxy (%s:%d -> remote:%d): RemoveProxy returned into failure state", command.SourceIP, command.SourcePort, command.DestPort)
|
||||
hasAnyFailed = true
|
||||
} else if err != nil {
|
||||
log.Warnf("failed to remove proxy (%s:%d -> remote:%d): %s", command.SourceIP, command.SourcePort, command.DestPort, err.Error())
|
||||
hasAnyFailed = true
|
||||
}
|
||||
|
||||
response := &commonbackend.ProxyStatusResponse{
|
||||
Type: "proxyStatusResponse",
|
||||
SourceIP: command.SourceIP,
|
||||
SourcePort: command.SourcePort,
|
||||
DestPort: command.DestPort,
|
||||
Protocol: command.Protocol,
|
||||
IsActive: hasAnyFailed,
|
||||
}
|
||||
|
||||
responseMarshalled, err := commonbackend.Marshal(response.Type, response)
|
||||
|
||||
if err != nil {
|
||||
log.Error("failed to marshal response: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case "proxyConnectionsRequest":
|
||||
_, ok := commandRaw.(*commonbackend.ProxyConnectionsRequest)
|
||||
|
||||
|
@ -180,7 +203,6 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
return err
|
||||
}
|
||||
case "checkClientParameters":
|
||||
// TODO: implement response logic
|
||||
command, ok := commandRaw.(*commonbackend.CheckClientParameters)
|
||||
|
||||
if !ok {
|
||||
|
@ -201,7 +223,6 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
return err
|
||||
}
|
||||
case "checkServerParameters":
|
||||
// TODO: implement response logic
|
||||
command, ok := commandRaw.(*commonbackend.CheckServerParameters)
|
||||
|
||||
if !ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue