Skip to content

Commit

Permalink
rename package to easyssh, so it doesn't conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbellamy committed Aug 20, 2016
1 parent 54b7771 commit dfa9e4a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SSH
# EasySSH

Easier ssh server wrapper, net/http-style.

Expand Down
9 changes: 9 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package easyssh

import "golang.org/x/crypto/ssh"

func PublicConfig() *ssh.ServerConfig {
return &ssh.ServerConfig{
NoClientAuth: true,
}
}
27 changes: 7 additions & 20 deletions example/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,26 @@ import (
"path/filepath"
"sync"

"github.com/paulbellamy/ssh"
gossh "golang.org/x/crypto/ssh"
"github.com/paulbellamy/easyssh"
)

func main() {
addr := flag.String("addr", ":12345", "address to listen on")
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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ssh
package easyssh

import "golang.org/x/crypto/ssh"

Expand Down
2 changes: 1 addition & 1 deletion listen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ssh
package easyssh

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion state.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ssh
package easyssh

import (
"context"
Expand Down

0 comments on commit dfa9e4a

Please sign in to comment.