feature: Adds API manifest definitions, and implement GetAllClientConnections()
Some checks failed
Release code / build (push) Has been cancelled
Some checks failed
Release code / build (push) Has been cancelled
This commit is contained in:
parent
f8a4fe00a0
commit
34b605c1b1
4 changed files with 48 additions and 2 deletions
|
@ -7,4 +7,5 @@ WORKDIR /app
|
|||
COPY --from=build /build/backend/backends.prod.json /app/backends.json
|
||||
COPY --from=build /build/backend/api/api /app/hermes
|
||||
COPY --from=build /build/backend/sshbackend/sshbackend /app/sshbackend
|
||||
COPY --from=build /build/backend/sshappbackend/local-code/sshappbackend /app/sshappbackend
|
||||
ENTRYPOINT ["/app/hermes", "--backends-path", "/app/backends.json"]
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
"name": "ssh",
|
||||
"path": "./sshbackend/sshbackend"
|
||||
},
|
||||
{
|
||||
"name": "sshapp",
|
||||
"path": "./sshappbackend/local-code/sshappbackend"
|
||||
},
|
||||
{
|
||||
"name": "dummy",
|
||||
"path": "./dummybackend/dummybackend"
|
||||
|
|
|
@ -2,5 +2,9 @@
|
|||
{
|
||||
"name": "ssh",
|
||||
"path": "./sshbackend"
|
||||
},
|
||||
{
|
||||
"name": "sshapp",
|
||||
"path": "./sshappbackend"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -533,9 +533,46 @@ func (backend *SSHAppBackend) StopProxy(command *commonbackend.RemoveProxy) (boo
|
|||
return false, fmt.Errorf("could not find the proxy")
|
||||
}
|
||||
|
||||
// TODO: implement!
|
||||
func (backend *SSHAppBackend) GetAllClientConnections() []*commonbackend.ProxyClientConnection {
|
||||
return []*commonbackend.ProxyClientConnection{}
|
||||
connections := []*commonbackend.ProxyClientConnection{}
|
||||
informationRequest := &datacommands.ProxyConnectionInformationRequest{}
|
||||
|
||||
for proxyID, tcpProxy := range backend.tcpProxies {
|
||||
informationRequest.ProxyID = proxyID
|
||||
|
||||
for connectionID := range tcpProxy.connections {
|
||||
informationRequest.ConnectionID = connectionID
|
||||
|
||||
proxyStatusRaw, err := backend.SendNonCriticalMessage(informationRequest)
|
||||
|
||||
if err != nil {
|
||||
log.Warnf("Failed to get connection information for Proxy ID: %d, Connection ID: %d: %s", proxyID, connectionID, err.Error())
|
||||
return connections
|
||||
}
|
||||
|
||||
connectionStatus, ok := proxyStatusRaw.(*datacommands.ProxyConnectionInformationResponse)
|
||||
|
||||
if !ok {
|
||||
log.Warn("Failed to get connection response: typecast failed")
|
||||
return connections
|
||||
}
|
||||
|
||||
if !connectionStatus.Exists {
|
||||
log.Warnf("Connection with proxy ID: %d, Connection ID: %d is reported to not exist!", proxyID, connectionID)
|
||||
tcpProxy.connections[connectionID].Close()
|
||||
}
|
||||
|
||||
connections = append(connections, &commonbackend.ProxyClientConnection{
|
||||
SourceIP: tcpProxy.proxyInformation.SourceIP,
|
||||
SourcePort: tcpProxy.proxyInformation.SourcePort,
|
||||
DestPort: tcpProxy.proxyInformation.DestPort,
|
||||
ClientIP: connectionStatus.ClientIP,
|
||||
ClientPort: connectionStatus.ClientPort,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return connections
|
||||
}
|
||||
|
||||
// We don't have any parameter limitations, so we should be good.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue