settings

package
v0.0.0-...-ca90a00 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserAllowAll = regexp.MustCompile("")

Functions

func EncodeConfig

func EncodeConfig(c Config) []byte

func Env

func Env(name string) string

Env returns a chisel environment variable

func EnvDuration

func EnvDuration(name string, def time.Duration) time.Duration

EnvDuration returns a duration using an environment variable, with a default fallback

func EnvInt

func EnvInt(name string, def int) int

EnvInt returns an integer using an environment variable, with a default fallback

func L4Proto

func L4Proto(s string) (head, proto string)

L4Proto extacts the layer-4 protocol from the given string

func ParseAuth

func ParseAuth(auth string) (string, string)

Types

type Config

type Config struct {
	Version string
	Remotes
}

func DecodeConfig

func DecodeConfig(b []byte) (*Config, error)

type Remote

type Remote struct {
	LocalHost, LocalPort, LocalProto    string
	RemoteHost, RemotePort, RemoteProto string
	Socks, Reverse, Stdio               bool
}

func DecodeRemote

func DecodeRemote(s string) (*Remote, error)

func (Remote) CanListen

func (r Remote) CanListen() bool

CanListen checks if the port can be listened on

func (Remote) Encode

func (r Remote) Encode() string

Encode remote to a string

func (Remote) Local

func (r Remote) Local() string

Local is the decodable local portion

func (Remote) Remote

func (r Remote) Remote() string

Remote is the decodable remote portion

func (Remote) String

func (r Remote) String() string

implement Stringer

func (Remote) UserAddr

func (r Remote) UserAddr() string

UserAddr is checked when checking if a user has access to a given remote

type Remotes

type Remotes []*Remote

func (Remotes) Encode

func (rs Remotes) Encode() []string

Encode back into strings

func (Remotes) Reversed

func (rs Remotes) Reversed(reverse bool) Remotes

Filter out forward reversed/non-reversed remotes

type User

type User struct {
	Name  string
	Pass  string
	Addrs []*regexp.Regexp
}

func (*User) HasAccess

func (u *User) HasAccess(addr string) bool

type UserIndex

type UserIndex struct {
	*cio.Logger
	*Users
	// contains filtered or unexported fields
}

UserIndex is a reloadable user source

func NewUserIndex

func NewUserIndex(logger *cio.Logger) *UserIndex

NewUserIndex creates a source for users

func (*UserIndex) LoadUsers

func (u *UserIndex) LoadUsers(configFile string) error

LoadUsers is responsible for loading users from a file

type Users

type Users struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewUsers

func NewUsers() *Users

func (*Users) AddUser

func (u *Users) AddUser(user *User)

AddUser adds a users to the set

func (*Users) Del

func (u *Users) Del(key string)

Del ete a users from the list

func (*Users) Get

func (u *Users) Get(key string) (*User, bool)

Get user from the index by key

func (*Users) Len

func (u *Users) Len() int

Len returns the numbers of users

func (*Users) Reset

func (u *Users) Reset(users []*User)

Reset all users to the given set, Use nil to remove all.

func (*Users) Set

func (u *Users) Set(key string, user *User)

Set a users into the list by specific key

Jump to

Keyboard shortcuts

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