cred

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyUsername   = errors.New("empty username")
	ErrNonexistentUser = errors.New("nonexistent user")
)

Functions

This section is empty.

Types

type ManagedServer

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

ManagedServer stores information about a server whose credentials are managed by the credential manager.

func (*ManagedServer) AddCredential

func (s *ManagedServer) AddCredential(username string, uPSK []byte) error

AddCredential adds a user credential.

func (*ManagedServer) Credentials

func (s *ManagedServer) Credentials() []UserCredential

Credentials returns the server credentials.

func (*ManagedServer) DeleteCredential

func (s *ManagedServer) DeleteCredential(username string) error

DeleteCredential deletes a user credential.

func (*ManagedServer) GetCredential

func (s *ManagedServer) GetCredential(username string) (UserCredential, bool)

GetCredential returns the user credential.

func (*ManagedServer) LoadFromFile

func (s *ManagedServer) LoadFromFile() error

LoadFromFile loads credentials from the configured credential file and applies the changes to the associated credential stores.

func (*ManagedServer) Start

func (s *ManagedServer) Start(ctx context.Context)

Start starts the managed server.

func (*ManagedServer) Stop

func (s *ManagedServer) Stop()

Stop stops the managed server.

func (*ManagedServer) UpdateCredential

func (s *ManagedServer) UpdateCredential(username string, uPSK []byte) error

UpdateCredential updates a user credential.

type Manager

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

Manager manages credentials for servers of supported protocols.

func NewManager

func NewManager(logger *zap.Logger) *Manager

NewManager returns a new credential manager.

func (*Manager) LoadAll

func (m *Manager) LoadAll() error

LoadAll loads credentials for all managed servers.

func (*Manager) RegisterServer

func (m *Manager) RegisterServer(name, path string, pskLength int, tcpCredStore, udpCredStore *ss2022.CredStore) (*ManagedServer, error)

RegisterServer registers a server to the manager.

func (*Manager) ReloadAll

func (m *Manager) ReloadAll()

ReloadAll asks all managed servers to reload credentials from files.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start starts all managed servers and registers to reload on SIGUSR1.

func (*Manager) Stop

func (m *Manager) Stop() error

Stop gracefully stops all managed servers.

func (*Manager) String

func (m *Manager) String() string

String implements the service.Service String method.

type UserCredential

type UserCredential struct {
	Name string `json:"username"`
	UPSK []byte `json:"uPSK"`
}

UserCredential stores a user's credential.

func (UserCredential) Compare added in v1.8.0

func (uc UserCredential) Compare(other UserCredential) int

Compare is useful for sorting user credentials by username.

Jump to

Keyboard shortcuts

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