constant

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

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

	TCP NetWork = iota
	UDP

	HTTP Type = iota
	HTTPCONNECT
	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 SetConfig added in v0.19.0

func SetConfig(file string)

SetConfig is used to set the configuration file

func SetHomeDir added in v0.19.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
	Reject

	Shadowsocks
	ShadowsocksR
	Snell
	Socks5
	Http
	Vmess
	Trojan

	Relay
	Selector
	Fallback
	URLTest
	LoadBalance
)

Adapter Type

func (AdapterType) String added in v0.5.0

func (at AdapterType) String() string

type Chain added in v0.19.0

type Chain []string

func (Chain) String added in v0.19.0

func (c Chain) String() string

type Conn added in v0.19.0

type Conn interface {
	net.Conn
	Connection
}

type Connection added in v0.19.0

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

type DelayHistory added in v0.19.0

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

type Metadata added in v0.19.0

type Metadata struct {
	NetWork  NetWork `json:"network"`
	Type     Type    `json:"type"`
	SrcIP    net.IP  `json:"sourceIP"`
	DstIP    net.IP  `json:"destinationIP"`
	SrcPort  string  `json:"sourcePort"`
	DstPort  string  `json:"destinationPort"`
	AddrType int     `json:"-"`
	Host     string  `json:"host"`
}

Metadata is used to store connection address

func (*Metadata) RemoteAddress added in v0.19.0

func (m *Metadata) RemoteAddress() string

func (*Metadata) Resolved added in v0.19.0

func (m *Metadata) Resolved() bool

func (*Metadata) SourceAddress added in v0.19.0

func (m *Metadata) SourceAddress() string

func (*Metadata) String added in v0.19.0

func (m *Metadata) String() string

func (*Metadata) UDPAddr added in v0.19.0

func (m *Metadata) UDPAddr() *net.UDPAddr

func (*Metadata) Valid added in v0.19.0

func (m *Metadata) Valid() bool

type NetWork

type NetWork int

func (NetWork) MarshalJSON added in v0.19.0

func (n NetWork) MarshalJSON() ([]byte, error)

func (NetWork) String

func (n NetWork) String() string

type PacketConn added in v0.19.0

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
	StreamConn(c net.Conn, metadata *Metadata) (net.Conn, error)
	DialContext(ctx context.Context, metadata *Metadata) (Conn, error)
	DialUDP(metadata *Metadata) (PacketConn, error)
	SupportUDP() bool
	MarshalJSON() ([]byte, error)
	Addr() string
	// Unwrap extracts the proxy from a proxy-group. It returns nil when nothing to extract.
	Unwrap(metadata *Metadata) Proxy
}

type Rule

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

type RuleType

type RuleType int
const (
	Domain RuleType = iota
	DomainSuffix
	DomainKeyword
	GEOIP
	IPCIDR
	SrcIPCIDR
	SrcPort
	DstPort
	MATCH
)

Rule Type

func (RuleType) String added in v0.5.0

func (rt RuleType) String() string

type ServerAdapter

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

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

type Type added in v0.19.0

type Type int

func (Type) MarshalJSON added in v0.19.0

func (t Type) MarshalJSON() ([]byte, error)

func (Type) String added in v0.19.0

func (t Type) String() string

type UDPPacket added in v0.19.0

type UDPPacket interface {
	// Data get the payload of UDP Packet
	Data() []byte

	// WriteBack writes the payload with source IP/Port equals addr
	// - variable source IP/Port is important to STUN
	// - if addr is not provided, WriteBack will wirte out UDP packet with SourceIP/Prot equals to origional Target,
	//   this is important when using Fake-IP.
	WriteBack(b []byte, addr net.Addr) (n int, err error)

	// Drop call after packet is used, could recycle buffer in this function.
	Drop()

	// LocalAddr returns the source IP/Port of packet
	LocalAddr() net.Addr
}

UDPPacket contains the data of UDP packet, and offers control/info of UDP packet's source

Jump to

Keyboard shortcuts

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