settings

package
v0.0.0-...-3835ea7 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func EncodeConfig

func EncodeConfig(c Config) []byte

EncodeConfig 编码配置

func Env

func Env(name string) string

Env 前缀为 CHISEL_ 的环境变量

func EnvDuration

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

EnvDuration 前缀为 CHISEL_ 的时间环境变量

func EnvInt

func EnvInt(name string, def int) int

EnvInt 前缀为 CHISEL_ 的整型环境变量

func L4Proto

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

L4Proto 从给定的字符串中提取第四层协议

func ParseAuth

func ParseAuth(auth string) (string, string)

Types

type Config

type Config struct {
	// 版本号
	Version string
	// 本地与远程服务的映射集合
	Remotes
}

Config 本地与远程服务的映射集合及协议版本号

func DecodeConfig

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

DecodeConfig 解码配置

type Remote

type Remote struct {
	// forwarding host 指的是chisel server上的host
	LocalHost string
	// forwarding port 指的是chisel server上的port
	LocalPort string
	// 指的是chisel server上的协议
	LocalProto string
	// target host 指的是要代理的服务的host
	RemoteHost string
	// target port 指的是要代理的服务的port
	RemotePort string
	// 指的是要代理的服务的协议
	RemoteProto string
	Socks       bool
	// 反向端口转发,是否开启客户端指定反向端口转发远程服务
	Reverse bool
	// 使用标准输入输出
	Stdio bool
}

Remote 本地与远程服务的映射

func DecodeRemote

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

DecodeRemote 解码映射

func (Remote) CanListen

func (r Remote) CanListen() bool

CanListen 检查端口是否可以被监听

func (Remote) Encode

func (r Remote) Encode() string

Encode 编码

func (Remote) Local

func (r Remote) Local() string

Local is the decodable local portion

func (Remote) Remote

func (r Remote) Remote() string

Remote 可解码的远程部分

func (Remote) String

func (r Remote) String() string

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

Remotes 本地与远程服务的映射集合

func (Remotes) Encode

func (rs Remotes) Encode() []string

Encode 编码

func (Remotes) Reversed

func (rs Remotes) Reversed(reverse bool) Remotes

Reversed 为true表示过滤反向代理,false表示过滤非反向代理

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 可重载的用户源配置

func NewUserIndex

func NewUserIndex(logger *cio.Logger) *UserIndex

NewUserIndex 创建

func (*UserIndex) LoadUsers

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

LoadUsers 从给定的文件路径加载,默认为authfile指定的文件路径

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 返回users数量

func (*Users) Reset

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

Reset 重置,如果值为nil表示清除所有

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