constant

package
v0.0.0-...-280623b Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

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

	TCP NetWork = iota
	UDP

	HTTP Type = iota
	SOCKS
	REDIR
)

Socks addr type

View Source
const Name = "clash"

Variables

View Source
var (
	Version   = "unknown version"
	BuildTime = "unknown time"
)
View Source
var Path *path

Path is used to get the configuration path

Functions

func SetHomeDir

func SetHomeDir(root string)

SetHomeDir is used to set the configuration path

Types

type AdapterType

type AdapterType int

AdapterType is enum of adapter type

const (
	Direct AdapterType = iota
	Fallback
	Reject
	Selector
	Shadowsocks
	ShadowsocksR
	Snell
	Socks5
	Http
	URLTest
	Vmess
	LoadBalance
)

Adapter Type

func (AdapterType) String

func (at AdapterType) String() string

type Chain

type Chain []string

func (Chain) String

func (c Chain) String() string

type Conn

type Conn interface {
	net.Conn
	Connection
}

type Connection

type Connection interface {
	Chains() Chain
	AppendToChains(adapter ProxyAdapter)
}

type DelayHistory

type DelayHistory struct {
	Time  time.Time `json:"time"`
	Delay uint16    `json:"delay"`
}

type Metadata

type Metadata struct {
	NetWork  NetWork
	Type     Type
	SrcIP    *net.IP
	DstIP    *net.IP
	SrcPort  string
	DstPort  string
	AddrType int
	Host     string
}

Metadata is used to store connection address

func (*Metadata) RemoteAddress

func (m *Metadata) RemoteAddress() string

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) Valid

func (m *Metadata) Valid() bool

type NetWork

type NetWork int

func (*NetWork) String

func (n *NetWork) String() string

type PacketConn

type PacketConn interface {
	net.PacketConn
	Connection
}

type Proxy

type Proxy interface {
	ProxyAdapter
	Alive() bool
	DelayHistory() []DelayHistory
	Dial(metadata *Metadata) (Conn, error)
	LastDelay() uint16
	URLTest(ctx context.Context, url string) (uint16, error)
}

type ProxyAdapter

type ProxyAdapter interface {
	Name() string
	Type() AdapterType
	DialContext(ctx context.Context, metadata *Metadata) (Conn, error)
	DialUDP(metadata *Metadata) (PacketConn, net.Addr, error)
	SupportUDP() bool
	Destroy()
	MarshalJSON() ([]byte, error)
}

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
	SrcIPCIDR
	SrcPort
	DstPort
	MATCH
)

Rule Type

func (RuleType) String

func (rt RuleType) String() string

type ServerAdapter

type ServerAdapter interface {
	net.Conn
	Metadata() *Metadata
}

type Traffic

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

func NewTraffic

func NewTraffic(interval time.Duration) *Traffic

func (*Traffic) Down

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

func (*Traffic) Now

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

func (*Traffic) Up

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

type Type

type Type int

Jump to

Keyboard shortcuts

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