fix: Adds missing backend status command implementations.
This commit is contained in:
parent
605ad31dd6
commit
93f2f9cbee
4 changed files with 45 additions and 0 deletions
|
@ -72,6 +72,42 @@ func (helper *BackendApplicationHelper) Start() error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helper.socket.Write(responseMarshalled)
|
||||||
|
case "backendStatusRequest":
|
||||||
|
_, ok := commandRaw.(*commonbackend.BackendStatusRequest)
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("failed to typecast")
|
||||||
|
}
|
||||||
|
|
||||||
|
ok, err := helper.Backend.GetBackendStatus()
|
||||||
|
|
||||||
|
var (
|
||||||
|
message string
|
||||||
|
statusCode int
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
message = err.Error()
|
||||||
|
statusCode = commonbackend.StatusFailure
|
||||||
|
} else {
|
||||||
|
statusCode = commonbackend.StatusSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
response := &commonbackend.BackendStatusResponse{
|
||||||
|
Type: "backendStatusResponse",
|
||||||
|
IsRunning: ok,
|
||||||
|
StatusCode: statusCode,
|
||||||
|
Message: message,
|
||||||
|
}
|
||||||
|
|
||||||
|
responseMarshalled, err := commonbackend.Marshal(response.Type, response)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error("failed to marshal response: %s", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
helper.socket.Write(responseMarshalled)
|
helper.socket.Write(responseMarshalled)
|
||||||
case "stop":
|
case "stop":
|
||||||
_, ok := commandRaw.(*commonbackend.Stop)
|
_, ok := commandRaw.(*commonbackend.Stop)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import "git.terah.dev/imterah/hermes/backend/commonbackend"
|
||||||
type BackendInterface interface {
|
type BackendInterface interface {
|
||||||
StartBackend(arguments []byte) (bool, error)
|
StartBackend(arguments []byte) (bool, error)
|
||||||
StopBackend() (bool, error)
|
StopBackend() (bool, error)
|
||||||
|
GetBackendStatus() (bool, error)
|
||||||
StartProxy(command *commonbackend.AddProxy) (bool, error)
|
StartProxy(command *commonbackend.AddProxy) (bool, error)
|
||||||
StopProxy(command *commonbackend.RemoveProxy) (bool, error)
|
StopProxy(command *commonbackend.RemoveProxy) (bool, error)
|
||||||
GetAllClientConnections() []*commonbackend.ProxyClientConnection
|
GetAllClientConnections() []*commonbackend.ProxyClientConnection
|
||||||
|
|
|
@ -19,6 +19,10 @@ func (backend *DummyBackend) StopBackend() (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (backend *DummyBackend) GetBackendStatus() (bool, error) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (backend *DummyBackend) StartProxy(command *commonbackend.AddProxy) (bool, error) {
|
func (backend *DummyBackend) StartProxy(command *commonbackend.AddProxy) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,10 @@ func (backend *SSHBackend) StopBackend() (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (backend *SSHBackend) GetBackendStatus() (bool, error) {
|
||||||
|
return backend.conn != nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (backend *SSHBackend) StartProxy(command *commonbackend.AddProxy) (bool, error) {
|
func (backend *SSHBackend) StartProxy(command *commonbackend.AddProxy) (bool, error) {
|
||||||
listenerObject := &SSHListener{
|
listenerObject := &SSHListener{
|
||||||
SourceIP: command.SourceIP,
|
SourceIP: command.SourceIP,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue