hub

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: BSD-3-Clause Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermRoomsJoin   = "rooms.join"
	PermRoomsNew    = "rooms.new"
	PermRoomsList   = "rooms.list"
	PermRoomsOpChat = "rooms.opchat"

	PermBroadcast       = "hub.broadcast"
	PermConfigWrite     = "config.write"
	PermConfigRead      = "config.read"
	PermTopic           = "hub.topic"
	PermDrop            = "user.drop"
	PermDropAll         = "user.drop_all"
	PermRedirect        = "user.redirect"
	PermRedirectAll     = "user.redirect_all"
	PermRegister        = "user.register"
	PermRegisterProfile = "user.register_profile"
	PermIP              = "user.ip"
	PermBanIP           = "ban.ip"
)
View Source
const (
	ConfigHubName    = "hub.name"
	ConfigHubDesc    = "hub.desc"
	ConfigHubTopic   = "hub.topic"
	ConfigHubOwner   = "hub.owner"
	ConfigHubWebsite = "hub.website"
	ConfigHubEmail   = "hub.email"
	ConfigHubMOTD    = "hub.motd"
	ConfigHubPrivate = "hub.private"
)
View Source
const (
	ConfigZlibLevel       = "zlib.level"
	ConfigNMDCRedirectTLS = "nmdc.redirect.tls"
	ConfigNMDCRedirectADC = "nmdc.redirect.adc"
	ConfigADCRedirectTLS  = "adc.redirect.tls"
)
View Source
const (
	UserNormal = UserKind(iota)
	UserHub
	UserBot
)
View Source
const (
	PermOwner     = "owner"
	ProfileParent = "parent"
)
View Source
const (
	ProfileNameRoot       = "root"
	ProfileNameRegistered = "user"
	ProfileNameOperator   = "op"
	ProfileNameGuest      = "guest"
)
View Source
const (
	FlagOpIcon  = "icon.op"
	FlagRegIcon = "icon.reg"
)
View Source
const (
	FileTypeAny     = FileType(0)
	FileTypePicture = FileType(1 << iota)
	FileTypeAudio
	FileTypeVideo
	FileTypeCompressed
	FileTypeDocuments
	FileTypeExecutable
)
View Source
const HTTPInfoPathV0 = "/api/v0/hubinfo.json"

Variables

View Source
var (
	ErrRoomExists   = errors.New("room already exists")
	ErrCantJoinRoom = errors.New("cannot join the room")
)
View Source
var (
	ErrUserRegDisabled = errors.New("user registration is disabled")
	ErrUserNotFound    = errors.New("user does not exist")
	ErrNameTaken       = errors.New("user name already taken")
)

Functions

func DefaultProfiles added in v0.16.4

func DefaultProfiles() map[string]Map

func IsBot added in v0.25.0

func IsBot(p Peer) bool

IsBot checks if a user is a bot.

func NMDCUserInfo added in v0.20.0

func NMDCUserInfo(p Peer) nmdcp.MyINFO

func RegisterPlugin added in v0.16.4

func RegisterPlugin(p Plugin)

RegisterPlugin should be called to register a new hub plugin. When the hub is started, p.Init will be called to associate the plugin with a hub.

This function should be called in the plugin's init() function.

func ToNMDCChatMsg added in v0.20.0

func ToNMDCChatMsg(from Peer, msg Message) *nmdcp.ChatMessage

Types

type Ban added in v0.16.4

type Ban struct {
	Key    BanKey
	Hard   bool
	Until  time.Time
	Reason string
}

type BanDatabase added in v0.20.0

type BanDatabase interface {
	ListBans() ([]Ban, error)
	GetBan(key BanKey) (*Ban, error)
	PutBans(bans []Ban) error
	DelBans(keys []BanKey) error
	ClearBans() error
}

type BanKey added in v0.20.0

type BanKey string

func MinAddrKey added in v0.20.0

func MinAddrKey(a net.Addr) BanKey

func MinIPKey added in v0.20.0

func MinIPKey(ip net.IP) BanKey

func (BanKey) ToIP added in v0.20.0

func (k BanKey) ToIP() net.IP

type BasePeer

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

func (*BasePeer) ConnInfo added in v0.16.4

func (p *BasePeer) ConnInfo() *ConnInfo

func (*BasePeer) LocalAddr

func (p *BasePeer) LocalAddr() net.Addr

func (*BasePeer) Name added in v0.16.4

func (p *BasePeer) Name() string

func (*BasePeer) Online added in v0.16.4

func (p *BasePeer) Online() bool

func (*BasePeer) RemoteAddr

func (p *BasePeer) RemoteAddr() net.Addr

func (*BasePeer) SID

func (p *BasePeer) SID() SID

func (*BasePeer) User added in v0.16.4

func (p *BasePeer) User() *User

type Bot added in v0.16.4

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

func (*Bot) Close added in v0.16.4

func (b *Bot) Close() error

func (*Bot) Name added in v0.18.0

func (b *Bot) Name() string

func (*Bot) SendGlobal added in v0.16.4

func (b *Bot) SendGlobal(m Message) error

func (*Bot) SendPrivate added in v0.16.4

func (b *Bot) SendPrivate(to Peer, m Message) error

func (*Bot) UserInfo added in v0.20.0

func (b *Bot) UserInfo() UserInfo

type CID added in v0.16.4

type CID = adc.CID

type Command

type Command struct {
	Menu    []string
	Name    string
	Aliases []string
	Short   string
	Long    string
	Require string
	Func    interface{}
	// contains filtered or unexported fields
}

type CommandFunc added in v0.16.4

type CommandFunc = func(p Peer, args string) error

type Config

type Config struct {
	Name             string
	Desc             string
	Topic            string
	Addr             string
	Owner            string
	Website          string
	Email            string
	Private          bool
	Keyprint         string
	Soft             types.Software
	MOTD             string
	ChatLog          int
	ChatLogJoin      int
	FallbackEncoding string
	TLS              *tls.Config
}

type ConnInfo added in v0.16.4

type ConnInfo struct {
	Local   net.Addr
	Remote  net.Addr
	Secure  bool
	TLSVers uint16
	ALPN    string
	Proto   string
}

type Database

type Database interface {
	UserDatabase
	ProfileDatabase
	BanDatabase
	Close() error
}

func NewDatabase added in v0.16.4

func NewDatabase() Database

NewDatabase creates an in-memory users database.

type Dir

type Dir struct {
	Peer Peer
	Path string
}

func (Dir) From

func (f Dir) From() Peer

type DirSearch

type DirSearch struct {
	NameSearch
}

func (DirSearch) Match

func (s DirSearch) Match(r SearchResult) bool

type ErrUnknownProtocol added in v0.16.4

type ErrUnknownProtocol struct {
	Magic  []byte
	Secure bool
}

func (*ErrUnknownProtocol) Error added in v0.16.4

func (e *ErrUnknownProtocol) Error() string

type File

type File struct {
	Peer Peer
	Path string
	Size uint64
	TTH  *TTH
}

func (File) From

func (f File) From() Peer

type FileSearch

type FileSearch struct {
	NameSearch
	Ext      []string
	NoExt    []string
	FileType FileType
	MinSize  uint64
	MaxSize  uint64
}

func (FileSearch) Match

func (s FileSearch) Match(r SearchResult) bool

type FileType

type FileType int

type Hub

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

func NewHub

func NewHub(conf Config) (*Hub, error)

func (*Hub) AddAddress added in v0.16.4

func (h *Hub) AddAddress(addr string)

func (*Hub) Close added in v0.16.4

func (h *Hub) Close() error

func (*Hub) ConfigKeys added in v0.20.0

func (h *Hub) ConfigKeys() []string

func (*Hub) DeleteUser added in v0.16.4

func (h *Hub) DeleteUser(name string) error

func (*Hub) EachHardBlockedIP added in v0.16.4

func (h *Hub) EachHardBlockedIP(fnc func(ip net.IP) bool)

func (*Hub) GetConfig added in v0.20.0

func (h *Hub) GetConfig(key string) (interface{}, bool)

func (*Hub) GetConfigBool added in v0.20.0

func (h *Hub) GetConfigBool(key string) (bool, bool)

func (*Hub) GetConfigFloat added in v0.20.0

func (h *Hub) GetConfigFloat(key string) (float64, bool)

func (*Hub) GetConfigInt added in v0.20.0

func (h *Hub) GetConfigInt(key string) (int64, bool)

func (*Hub) GetConfigString added in v0.20.0

func (h *Hub) GetConfigString(key string) (string, bool)

func (*Hub) GetConfigUint added in v0.20.0

func (h *Hub) GetConfigUint(key string) (uint64, bool)

func (*Hub) GlobalChatRoom added in v0.25.0

func (h *Hub) GlobalChatRoom() *Room

GlobalChatRoom returns a global chat room that all users join by default when entering the hub.

func (*Hub) HardBlock added in v0.16.4

func (h *Hub) HardBlock(a net.Addr)

func (*Hub) HardBlockIP added in v0.16.4

func (h *Hub) HardBlockIP(ip net.IP)

func (*Hub) HardUnBlockIP added in v0.16.4

func (h *Hub) HardUnBlockIP(ip net.IP)

func (*Hub) HubUser added in v0.16.4

func (h *Hub) HubUser() *Bot

func (*Hub) IsHardBlocked added in v0.16.4

func (h *Hub) IsHardBlocked(a net.Addr) bool

func (*Hub) IsHardBlockedIP added in v0.16.4

func (h *Hub) IsHardBlockedIP(ip net.IP) bool

func (*Hub) IsPrivate added in v0.25.0

func (h *Hub) IsPrivate() bool

func (*Hub) IsRegistered

func (h *Hub) IsRegistered(name string) (bool, error)

func (*Hub) ListCommands

func (h *Hub) ListCommands(u *User) []*Command

func (*Hub) ListenAndServe

func (h *Hub) ListenAndServe(addr string) error

func (*Hub) LoadPluginsInDir added in v0.16.4

func (h *Hub) LoadPluginsInDir(dir string) error

LoadPluginsInDir loads all plugins in a specified directory. Should be called before Start.

Details about building Go plugins can be found here: https://golang.org/pkg/plugin/

func (*Hub) Log added in v0.25.0

func (h *Hub) Log(args ...interface{})

func (*Hub) Logf added in v0.25.0

func (h *Hub) Logf(format string, args ...interface{})

func (*Hub) MergeConfig added in v0.20.0

func (h *Hub) MergeConfig(m Map)

func (*Hub) MergeConfigPath added in v0.20.0

func (h *Hub) MergeConfigPath(path string, m Map)

func (*Hub) NewBot added in v0.16.4

func (h *Hub) NewBot(name string, soft types.Software) (*Bot, error)

func (*Hub) NewBotDesc added in v0.20.0

func (h *Hub) NewBotDesc(name, desc, email string, soft types.Software) (*Bot, error)

func (*Hub) NewPermRoom added in v0.25.0

func (h *Hub) NewPermRoom(name string, perm string) (*Room, error)

NewPermRoom creates a new private room that can be accessed by anyone with a given permission.

func (*Hub) NewPrivateRoom added in v0.25.0

func (h *Hub) NewPrivateRoom(name string) (*Room, error)

NewPrivateRoom creates a new private room. It cannot be entered by anyone except the owner. It's the caller's responsibility to add users to this kind of room.

func (*Hub) NewRoom

func (h *Hub) NewRoom(name string) (*Room, error)

NewRoom creates a new public room with a given name.

func (*Hub) OnChat added in v0.16.4

func (h *Hub) OnChat(fnc func(r *Room, p Peer, m Message) bool)

OnChat is triggered when the message is sent in any of the chat rooms. The function returns a flag if a message should be accepted or not.

func (*Hub) OnConnected added in v0.16.4

func (h *Hub) OnConnected(fnc func(c net.Conn) bool)

OnConnected registers a trigger for a moment when a new connection is accepted, but before the protocol detection. The function returns a flag indicating if a connection should be accepted or not.

func (*Hub) OnConnectedIP4 added in v0.25.0

func (h *Hub) OnConnectedIP4(fnc func(c net.Conn, ip net.IP) bool)

OnConnectedIP4 registers a trigger for a moment when a new connection from IPv4 is accepted, but before the protocol detection. The function returns a flag indicating if a connection should be accepted or not.

func (*Hub) OnConnectedIP6 added in v0.25.0

func (h *Hub) OnConnectedIP6(fnc func(c net.Conn, ip net.IP) bool)

OnConnectedIP6 registers a trigger for a moment when a new connection from IPv6 is accepted, but before the protocol detection. The function returns a flag indicating if a connection should be accepted or not.

func (*Hub) OnDisconnected added in v0.16.4

func (h *Hub) OnDisconnected(fnc func(c net.Conn))

OnDisconnected registers a trigger for a moment when the connection is closed.

func (*Hub) OnGlobalChat added in v0.25.0

func (h *Hub) OnGlobalChat(fnc func(p Peer, m Message) bool)

OnGlobalChat is triggered when the message is sent in the global chat. The function returns a flag if a message should be accepted or not.

func (*Hub) OnJoined added in v0.16.4

func (h *Hub) OnJoined(fnc func(p Peer) bool)

OnJoined is triggered when the peer successfully joins the hub, after all the checks and right before the client event loop. The function returns a flag if a peer should be accepted or not.

func (*Hub) OnLeave added in v0.20.0

func (h *Hub) OnLeave(fnc func(p Peer))

OnLeave is triggered when the peer disconnects from the hub, after he was unregistered from the users list.

func (*Hub) OnPM added in v0.25.0

func (h *Hub) OnPM(fnc func(from, to Peer, m Message) bool)

OnPM is triggered when the private message is sent through the hub. The function returns a flag if a message should be accepted or not.

func (*Hub) OnPermJoined added in v0.25.0

func (h *Hub) OnPermJoined(perm string, fnc func(p Peer) bool)

OnPermJoined is an analog of OnJoined, but triggers only when a user with a specified permission joins.

func (*Hub) OnPermLeave added in v0.25.0

func (h *Hub) OnPermLeave(perm string, fnc func(p Peer))

OnPermLeave is an analog of OnLeave, but triggers only when a user with a specified permission leaves.

func (*Hub) OpLog added in v0.25.0

func (h *Hub) OpLog(args ...interface{})

func (*Hub) OpLogf added in v0.25.0

func (h *Hub) OpLogf(format string, args ...interface{})

func (*Hub) PeerByName added in v0.16.4

func (h *Hub) PeerByName(name string) Peer

func (*Hub) Peers

func (h *Hub) Peers() []Peer

func (*Hub) Profile added in v0.16.4

func (h *Hub) Profile(id string) *UserProfile

func (*Hub) RegisterCommand added in v0.16.4

func (h *Hub) RegisterCommand(cmd Command)

func (*Hub) RegisterUser

func (h *Hub) RegisterUser(name, pass string) error

func (*Hub) Room

func (h *Hub) Room(name string) *Room

Room finds a room with a given name. It returns nil if room doesn't exist. This function won't be able to retrieve the global chat. See GlobalChatRoom for this.

func (*Hub) Rooms added in v0.16.4

func (h *Hub) Rooms() []*Room

Rooms returns a list of all rooms that exist on the hub. It won't list the global chat. This function returns all rooms regardless of user's permissions. Use RoomsFor to get a filtered list.

func (*Hub) RoomsFor added in v0.25.0

func (h *Hub) RoomsFor(p Peer) []*Room

RoomsFor returns a list of all rooms that are accessible by the peer. It won't list the global chat.

func (*Hub) Search

func (h *Hub) Search(req SearchRequest, s Search, peers []Peer)

func (*Hub) SendGlobalChat added in v0.16.4

func (h *Hub) SendGlobalChat(text string)

func (*Hub) SendNMDCTo added in v0.20.0

func (h *Hub) SendNMDCTo(p Peer, msgs ...nmdcp.Message) error

func (*Hub) Serve

func (h *Hub) Serve(conn net.Conn) error

Serve automatically detects the protocol and start the hub-client handshake.

func (*Hub) ServeADC

func (h *Hub) ServeADC(conn net.Conn, cinfo *ConnInfo) error

func (*Hub) ServeHTTP1

func (h *Hub) ServeHTTP1(conn net.Conn) error

func (*Hub) ServeHTTP2

func (h *Hub) ServeHTTP2(conn net.Conn) error

func (*Hub) ServeIRC

func (h *Hub) ServeIRC(conn net.Conn, cinfo *ConnInfo) error

func (*Hub) ServeNMDC

func (h *Hub) ServeNMDC(conn net.Conn, cinfo *ConnInfo) error

func (*Hub) SetConfig added in v0.20.0

func (h *Hub) SetConfig(key string, val interface{})

func (*Hub) SetConfigBool added in v0.20.0

func (h *Hub) SetConfigBool(key string, val bool)

func (*Hub) SetConfigFloat added in v0.20.0

func (h *Hub) SetConfigFloat(key string, val float64)

func (*Hub) SetConfigInt added in v0.20.0

func (h *Hub) SetConfigInt(key string, val int64)

func (*Hub) SetConfigString added in v0.20.0

func (h *Hub) SetConfigString(key string, val string)

func (*Hub) SetConfigUint added in v0.20.0

func (h *Hub) SetConfigUint(key string, val uint64)

func (*Hub) SetDatabase

func (h *Hub) SetDatabase(db Database)

func (*Hub) Start added in v0.16.4

func (h *Hub) Start() error

func (*Hub) Stats

func (h *Hub) Stats() Stats

func (*Hub) UpdateUser added in v0.16.4

func (h *Hub) UpdateUser(name string, fnc func(u *UserRecord) (bool, error)) error

func (*Hub) Uptime added in v0.16.5

func (h *Hub) Uptime() time.Duration

type Map added in v0.16.4

type Map map[string]interface{}

func (Map) Clone added in v0.16.4

func (m Map) Clone() Map

type Message

type Message struct {
	Time time.Time
	Name string
	Text string
	Me   bool
}

type NameSearch

type NameSearch struct {
	And []string
	Not []string
}

func (NameSearch) Match

func (f NameSearch) Match(r SearchResult) bool

func (NameSearch) MatchName

func (f NameSearch) MatchName(name string) bool

type Peer

type Peer interface {

	// Close the peer's connection.
	Close() error

	// ConnInfo returns a connection information for this peer.
	// The returned value should not be changed.
	ConnInfo() *ConnInfo

	// User returns a user associated with this peer. It may be nil.
	User() *User

	// Online flag for this peer.
	Online() bool
	// Searchable checks if this peer accepts search requests.
	Searchable() bool

	// SID returns a session ID of this peer.
	SID() SID

	// Name returns peer's user name.
	Name() string

	// UserInfo returns a snapshot of a user info.
	UserInfo() UserInfo

	// PeersJoin sends a set of "peer join" events to this peer.
	PeersJoin(e *PeersJoinEvent) error
	// PeersUpdate sends a set of "peer info update" events to this peer.
	PeersUpdate(e *PeersUpdateEvent) error
	// PeersLeave sends a set of "peer leave" events to this peer.
	PeersLeave(e *PeersLeaveEvent) error

	// PrivateMsg sends a private message for this peer.
	PrivateMsg(from Peer, m Message) error
	// HubChatMsg sends a global message from the hub.
	HubChatMsg(m Message) error

	// JoinRoom sends a "room join" event for this peer.
	JoinRoom(room *Room) error
	// ChatMsg sends a chat message from a specific room to this peer.
	ChatMsg(room *Room, from Peer, m Message) error
	// LeaveRoom sends a "room leave" event for this peer.
	LeaveRoom(room *Room) error

	// ConnectTo sends a connection request to this peer.
	ConnectTo(peer Peer, addr string, token string, secure bool) error
	// RevConnectTo sends a reverse connection request to this peer.
	RevConnectTo(peer Peer, token string, secure bool) error

	// Search sends a search request to this peer.
	Search(ctx context.Context, req SearchRequest, out Search) error

	// Redirect the peer to a different hub or address.
	Redirect(addr string) error
	// contains filtered or unexported methods
}

type PeerTopic added in v0.20.0

type PeerTopic interface {
	Topic(topic string) error
}

type PeersJoinEvent added in v0.18.0

type PeersJoinEvent struct {
	Peers []Peer
	// contains filtered or unexported fields
}

type PeersLeaveEvent added in v0.18.0

type PeersLeaveEvent struct {
	Peers []Peer
	// contains filtered or unexported fields
}

type PeersUpdateEvent added in v0.18.0

type PeersUpdateEvent struct {
	Peers []Peer
	// contains filtered or unexported fields
}

type Plugin added in v0.16.4

type Plugin interface {
	// Name is a unique name of a plugin.
	Name() string
	// Version returns a plugin version.
	Version() Version
	// Init the plugin for a given hub. The plugin should save the reference to
	// the hub to be able to call methods on it.
	Init(h *Hub, path string) error
	// Close shuts down a plugin.
	Close() error
}

type ProfileDatabase added in v0.16.4

type ProfileDatabase interface {
	GetProfile(id string) (Map, error)
	PutProfile(id string, m Map) error
	DelProfile(id string) error
	ListProfiles() ([]string, error)
}

type RawCmd added in v0.16.4

type RawCmd string

type ReleaseInfo added in v0.25.0

type ReleaseInfo struct {
	Version semver.Version
	Time    time.Time
	URL     string
	Desc    string
}

ReleaseInfo contains an information about a specific software release.

func CheckForUpdates added in v0.25.0

func CheckForUpdates(ctx context.Context, force bool) (*ReleaseInfo, error)

CheckForUpdates fetches the latest release info and returns it, if it's different from the current version. The method does its own caching so it is safe to call it as frequently as necessary. Force flag can be used to bypass the cache.

type Room

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

func (*Room) CanJoin added in v0.25.0

func (r *Room) CanJoin(p Peer) bool

CanJoin checks if the peer can access the room.

func (*Room) InRoom

func (r *Room) InRoom(p Peer) bool

InRoom checks if the peer is already in this room.

func (*Room) IsPrivate added in v0.25.0

func (r *Room) IsPrivate() bool

IsPrivate reports if a room is private.

func (*Room) Join

func (r *Room) Join(p Peer)

Join adds the peer to the room. It will not run any additional checks. See CanJoin for this.

func (*Room) Leave

func (r *Room) Leave(p Peer)

Leave removes the peer from the room.

func (*Room) Name

func (r *Room) Name() string

Name returns a room name.

func (*Room) Peers

func (r *Room) Peers() []Peer

Peers returns a list of peers currently in the room.

func (*Room) ReplayChat

func (r *Room) ReplayChat(to Peer, n int)

ReplayChat replays the chat log from this room to a given peer.

func (*Room) SID

func (r *Room) SID() SID

func (*Room) SendChat

func (r *Room) SendChat(from Peer, m Message)

SendChat sends chat message to the room.

func (*Room) Users

func (r *Room) Users() int

Users returns the number of users currently in the room.

type SID

type SID = adc.SID
type Search interface {
	Peer() Peer
	SendResult(r SearchResult) error
	Close() error
}

type SearchRequest

type SearchRequest interface {
	Match(r SearchResult) bool
	// contains filtered or unexported methods
}

type SearchResult

type SearchResult interface {
	From() Peer
	// contains filtered or unexported methods
}

type Stats

type Stats struct {
	Name     string         `json:"name"`
	Desc     string         `json:"desc,omitempty"`
	Addr     []string       `json:"addr,omitempty"`
	Private  bool           `json:"private,omitempty"`
	Icon     string         `json:"icon,omitempty"`
	Owner    string         `json:"owner,omitempty"`
	Website  string         `json:"website,omitempty"`
	Email    string         `json:"email,omitempty"`
	Users    int            `json:"users"`
	MaxUsers int            `json:"max-users,omitempty"`
	Share    uint64         `json:"share"`               // MB
	MaxShare uint64         `json:"max-share,omitempty"` // MB
	Enc      string         `json:"encoding,omitempty"`
	Soft     types.Software `json:"soft"`
	Uptime   uint64         `json:"uptime,omitempty"`
	Keyprint string         `json:"-"`
}

func (*Stats) DefaultAddr

func (st *Stats) DefaultAddr() string

type TTH

type TTH = tiger.Hash

type TTHSearch

type TTHSearch TTH

func (TTHSearch) Match

func (h TTHSearch) Match(r SearchResult) bool

type User

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

func (*User) BanUntil added in v0.16.4

func (u *User) BanUntil(t time.Time, reason string)

func (*User) Has added in v0.16.4

func (u *User) Has(flag string) bool

func (*User) HasPerm added in v0.16.4

func (u *User) HasPerm(perm string) bool

func (*User) IsBanned added in v0.16.4

func (u *User) IsBanned() *Ban

func (*User) IsOp added in v0.20.0

func (u *User) IsOp() bool

func (*User) IsOwner added in v0.16.4

func (u *User) IsOwner() bool

func (*User) IsRegistered added in v0.20.0

func (u *User) IsRegistered() bool

func (*User) Name

func (u *User) Name() string

func (*User) Profile added in v0.16.4

func (u *User) Profile() *UserProfile

func (*User) SetName added in v0.16.4

func (u *User) SetName(name string)

func (*User) SetProfile added in v0.16.4

func (u *User) SetProfile(p *UserProfile)

type UserDatabase

type UserDatabase interface {
	IsRegistered(name string) (bool, error)
	GetUser(name string) (*UserRecord, error)
	CreateUser(rec UserRecord) error
	DeleteUser(name string) error
	ListUsers() ([]UserRecord, error)
	UpdateUser(name string, fnc func(u *UserRecord) (bool, error)) error
}

type UserInfo added in v0.16.4

type UserInfo struct {
	Name           string
	Desc           string
	Kind           UserKind
	App            types.Software
	HubsNormal     int
	HubsRegistered int
	HubsOperator   int
	Slots          int
	Share          uint64
	Email          string
	IPv4           bool
	IPv6           bool
	TLS            bool
}

type UserKind added in v0.16.4

type UserKind int

type UserProfile added in v0.16.4

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

func (*UserProfile) Get added in v0.16.4

func (p *UserProfile) Get(key string) (interface{}, bool)

func (*UserProfile) GetBool added in v0.16.4

func (p *UserProfile) GetBool(key string) bool

func (*UserProfile) GetString added in v0.16.4

func (p *UserProfile) GetString(key string) string

func (*UserProfile) Has added in v0.16.4

func (p *UserProfile) Has(flag string) bool

func (*UserProfile) HasParent added in v0.20.0

func (p *UserProfile) HasParent(id string) bool

func (*UserProfile) ID added in v0.16.4

func (p *UserProfile) ID() string

func (*UserProfile) IsOwner added in v0.16.4

func (p *UserProfile) IsOwner() bool

func (*UserProfile) Parent added in v0.16.4

func (p *UserProfile) Parent() *UserProfile

func (*UserProfile) SetParent added in v0.16.4

func (p *UserProfile) SetParent(par *UserProfile) *UserProfile

type UserRecord added in v0.16.4

type UserRecord struct {
	Name    string
	Pass    string
	Profile string
}

type Version added in v0.16.4

type Version struct {
	Major int
	Minor int
	Patch int
	Rev   string
}

func (Version) String added in v0.16.4

func (v Version) String() string

func (Version) Vers3 added in v0.16.4

func (v Version) Vers3() string

Directories

Path Synopsis
plugins
all
lua

Jump to

Keyboard shortcuts

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