summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-09-26 16:42:47 +0300
committerPaul Buetow <paul@buetow.org>2021-10-02 12:26:36 +0300
commitfcaa94c7453efa0d74e330128c0f5c2cde8f11b3 (patch)
tree1f686e5eeeb1b180cc14a3586f388f1a3492899c /internal/server
parentfe3e68afd99d8ea246be52893730f987e138ec24 (diff)
refactor config reader - also looks in additional search paths for config file unless NONE is specified
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/continuous.go2
-rw-r--r--internal/server/handlers/readcommand.go2
-rw-r--r--internal/server/scheduler.go2
-rw-r--r--internal/server/server.go12
4 files changed, 13 insertions, 5 deletions
diff --git a/internal/server/continuous.go b/internal/server/continuous.go
index 5f4c454..87c8889 100644
--- a/internal/server/continuous.go
+++ b/internal/server/continuous.go
@@ -61,7 +61,7 @@ func (c *continuous) runJob(ctx context.Context, job config.Continuous) {
}
args := config.Args{
- ConnectionsPerCPU: 10,
+ ConnectionsPerCPU: config.DefaultConnectionsPerCPU,
Discovery: job.Discovery,
ServersStr: servers,
What: files,
diff --git a/internal/server/handlers/readcommand.go b/internal/server/handlers/readcommand.go
index 60ad2a0..c76ae2a 100644
--- a/internal/server/handlers/readcommand.go
+++ b/internal/server/handlers/readcommand.go
@@ -7,9 +7,9 @@ import (
"sync"
"time"
+ "github.com/mimecast/dtail/internal/io/dlog"
"github.com/mimecast/dtail/internal/io/fs"
"github.com/mimecast/dtail/internal/io/line"
- "github.com/mimecast/dtail/internal/io/dlog"
"github.com/mimecast/dtail/internal/omode"
"github.com/mimecast/dtail/internal/regex"
)
diff --git a/internal/server/scheduler.go b/internal/server/scheduler.go
index f474cc8..64e6573 100644
--- a/internal/server/scheduler.go
+++ b/internal/server/scheduler.go
@@ -72,7 +72,7 @@ func (s *scheduler) runJobs(ctx context.Context) {
}
args := config.Args{
- ConnectionsPerCPU: 10,
+ ConnectionsPerCPU: config.DefaultConnectionsPerCPU,
Discovery: job.Discovery,
ServersStr: servers,
What: files,
diff --git a/internal/server/server.go b/internal/server/server.go
index a8f541b..d1cd57d 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -124,7 +124,12 @@ func (s *Server) handleConnection(ctx context.Context, conn net.Conn) {
}
func (s *Server) handleChannel(ctx context.Context, sshConn gossh.Conn, newChannel gossh.NewChannel) {
- user := user.New(sshConn.User(), sshConn.RemoteAddr().String())
+ user, err := user.New(sshConn.User(), sshConn.RemoteAddr().String())
+ if err != nil {
+ dlog.Server.Error(user, err)
+ newChannel.Reject(gossh.Prohibited, err.Error())
+ return
+ }
dlog.Server.Info(user, "Invoking channel handler")
if newChannel.ChannelType() != "session" {
@@ -213,7 +218,10 @@ func (s *Server) handleRequests(ctx context.Context, sshConn gossh.Conn, in <-ch
// Callback for SSH authentication.
func (s *Server) Callback(c gossh.ConnMetadata, authPayload []byte) (*gossh.Permissions, error) {
- user := user.New(c.User(), c.RemoteAddr().String())
+ user, err := user.New(c.User(), c.RemoteAddr().String())
+ if err != nil {
+ return nil, err
+ }
if config.ServerRelaxedAuthEnable {
dlog.Server.Fatal(user, "Granting permissions via relaxed-auth")