users

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 9 Imported by: 0

README

users

for the ftp and the sftp server to work

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqSlice

func UniqSlice[T comparable](s []T) []T

Types

type LocalUsers

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

func NewLocalUsers

func NewLocalUsers(logger *slog.Logger) *LocalUsers

NewLocalUsers creates a new LocalUsers

func (*LocalUsers) Add

func (u *LocalUsers) Add(user, pass string) *User

Add adds a new user

func (*LocalUsers) FindUser added in v0.1.13

func (u *LocalUsers) FindUser(ctx context.Context, username, password, ipaddr string) (any, error)

FindUser returns a user by username and password, if the user is not found it returns an error

func (*LocalUsers) Get

func (u *LocalUsers) Get(username string) (*User, error)

Get returns a user by username, if the user is not found it returns an error

func (*LocalUsers) List

func (u *LocalUsers) List() (map[string]*User, error)

List returns all users

func (*LocalUsers) Logger added in v0.1.36

func (u *LocalUsers) Logger() *slog.Logger

func (*LocalUsers) Remove

func (u *LocalUsers) Remove(user string) *User

Remove removes a user

func (*LocalUsers) VerifyUser added in v0.1.26

func (u *LocalUsers) VerifyUser(r *http.Request) (any, error)

type User

type User struct {
	Username string
	Password string
	IPs      map[string]*netip.Prefix
}

func (*User) AddIP

func (u *User) AddIP(ip string) (err error)

AddIP adds an IP prefix to the user if the ip is without the prefix, it will add /32

func (*User) FindIP

func (u *User) FindIP(ip string) bool

FindIP finds an IP in the prefixes in the user

func (*User) RemoveIP

func (u *User) RemoveIP(ip string)

RemoveIP removes an IP prefix from the user if the ip is without the prefix, it will add /32

Jump to

Keyboard shortcuts

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