server

package
v0.5.20 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientPolicy added in v0.3.8

type ClientPolicy string
const (
	PolicyWorld ClientPolicy = "world"
	PolicyAllow ClientPolicy = "allow"
	PolicyFixed ClientPolicy = "fixed"
)

type Config

type Config struct {
	// Arbitrary string clients will need to be able to connect
	ProtocolVersion string

	// PolicyLoader should return all allowed users and their names
	PolicyLoader PolicyLoader

	Key *crypto.Key

	Log *log.Logger

	// HTTP link address
	HTTPPublicAddress string
	// HTTP/WS listen address
	HTTPAddress string
	// TCP listen address
	TCPAddress string

	// Path to store databases
	StorePath string

	// Path to store uploads and from which the http server can serve files
	UploadsPath   string
	MaxUploadSize int64

	// HTTPS certs, leave empty to disable TLS
	Cert    []byte
	CertKey []byte

	Router    simplehttp.Router
	RWFactory channel.RWFactory

	// Interval to log bandwidth, 0 = no logging
	LogBandwidth time.Duration
}

type PolicyLoader added in v0.3.8

type PolicyLoader interface {
	Policy() ClientPolicy
	Exists(fingerprint string) (name string, err error)
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(c Config) (*Server, error)

func (*Server) AddChannel

func (s *Server) AddChannel(name string, c channel.Channel) error

func (*Server) Broadcast

func (s *Server) Broadcast(f channel.ClientFilter, m channel.Msg) error

func (*Server) BroadcastBatch

func (s *Server) BroadcastBatch(b []channel.Batch) error

func (*Server) Close

func (s *Server) Close() error

func (*Server) GetUsers

func (s *Server) GetUsers(ch string) []channel.User

func (*Server) Init

func (s *Server) Init() error

func (*Server) MustAddChannel

func (s *Server) MustAddChannel(name string, c channel.Channel)

func (*Server) MustSetUserUpdateHandler

func (s *Server) MustSetUserUpdateHandler(h channel.UserUpdateHandler)

func (*Server) RunChannels added in v0.3.6

func (s *Server) RunChannels() error

func (*Server) RunHTTP added in v0.3.6

func (s *Server) RunHTTP() error

func (*Server) RunTCP added in v0.3.6

func (s *Server) RunTCP() error

func (*Server) Save

func (s *Server) Save() error

func (*Server) SetUserUpdateHandler

func (s *Server) SetUserUpdateHandler(h channel.UserUpdateHandler) error

func (*Server) Upload

func (s *Server) Upload(filename string, r io.Reader) (*url.URL, error)

Jump to

Keyboard shortcuts

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