mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-07 19:03:17 +03:00
sshd: Better comments
This commit is contained in:
parent
40f6957e93
commit
e6233daefd
@ -5,6 +5,7 @@ import stdlog "log"
|
|||||||
|
|
||||||
var logger *stdlog.Logger
|
var logger *stdlog.Logger
|
||||||
|
|
||||||
|
// SetLogger sets the package logging output to use w.
|
||||||
func SetLogger(w io.Writer) {
|
func SetLogger(w io.Writer) {
|
||||||
flags := stdlog.Flags()
|
flags := stdlog.Flags()
|
||||||
prefix := "[sshd] "
|
prefix := "[sshd] "
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Container for the connection and ssh-related configuration
|
// SSHListener is the container for the connection and ssh-related configuration
|
||||||
type SSHListener struct {
|
type SSHListener struct {
|
||||||
net.Listener
|
net.Listener
|
||||||
config *ssh.ServerConfig
|
config *ssh.ServerConfig
|
||||||
@ -16,7 +16,7 @@ type SSHListener struct {
|
|||||||
HandlerFunc func(term *Terminal)
|
HandlerFunc func(term *Terminal)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make an SSH listener socket
|
// ListenSSH makes an SSH listener socket
|
||||||
func ListenSSH(laddr string, config *ssh.ServerConfig) (*SSHListener, error) {
|
func ListenSSH(laddr string, config *ssh.ServerConfig) (*SSHListener, error) {
|
||||||
socket, err := net.Listen("tcp", laddr)
|
socket, err := net.Listen("tcp", laddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -43,7 +43,7 @@ func (l *SSHListener) handleConn(conn net.Conn) (*Terminal, error) {
|
|||||||
return NewSession(sshConn, channels)
|
return NewSession(sshConn, channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accept incoming connections as terminal requests and yield them
|
// Serve Accepts incoming connections as terminal requests and yield them
|
||||||
func (l *SSHListener) Serve() {
|
func (l *SSHListener) Serve() {
|
||||||
defer l.Close()
|
defer l.Close()
|
||||||
for {
|
for {
|
||||||
|
@ -14,7 +14,10 @@ import (
|
|||||||
var keepaliveInterval = time.Second * 30
|
var keepaliveInterval = time.Second * 30
|
||||||
var keepaliveRequest = "keepalive@ssh-chat"
|
var keepaliveRequest = "keepalive@ssh-chat"
|
||||||
|
|
||||||
|
// ErrNoSessionChannel is returned when there is no session channel.
|
||||||
var ErrNoSessionChannel = errors.New("no session channel")
|
var ErrNoSessionChannel = errors.New("no session channel")
|
||||||
|
|
||||||
|
// ErrNotSessionChannel is returned when a channel is not a session channel.
|
||||||
var ErrNotSessionChannel = errors.New("terminal requires session channel")
|
var ErrNotSessionChannel = errors.New("terminal requires session channel")
|
||||||
|
|
||||||
// Connection is an interface with fields necessary to operate an sshd host.
|
// Connection is an interface with fields necessary to operate an sshd host.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user