constant

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: MIT Imports: 5 Imported by: 272

Documentation

Index

Constants

View Source
const (
	AtypIPv4       = 1
	AtypDomainName = 3
	AtypIPv6       = 4

	TCP NetWork = iota
	UDP

	HTTP SourceType = iota
	SOCKS
)

Socks addr type

View Source
const Name = "clash"

Variables

View Source
var (
	// LogLevelMapping is a mapping for LogLevel enum
	LogLevelMapping = map[string]LogLevel{
		"error":   ERROR,
		"warning": WARNING,
		"info":    INFO,
		"debug":   DEBUG,
	}
)
View Source
var Path *path

Path is used to get the configuration path

Functions

func SetHomeDir added in v0.8.0

func SetHomeDir(root string)

SetHomeDir is used to set the configuration path

Types

type AdapterType added in v0.5.0

type AdapterType int

AdapterType is enum of adapter type

const (
	Direct AdapterType = iota
	Fallback
	Reject
	Selector
	Shadowsocks
	Socks5
	URLTest
	Vmess
)

Adapter Type

func (AdapterType) String added in v0.5.0

func (at AdapterType) String() string

type General added in v0.5.0

type General struct {
	Mode      *string `json:"mode,omitempty"`
	AllowLan  *bool   `json:"allow-lan,omitempty"`
	Port      *int    `json:"port,omitempty"`
	SocksPort *int    `json:"socks-port,omitempty"`
	RedirPort *int    `json:"redir-port,omitempty"`
	LogLevel  *string `json:"log-level,omitempty"`
}

type LogLevel added in v0.6.0

type LogLevel int
const (
	ERROR LogLevel = iota
	WARNING
	INFO
	DEBUG
)

func (LogLevel) String added in v0.6.0

func (l LogLevel) String() string

type Metadata added in v0.8.0

type Metadata struct {
	NetWork  NetWork
	Source   SourceType
	AddrType int
	Host     string
	IP       *net.IP
	Port     string
}

Metadata is used to store connection address

func (*Metadata) String added in v0.8.0

func (addr *Metadata) String() string

type NetWork

type NetWork int

func (*NetWork) String

func (n *NetWork) String() string

type Proxy

type Proxy interface {
	Name() string
	Type() AdapterType
	Generator(metadata *Metadata) (ProxyAdapter, error)
}

type ProxyAdapter

type ProxyAdapter interface {
	Conn() net.Conn
	Close()
}

type ProxySignal added in v0.5.0

type ProxySignal struct {
	Done   chan<- struct{}
	Closed <-chan struct{}
}

ProxySignal is used to handle graceful shutdown of proxy

type Rule

type Rule interface {
	RuleType() RuleType
	IsMatch(metadata *Metadata) bool
	Adapter() string
	Payload() string
}

type RuleType

type RuleType int
const (
	Domain RuleType = iota
	DomainSuffix
	DomainKeyword
	GEOIP
	IPCIDR
	FINAL
)

Rule Type

func (RuleType) String added in v0.5.0

func (rt RuleType) String() string

type ServerAdapter

type ServerAdapter interface {
	Metadata() *Metadata
	Close()
}

type SourceType added in v0.6.0

type SourceType int

type Traffic added in v0.4.0

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

func NewTraffic added in v0.4.0

func NewTraffic(interval time.Duration) *Traffic

func (*Traffic) Down added in v0.4.0

func (t *Traffic) Down() chan<- int64

func (*Traffic) Now added in v0.4.0

func (t *Traffic) Now() (up int64, down int64)

func (*Traffic) Up added in v0.4.0

func (t *Traffic) Up() chan<- int64

Jump to

Keyboard shortcuts

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