Documentation ¶
Overview ¶
Package sshchat is an implementation of an ssh server which serves a chat room instead of a shell.
sshd subdirectory contains the ssh-related pieces which know nothing about chat.
chat subdirectory contains the chat-related pieces which know nothing about ssh.
The Host type is the glue between the sshd and chat pieces.
Index ¶
- Variables
- func GetPrompt(user *message.User) string
- func SetLogger(l *golog.Logger)
- type Auth
- func (a *Auth) AllowAnonymous() bool
- func (a *Auth) Ban(key ssh.PublicKey, d time.Duration)
- func (a *Auth) BanAddr(addr net.Addr, d time.Duration)
- func (a *Auth) BanClient(client string, d time.Duration)
- func (a *Auth) BanFingerprint(authkey string, d time.Duration)
- func (a *Auth) BanQuery(q string) error
- func (a *Auth) Banned() (ip []string, fingerprint []string, client []string)
- func (a *Auth) Check(addr net.Addr, key ssh.PublicKey, clientVersion string) error
- func (a *Auth) IsOp(key ssh.PublicKey) bool
- func (a *Auth) Op(key ssh.PublicKey, d time.Duration)
- func (a *Auth) Whitelist(key ssh.PublicKey, d time.Duration)
- type Host
- func (h *Host) AutoCompleteFunction(u *message.User) func(line string, pos int, key rune) (newLine string, newPos int, ok bool)
- func (h *Host) Connect(term *sshd.Terminal)
- func (h *Host) GetUser(name string) (*message.User, bool)
- func (h *Host) InitCommands(c *chat.Commands)
- func (h *Host) Serve()
- func (h *Host) SetMotd(motd string)
- func (h *Host) SetTheme(theme message.Theme)
- type Identity
Constants ¶
This section is empty.
Variables ¶
var ErrBanned = errors.New("banned")
ErrBanned is the error returned when a key is checked that is banned.
var ErrNotWhitelisted = errors.New("not whitelisted")
ErrNotWhitelisted Is the error returned when a key is checked that is not whitelisted, when whitelisting is enabled.
Functions ¶
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth stores lookups for bans, whitelists, and ops. It implements the sshd.Auth interface.
func (*Auth) AllowAnonymous ¶
AllowAnonymous determines if anonymous users are permitted.
func (*Auth) BanFingerprint ¶
BanFingerprint will set a public key fingerprint as banned.
func (*Auth) BanQuery ¶
BanQuery takes space-separated key="value" pairs to ban, including ip, fingerprint, client. Fields without an = will be treated as a duration, applied to the next field. For example: 5s client=foo 10min ip=1.1.1.1 Will ban client foo for 5 seconds, and ip 1.1.1.1 for 10min.
type Host ¶
type Host struct { *chat.Room // Version string to print on /version Version string // GetMOTD is used to reload the motd from an external source GetMOTD func() (string, error) // contains filtered or unexported fields }
Host is the bridge between sshd and chat modules TODO: Should be easy to add support for multiple rooms, if we want.
func NewHost ¶
func NewHost(listener *sshd.SSHListener, auth *Auth) *Host
NewHost creates a Host on top of an existing listener.
func (*Host) AutoCompleteFunction ¶
func (h *Host) AutoCompleteFunction(u *message.User) func(line string, pos int, key rune) (newLine string, newPos int, ok bool)
AutoCompleteFunction returns a callback for terminal autocompletion
func (*Host) InitCommands ¶
InitCommands adds host-specific commands to a Commands container. These will override any existing commands.
type Identity ¶
type Identity struct { sshd.Connection // contains filtered or unexported fields }
Identity is a container for everything that identifies a client.
func NewIdentity ¶
func NewIdentity(conn sshd.Connection) *Identity
NewIdentity returns a new identity object from an sshd.Connection.