server

package
v0.0.0-...-4083cd3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewListener

func NewListener(port string) (net.Listener, error)

func SendMessage

func SendMessage(conn net.Conn, msg []byte) error

Types

type ConnectedUser

type ConnectedUser struct {
	AESKey []byte
	// contains filtered or unexported fields
}

func (*ConnectedUser) ProcessMessage

func (cu *ConnectedUser) ProcessMessage(s *Server)

type Server

type Server struct {
	LiveConns          map[string]*ConnectedUser
	Listener           net.Listener
	MsgHistory         [][]byte
	MaxMsgHistorySize  uint
	MaxConnectionLimit uint
	Blacklist          []string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(port string, historySize uint, logger *log.Logger) (Server, error)

func (*Server) ActionKeepAlive

func (s *Server) ActionKeepAlive(username string)

func (*Server) ActionMessageType

func (s *Server) ActionMessageType(p encoding.MsgProtocol, data []byte) error

func (*Server) AddMsgToHistory

func (s *Server) AddMsgToHistory(msg []byte)

func (*Server) AddToLiveConns

func (s *Server) AddToLiveConns(userKey string, conn *ConnectedUser) error

func (*Server) AwaitClientAESKey

func (s *Server) AwaitClientAESKey(conn net.Conn, cliPubKey *rsa.PublicKey) ([]byte, error)

func (*Server) AwaitHandshake

func (s *Server) AwaitHandshake(conn net.Conn) (encoding.MsgProtocol, error)

func (*Server) AwaitMessage

func (s *Server) AwaitMessage(user *ConnectedUser)

func (*Server) BanUser

func (s *Server) BanUser(username string) bool

func (*Server) BroadcastActiveUsers

func (s *Server) BroadcastActiveUsers()

func (*Server) BroadcastMessage

func (s *Server) BroadcastMessage(sentBy string, message []byte) []error

func (*Server) CloseConnection

func (s *Server) CloseConnection(user *ConnectedUser)

func (*Server) CloseConnectionForUser

func (s *Server) CloseConnectionForUser(username string)

func (*Server) DenyConnection

func (s *Server) DenyConnection(conn net.Conn, errMsg string)

func (*Server) GetAllActiveUsers

func (s *Server) GetAllActiveUsers() []UserInfo

func (*Server) IsActiveUser

func (s *Server) IsActiveUser(username string) (*ConnectedUser, bool)

func (*Server) NewConnection

func (s *Server) NewConnection(newUser ConnectedUser) (*ConnectedUser, error)

func (*Server) ProcessGroupMessage

func (s *Server) ProcessGroupMessage(sentBy string, msg []byte)

func (*Server) SendAESKey

func (s *Server) SendAESKey(conn net.Conn, cliPubKey *rsa.PublicKey) error

func (*Server) SendDisconnectionNotification

func (s *Server) SendDisconnectionNotification(user *ConnectedUser)

func (*Server) SendHandshakeResponse

func (s *Server) SendHandshakeResponse(conn net.Conn) error

func (*Server) SendHistory

func (s *Server) SendHistory(user *ConnectedUser) error

func (*Server) SentMessageToClient

func (s *Server) SentMessageToClient(client string, msg []byte) error

func (*Server) SetHostUser

func (s *Server) SetHostUser(username string)

func (*Server) StartListening

func (s *Server) StartListening()

type UserInfo

type UserInfo struct {
	Username   string
	UserColour string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL