summaryrefslogtreecommitdiff
path: root/internal/clients/connectors
diff options
context:
space:
mode:
Diffstat (limited to 'internal/clients/connectors')
-rw-r--r--internal/clients/connectors/serverconnection.go19
-rw-r--r--internal/clients/connectors/serverless.go22
2 files changed, 13 insertions, 28 deletions
diff --git a/internal/clients/connectors/serverconnection.go b/internal/clients/connectors/serverconnection.go
index 5bc63ee..1666a79 100644
--- a/internal/clients/connectors/serverconnection.go
+++ b/internal/clients/connectors/serverconnection.go
@@ -23,7 +23,6 @@ type ServerConnection struct {
config *ssh.ClientConfig
handler handlers.Handler
commands []string
- isOneOff bool
hostKeyCallback client.HostKeyCallback
throttlingDone bool
}
@@ -49,24 +48,6 @@ func NewServerConnection(server string, userName string, authMethods []ssh.AuthM
return &c
}
-// NewOneOffServerConnection creates new one-off connection (only for sending a series of commands and then quit).
-func NewOneOffServerConnection(server string, userName string, authMethods []ssh.AuthMethod, handler handlers.Handler, commands []string) *ServerConnection {
- c := ServerConnection{
- server: server,
- handler: handler,
- commands: commands,
- config: &ssh.ClientConfig{
- User: userName,
- Auth: authMethods,
- HostKeyCallback: ssh.InsecureIgnoreHostKey(),
- },
- isOneOff: true,
- }
-
- c.initServerPort()
- return &c
-}
-
func (c *ServerConnection) Server() string {
return c.server
}
diff --git a/internal/clients/connectors/serverless.go b/internal/clients/connectors/serverless.go
index 7740aab..ae72c9b 100644
--- a/internal/clients/connectors/serverless.go
+++ b/internal/clients/connectors/serverless.go
@@ -20,14 +20,12 @@ type Serverless struct {
// NewServerConnection returns a new connection.
func NewServerless(userName string, handler handlers.Handler, commands []string) *Serverless {
- s := Serverless{
+ dlog.Client.Debug("Creating new serverless connector", handler, commands)
+ return &Serverless{
userName: userName,
handler: handler,
commands: commands,
}
-
- dlog.Client.Debug("Creating new serverless connector", handler, commands)
- return &s
}
func (s *Serverless) Server() string {
@@ -58,11 +56,17 @@ func (s *Serverless) handle(ctx context.Context, cancel context.CancelFunc) erro
return err
}
- serverHandler := serverHandlers.NewServerHandler(
- user,
- make(chan struct{}, config.Server.MaxConcurrentCats),
- make(chan struct{}, config.Server.MaxConcurrentTails),
- )
+ var serverHandler serverHandlers.Handler
+ switch s.userName {
+ case config.ControlUser:
+ serverHandler = serverHandlers.NewControlHandler(user)
+ default:
+ serverHandler = serverHandlers.NewServerHandler(
+ user,
+ make(chan struct{}, config.Server.MaxConcurrentCats),
+ make(chan struct{}, config.Server.MaxConcurrentTails),
+ )
+ }
terminate := func() {
serverHandler.Shutdown()