Documentation ¶
Index ¶
Constants ¶
View Source
const ( ProtocolVersion = 1 MaxMessagesCount = 0xffffffff )
View Source
const CommandLength = 4
View Source
const MaxPacketSize uint32 = 8192
Variables ¶
View Source
var ( ErrCounterOverflow = errors.New("message counter overflow") ErrLowCounter = errors.New("message counter is too low") ErrShortMessage = errors.New("message is too short") ErrAuth = errors.New("authentication failed") ErrIVGen = errors.New("failed to generate initialization vector") )
View Source
var ( ErrParseDHState = errors.New("failed to parse second user's diffie-hellman state") ErrParseHalfKey = errors.New("failed to parse second user's halfkey") ErrWeakHalfkey = errors.New("weak halfkey from second user") ErrShortQ = errWeakDHState("q constant size lower than 256 bits") ErrShortP = errWeakDHState("p constant size lower than 2048 bits") ErrWrongG = errWeakDHState("g^q (modp) doesn't equal 1") )
View Source
var ErrLongPacket = errors.New("packet is too long")
View Source
var (
ErrShortCommand = errors.New("command is too short")
)
View Source
var ManagerCommands = managerCommands()
View Source
var PeerCommands = peerCommands()
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command [CommandLength]byte
type CommandParser ¶
type CommandParser struct {
// contains filtered or unexported fields
}
func CreateCommandParser ¶
func CreateCommandParser(typeChecker func(interface{}) bool) *CommandParser
func (*CommandParser) AddCommand ¶
func (parser *CommandParser) AddCommand(cmd Command, handler interface{})
func (*CommandParser) CommandLoop ¶
func (parser *CommandParser) CommandLoop(rw PackageReadWriter, execute func(interface{}, []byte) error)
func (*CommandParser) GetHandler ¶
func (parser *CommandParser) GetHandler(data []byte) (interface{}, []byte, error)
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func CreateConn ¶
func (*Conn) ReadPackage ¶
func (*Conn) RemoteAddr ¶
type CryptoState ¶
type CryptoState struct { SendEnc cipher.Block RecEnc cipher.Block SendAuth hash.Hash RecAuth hash.Hash MsgSendCtr uint32 MsgRecCtr uint32 }
func InitCryptoState ¶
func InitCryptoState(key []byte, isUserA bool) *CryptoState
func (*CryptoState) AuthAndEncrypt ¶
func (cs *CryptoState) AuthAndEncrypt(data []byte) ([]byte, error)
func (*CryptoState) DecryptAndAuth ¶
func (cs *CryptoState) DecryptAndAuth(data []byte) ([]byte, error)
func (*CryptoState) RecAuthMessage ¶
func (cs *CryptoState) RecAuthMessage(data []byte) []byte
func (*CryptoState) SendAuthMessage ¶
func (cs *CryptoState) SendAuthMessage(data []byte) []byte
type Host ¶
type Host struct { Login string Addr string DifHel *DHState `json:"-"` Peers map[string]*Peer `json:"-"` Commands *CommandParser `json:"-"` Msg chan string `json:"-"` Quit chan bool `json:"-"` }
func (*Host) Disconnect ¶
func (host *Host) Disconnect()
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func CreateListener ¶
type Manager ¶
type Manager struct { Conn *Conn Peer *Peer Commands *CommandParser }
func (*Manager) SendMessage ¶
type PackageReadWriter ¶
type Peer ¶
type Peer struct { Login string Addr string DifHel *DHState `json:"-"` Crypto *CryptoState `json:"-"` Conn *Conn `json:"-"` }
func (*Peer) ReadPackage ¶
Click to show internal directories.
Click to hide internal directories.