server

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOG_SILENT     int = -1
	LOG_INFO       int = 0
	LOG_CONNECTION int = 1
	LOG_CHANNEL    int = 2
	LOG_DEBUG      int = 3
	LOG_PROTOCOL   int = 4
)

Variables

View Source
var (
	PID     int
	PID_STR string
)
View Source
var (
	DEFAULT_CONF_FILE string = ""
	DEFAULT_CONF_NAME string = "nvdaRemoteServer.json"
	DEFAULT_CONF_DIR  string
)
View Source
var (
	DEFAULT_GEN_CONF_FILE string = ""
	DEFAULT_GEN_CONF_DIR  bool   = false
)
View Source
var (
	DEFAULT_CERT_FILE     string = ""
	DEFAULT_KEY_FILE      string = ""
	DEFAULT_GEN_CERT_FILE string = ""
)
View Source
var (
	DEFAULT_MOTD                string = ""
	DEFAULT_MOTD_ALWAYS_DISPLAY bool   = false
)
View Source
var DEFAULT_ADDRESS string = ":6837"
View Source
var DEFAULT_CONF_READ bool = true
View Source
var DEFAULT_CREATE_DIR bool = false
View Source
var DEFAULT_LAUNCH bool = true
View Source
var DEFAULT_LOG_FILE string = ""
View Source
var DEFAULT_LOG_LEVEL int = 0
View Source
var DEFAULT_PID_FILE string = ""
View Source
var DEFAULT_SEND_ORIGIN bool = true
View Source
var (
	EndMessage byte = '\n'
)
View Source
var Launch bool
View Source
var PanicHandle panichandler.Capture = panichandler.Capture{
	F: func(i *panichandler.Info) {
		Log_error("PANIC\n", i.String())
		Shutdown()
		os.Exit(2)
	},
	ExitCode: panichandler.ExitCode,
}
View Source
var Servers []*Server
View Source
var (
	StopServers context.CancelFunc
)

Functions

func AddChannel

func AddChannel(name, password string, locked bool, c *Client)

func AddClient

func AddClient(c *Client)

func Authorize

func Authorize(c *Client, data []byte) error

func Configure

func Configure() error

func Encode

func Encode(data interface{}) ([]byte, error)

func FindClient

func FindClient(c *Client) bool

func JsonAdd

func JsonAdd(data []byte, key string, value interface{}) ([]byte, error)

func Launch_fail added in v0.2.2

func Launch_fail()

func Log

func Log(level int, msg ...interface{})

func Log_close added in v0.5.6

func Log_close()

func Log_error

func Log_error(msg ...interface{})

func MessageReceived

func MessageReceived(c *Client, pmsg []byte)

func PidfileClear added in v0.3.5

func PidfileClear()

func PidfileSet added in v0.3.5

func PidfileSet()

func RemoveChannel

func RemoveChannel(name string)

func RemoveClient

func RemoveClient(c *Client)

func Shutdown added in v0.5.2

func Shutdown()

func Start

func Start() int

Types

type AddressList added in v0.3.1

type AddressList []string

func (*AddressList) Set added in v0.3.1

func (a *AddressList) Set(v string) error

func (*AddressList) String added in v0.3.1

func (a *AddressList) String() string

type Cfg added in v0.4.0

type Cfg struct {
	PidFile           string      `json:"pid_file"`
	LogFile           string      `json:"log_file"`
	LogLevel          int         `json:"log_level"`
	Addresses         AddressList `json:"addresses"`
	Cert              string      `json:"cert_file"`
	Key               string      `json:"key_file"`
	Motd              string      `json:"motd"`
	MotdAlwaysDisplay bool        `json:"motd_always_display"`
	SendOrigin        bool        `json:"send_origin"`
	// contains filtered or unexported fields
}

func (*Cfg) CmdGet added in v0.4.0

func (c *Cfg) CmdGet()

func (*Cfg) CmdSet added in v0.4.0

func (c *Cfg) CmdSet()

func (*Cfg) Cwd added in v0.4.0

func (c *Cfg) Cwd(d string)

func (*Cfg) Decode added in v0.4.0

func (c *Cfg) Decode(d []byte) error

func (*Cfg) DoPanicTask added in v0.5.4

func (c *Cfg) DoPanicTask(i *panichandler.Info)

func (*Cfg) FindFile added in v0.4.0

func (c *Cfg) FindFile() string

func (*Cfg) Generate added in v0.4.0

func (c *Cfg) Generate() error

func (*Cfg) IsDefault added in v0.4.0

func (c *Cfg) IsDefault() bool

func (*Cfg) Log added in v0.4.0

func (c *Cfg) Log(level int, msg ...interface{})

func (*Cfg) LogWrite added in v0.4.0

func (c *Cfg) LogWrite()

func (*Cfg) Log_error added in v0.4.0

func (c *Cfg) Log_error(msg ...interface{})

func (*Cfg) Read added in v0.4.0

func (c *Cfg) Read() error

func (*Cfg) ReadFile added in v0.4.0

func (c *Cfg) ReadFile(f string) ([]byte, error)

func (*Cfg) SearchFile added in v0.4.0

func (c *Cfg) SearchFile(f string) string

func (*Cfg) Setup added in v0.4.0

func (c *Cfg) Setup() error

func (*Cfg) Write added in v0.4.0

func (c *Cfg) Write(file string) error

type Client

type Client struct {
	sync.Mutex

	Close context.CancelFunc
	// contains filtered or unexported fields
}

func (*Client) ClearChannel

func (c *Client) ClearChannel()

func (*Client) GetAuthorized added in v1.1.0

func (c *Client) GetAuthorized() bool

func (*Client) GetChannel

func (c *Client) GetChannel() *ClientChannel

func (*Client) GetConnectionType

func (c *Client) GetConnectionType() string

func (*Client) GetID

func (c *Client) GetID() int

func (*Client) GetIP added in v0.1.10

func (c *Client) GetIP() string

func (*Client) GetVersion

func (c *Client) GetVersion() int

func (*Client) Send

func (c *Client) Send(b []byte)

Send bytes to client.

func (*Client) SetAuthorized added in v1.1.0

func (c *Client) SetAuthorized(auth bool)

func (*Client) SetChannel

func (c *Client) SetChannel(clientChannel *ClientChannel)

func (*Client) SetConnectionType

func (c *Client) SetConnectionType(ctype string)

func (*Client) SetID added in v0.1.10

func (c *Client) SetID(id int)

func (*Client) SetVersion

func (c *Client) SetVersion(version int)

type ClientChannel

type ClientChannel struct {
	sync.Mutex

	ClientsAll    map[int]*Client
	ClientsMaster map[int]*Client
	ClientsSlave  map[int]*Client
	// contains filtered or unexported fields
}

func FindChannel

func FindChannel(name string) *ClientChannel

func NewClientChannel

func NewClientChannel(name, password string, locked bool, client *Client) *ClientChannel

func (*ClientChannel) Add

func (c *ClientChannel) Add(client *Client, password string)

func (*ClientChannel) EndIfEmpty

func (c *ClientChannel) EndIfEmpty() bool

func (*ClientChannel) Lmotd added in v1.1.0

func (c *ClientChannel) Lmotd(ctype, name, password string) string

func (*ClientChannel) Name

func (c *ClientChannel) Name() string

func (*ClientChannel) Quit

func (c *ClientChannel) Quit()

func (*ClientChannel) Remove

func (c *ClientChannel) Remove(client *Client)

func (*ClientChannel) SendAll

func (c *ClientChannel) SendAll(msg []byte, client *Client)

func (*ClientChannel) SendOthers

func (c *ClientChannel) SendOthers(msg []byte, client *Client)

type ClientData

type ClientData struct {
	ID             int    `json:"id"`
	ConnectionType string `json:"connection_type"`
}

type Data

type Data struct {
	Type              string       `json:"type"`
	Channel           string       `json:"channel,omitempty"`
	ConnectionType    string       `json:"connection_type,omitempty"`
	Version           int          `json:"version,omitempty"`
	Origin            int          `json:"origin,omitempty"`
	Key               string       `json:"key,omitempty"`
	ID                int          `json:"user_id,omitempty"`
	UserIds           []int        `json:"user_ids,omitempty"`
	Clients           []ClientData `json:"clients,omitempty"`
	Client            *ClientData  `json:"client,omitempty"`
	Error             string       `json:"error,omitempty"`
	Motd              string       `json:"motd,omitempty"`
	MotdAlwaysDisplay bool         `json:"force_display,omitempty"`
}

func Decode

func Decode(data []byte) (Data, error)

type Server

type Server struct {
	sync.Mutex
	sync.WaitGroup

	Stop context.CancelFunc
	// contains filtered or unexported fields
}

TCP server.

func New

func New(address string) *Server

Creates new tcp server instance.

func NewWithTLSConfig

func NewWithTLSConfig(address string, config *tls.Config) *Server

func (*Server) Listen

func (s *Server) Listen() error

Listen starts network server.

func (*Server) MessageTerminator

func (s *Server) MessageTerminator(terminator byte)

Set message terminator.

Jump to

Keyboard shortcuts

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