From dfa9e4aedde33d1a778ad950e94ba787fae6d754 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Sat, 20 Aug 2016 15:21:26 +0100 Subject: [PATCH] rename package to easyssh, so it doesn't conflict --- README.md | 2 +- config.go | 9 +++++++++ example/server.go | 27 +++++++-------------------- handler.go | 2 +- listen.go | 2 +- state.go | 2 +- types.go | 2 +- 7 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 config.go diff --git a/README.md b/README.md index 0985757..9f17be4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SSH +# EasySSH Easier ssh server wrapper, net/http-style. diff --git a/config.go b/config.go new file mode 100644 index 0000000..f81eb64 --- /dev/null +++ b/config.go @@ -0,0 +1,9 @@ +package easyssh + +import "golang.org/x/crypto/ssh" + +func PublicConfig() *ssh.ServerConfig { + return &ssh.ServerConfig{ + NoClientAuth: true, + } +} diff --git a/example/server.go b/example/server.go index d6cf8c6..d79e5c4 100644 --- a/example/server.go +++ b/example/server.go @@ -14,8 +14,7 @@ import ( "path/filepath" "sync" - "github.com/paulbellamy/ssh" - gossh "golang.org/x/crypto/ssh" + "github.com/paulbellamy/easyssh" ) func main() { @@ -23,30 +22,18 @@ func main() { flag.Parse() // Configure the server - server := &ssh.Server{ + server := &easyssh.Server{ Addr: *addr, - Handler: &topic{clients: make(map[int]ssh.Channel)}, + Handler: &topic{clients: make(map[int]easyssh.Channel)}, // ConnState specifies an optional callback function that is // called when a client connection changes state. See the // ConnState type and associated constants for details. - ConnState: func(conn net.Conn, state ssh.ConnState) { + ConnState: func(conn net.Conn, state easyssh.ConnState) { log.Printf("[ConnState] %v: %s", conn.RemoteAddr(), state) }, - ServerConfig: &gossh.ServerConfig{ - NoClientAuth: true, - /* - PasswordCallback: func(c gossh.ConnMetadata, pass []byte) (*gossh.Permissions, error) { - // Should use constant-time compare (or better, salt+hash) in - // a production setting. - if c.User() == "testuser" && string(pass) == "tiger" { - return nil, nil - } - return nil, fmt.Errorf("password rejected for %q", c.User()) - }, - */ - }, + ServerConfig: easyssh.PublicConfig(), } // Generate a random key for now @@ -74,11 +61,11 @@ func main() { // Topic relays all messages from connected clients to all other clients type topic struct { - clients map[int]ssh.Channel + clients map[int]easyssh.Channel sync.RWMutex } -func (t *topic) ServeSSH(p *ssh.Permissions, c ssh.Channel, r <-chan *ssh.Request) { +func (t *topic) ServeSSH(p *easyssh.Permissions, c easyssh.Channel, r <-chan *easyssh.Request) { t.Lock() id := len(t.clients) t.clients[id] = c diff --git a/handler.go b/handler.go index b1067ef..256ae2e 100644 --- a/handler.go +++ b/handler.go @@ -1,4 +1,4 @@ -package ssh +package easyssh import "golang.org/x/crypto/ssh" diff --git a/listen.go b/listen.go index e8f96c7..6fec552 100644 --- a/listen.go +++ b/listen.go @@ -1,4 +1,4 @@ -package ssh +package easyssh import ( "context" diff --git a/state.go b/state.go index 7ef0bd2..e0e49d3 100644 --- a/state.go +++ b/state.go @@ -1,4 +1,4 @@ -package ssh +package easyssh // A ConnState represents the state of a client connection to a server. // It's used by the optional Server.ConnState hook. diff --git a/types.go b/types.go index c5dca0f..6752b46 100644 --- a/types.go +++ b/types.go @@ -1,4 +1,4 @@ -package ssh +package easyssh import ( "context"