func (a *Auth) CheckBans(addr net.Addr, key ssh.PublicKey, clientVersion string) error {
	authkey := newAuthKey(key)
	var banned bool
	if authkey != "" {
		banned = a.banned.In(authkey)
	}
	if !banned {
		banned = a.bannedAddr.In(newAuthAddr(addr))
	}
	if !banned {
		banned = a.bannedClient.In(clientVersion)
	}
	if banned && !a.IsOp(key) {
		return ErrBanned
	}
	return nil
}
CheckBans checks IP, key and client bans.
package sshchat
import (
	"crypto/sha256"
	"crypto/subtle"
	"encoding/csv"
	"errors"
	"fmt"
	"net"
	"strings"
	"time"
	"github.com/shazow/ssh-chat/set"
	"github.com/shazow/ssh-chat/sshd"
	"golang.org/x/crypto/ssh"
)
var ErrNotWhitelisted = errors.New("not whitelisted")
var ErrBanned = errors.New("banned")
var ErrIncorrectPassphrase = errors.New("incorrect passphrase")
func newAuthKey(key ssh.PublicKey) string {
	if key == nil {
		return ""
	}
	return sshd.Fingerprint(key)
}
func newAuthItem(key ssh.PublicKey) set.Item {
	return set.StringItem(newAuthKey(key))
}
func newAuthAddr(addr net.Addr) string {
	if addr == nil {
		return ""
	}
	host, _, _ := net.SplitHostPort(addr.String())
	return host
}
type Auth struct {
	passphraseHash []byte
	bannedAddr     *set.Set
	bannedClient   *set.Set
	banned         *set.Set
	whitelist      *set.Set
	ops            *set.Set
}
func NewAuth() *Auth {
	return &Auth{
		bannedAddr:   set.New(),
		bannedClient: set.New(),
		banned:       set.New(),
		whitelist:    set.New(),
		ops:          set.New(),
	}
}
func (a *Auth) SetPassphrase(passphrase string) {
	if passphrase == "" {
		a.passphraseHash = nil
	} else {
		hashArray := sha256.Sum256([]byte(passphrase))
		a.passphraseHash = hashArray[:]
	}
}
func (a *Auth) AllowAnonymous() bool {
	return a.whitelist.Len() == 0 && a.passphraseHash == nil
}
func (a *Auth) AcceptPassphrase() bool {
	return a.passphraseHash != nil
}