Skip to content

Commit df1b8bf

Browse files
committed
Merge remote-tracking branch 'origin/master' into ptysess
Signed-off-by: Carlos Alexandro Becker <[email protected]>
2 parents ba3b31c + e11ae27 commit df1b8bf

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

.github/dependabot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
labels:
8+
- "dependencies"
9+
commit-message:
10+
prefix: "feat"
11+
include: "scope"
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"
16+
labels:
17+
- "dependencies"
18+
commit-message:
19+
prefix: "chore"
20+
include: "scope"
21+
- package-ecosystem: "docker"
22+
directory: "/"
23+
schedule:
24+
interval: "daily"
25+
labels:
26+
- "dependencies"
27+
commit-message:
28+
prefix: "feat"
29+
include: "scope"

server.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type Server struct {
3939
Version string // server version to be sent before the initial handshake
4040
Banner string // server banner
4141

42+
BannerHandler BannerHandler // server banner handler, overrides Banner
4243
KeyboardInteractiveHandler KeyboardInteractiveHandler // keyboard-interactive authentication handler
4344
PasswordHandler PasswordHandler // password authentication handler
4445
PublicKeyHandler PublicKeyHandler // public key authentication handler
@@ -134,10 +135,16 @@ func (srv *Server) config(ctx Context) *gossh.ServerConfig {
134135
config.ServerVersion = "SSH-2.0-" + srv.Version
135136
}
136137
if srv.Banner != "" {
137-
config.BannerCallback = func(conn gossh.ConnMetadata) string {
138+
config.BannerCallback = func(_ gossh.ConnMetadata) string {
138139
return srv.Banner
139140
}
140141
}
142+
if srv.BannerHandler != nil {
143+
config.BannerCallback = func(conn gossh.ConnMetadata) string {
144+
applyConnMetadata(ctx, conn)
145+
return srv.BannerHandler(ctx)
146+
}
147+
}
141148
if srv.PasswordHandler != nil {
142149
config.PasswordCallback = func(conn gossh.ConnMetadata, password []byte) (*gossh.Permissions, error) {
143150
applyConnMetadata(ctx, conn)

ssh.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ type Option func(*Server) error
3636
// Handler is a callback for handling established SSH sessions.
3737
type Handler func(Session)
3838

39+
// BannerHandler is a callback for displaying the server banner.
40+
type BannerHandler func(ctx Context) string
41+
3942
// PublicKeyHandler is a callback for performing public key authentication.
4043
type PublicKeyHandler func(ctx Context, key PublicKey) bool
4144

@@ -152,8 +155,7 @@ func Handle(handler Handler) {
152155

153156
// KeysEqual is constant time compare of the keys to avoid timing attacks.
154157
func KeysEqual(ak, bk PublicKey) bool {
155-
156-
//avoid panic if one of the keys is nil, return false instead
158+
// avoid panic if one of the keys is nil, return false instead
157159
if ak == nil || bk == nil {
158160
return false
159161
}

0 commit comments

Comments
 (0)