Documentation
¶
Index ¶
- Variables
- func Dial(network string, address string) (net.Conn, error)
- func Gravity(conn io.ReadWriteCloser, k []byte) io.ReadWriteCloser
- func GravityReader(r io.Reader, k []byte) io.Reader
- func GravityWriter(w io.Writer, k []byte) io.Writer
- func Link(a, b io.ReadWriteCloser)
- func LoadApnic() map[string][]*net.IPNet
- func LoadReservedIP() []*net.IPNet
- func NewExpvarPercent(name string, n string, d string) expvar.Func
- func OpenFile(name string) (io.ReadCloser, error)
- func ResolverAny(addr string) *net.Resolver
- func ResolverDns(addr string) *net.Resolver
- func ResolverDoh(addr string) *net.Resolver
- func ResolverDot(addr string) *net.Resolver
- func Salt(s string) []byte
- func SizeParser(s string) uint64
- type Aimbot
- type AimbotOption
- type Context
- type Dialer
- type Direct
- type ExpvarAverage
- type Locale
- func (l *Locale) Close() error
- func (l *Locale) Run() error
- func (l *Locale) Serve(ctx *Context, cli io.ReadWriteCloser) error
- func (l *Locale) ServeProxy(ctx *Context, cli io.ReadWriteCloser) error
- func (l *Locale) ServeSocks4(ctx *Context, cli io.ReadWriteCloser) error
- func (l *Locale) ServeSocks5(ctx *Context, cli io.ReadWriteCloser) error
- func (l *Locale) ServeSocks5TCP(ctx *Context, cli io.ReadWriteCloser, dst string) error
- func (l *Locale) ServeSocks5UDP(ctx *Context, cli io.ReadWriteCloser) error
- func (l *Locale) ServeSocks5UDPRead(srv io.Reader, bnd *net.UDPConn, app *net.UDPAddr, pre []byte) error
- type RandomReader
- type ReadWriteCloser
- type Road
- type Router
- type RouterCache
- type RouterChain
- type RouterIPNet
- type RouterRight
- type RouterRules
- type Tester
- type WireConn
- func (c *WireConn) Close() error
- func (c *WireConn) LocalAddr() net.Addr
- func (c *WireConn) Read(b []byte) (n int, err error)
- func (c *WireConn) RemoteAddr() net.Addr
- func (c *WireConn) SetDeadline(t time.Time) error
- func (c *WireConn) SetReadDeadline(t time.Time) error
- func (c *WireConn) SetWriteDeadline(t time.Time) error
- func (c *WireConn) Write(b []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
var Conf = struct { DialerTimeout time.Duration RouterLruSize int Socks5LruSize int }{ DialerTimeout: time.Second * 8, RouterLruSize: 128, Socks5LruSize: 8, }
Conf is acting as package level configuration.
var Expv = struct { RouterCacheCall *expvar.Int RouterCacheHits *expvar.Int RouterCacheRate expvar.Func RouterIPNetCall *expvar.Int RouterIPNetTime *ExpvarAverage }{ RouterCacheCall: expvar.NewInt("RouterCache.Call"), RouterCacheHits: expvar.NewInt("RouterCache.Hits"), RouterCacheRate: NewExpvarPercent("RouterCache.Rate", "RouterCache.Hits", "RouterCache.Call"), RouterIPNetCall: expvar.NewInt("RouterIPNet.Call"), RouterIPNetTime: NewExpvarAverage("RouterIPNet.Time", 64), }
Expv is a simple wrapper around the expvars package.
Functions ¶
func Gravity ¶
func Gravity(conn io.ReadWriteCloser, k []byte) io.ReadWriteCloser
Gravity double, happiness double.
func GravityReader ¶
GravityReader wraps an io.Reader with RC4 crypto.
func GravityWriter ¶
GravityWriter wraps an io.Writer with RC4 crypto.
func Link ¶
func Link(a, b io.ReadWriteCloser)
Link copies from src to dst and dst to src until either EOF is reached.
func LoadApnic ¶
LoadApnic loads remote resource. APNIC is the Regional Internet Registry administering IP addresses for the Asia Pacific.
func LoadReservedIP ¶
LoadReservedIP loads reserved ip addresses.
Introduction: See https://en.wikipedia.org/wiki/Reserved_IP_addresses
func NewExpvarPercent ¶
NewExpvarPercent creates a new expvar.Func that calculates the ratio of two expvar.Int or expvar.Float metrics.
func OpenFile ¶
func OpenFile(name string) (io.ReadCloser, error)
OpenFile select the appropriate method to open the file based on the incoming args automatically.
Examples: OpenFile("/etc/hosts") OpenFile("https://raw.githubusercontent.com/libraries/daze/master/README.md")
func ResolverAny ¶
ResolverDot returns a DoT resolver. Depending on the addr entered, the dns, dot or doh protocol will be used automatically.
Dns: 1.1.1.1:53 Dot: 1.1.1.1:853 Doh: https://1.1.1.1/dns-query
func ResolverDoh ¶
ResolverDoh returns a DoH resolver. For further information, see https://datatracker.ietf.org/doc/html/rfc8484.
func ResolverDot ¶
ResolverDot returns a DoT resolver. For further information, see https://datatracker.ietf.org/doc/html/rfc7858.
func SizeParser ¶
SizeParser converts a string like "1K", "1M", or "1G" to bytes as uint64. It expects the input string to end with a unit (K, M, or G) and panics if the unit is invalid. The number part can be a float (e.g., "1.5M") and is converted to bytes based on the unit.
Types ¶
type Aimbot ¶
Aimbot automatically distinguish whether to use a proxy or a local network.
func NewAimbot ¶
func NewAimbot(client Dialer, option *AimbotOption) *Aimbot
NewAimbot returns a new Aimbot.
type AimbotOption ¶
AimbotOption provides configuration for quick initialization of Aimbot.
type Dialer ¶
type Dialer interface {
Dial(ctx *Context, network string, address string) (io.ReadWriteCloser, error)
}
Dialer abstracts the way to establish network connections.
type ExpvarAverage ¶
ExpvarAverage is a structure to maintain a running average using expvar.Float.
func NewExpvarAverage ¶
func NewExpvarAverage(name string, length int) *ExpvarAverage
NewExpvarAverage creates and initializes a new ExpvarAverage instance.
func (*ExpvarAverage) Add ¶
func (e *ExpvarAverage) Add(value float64)
Adds a new value to the running average. This is not strictly concurrency-safe, but it won't have much impact on the data.
type Locale ¶
Locale is the main process of daze. In most cases, it is usually deployed as a daemon on a local machine.
func (*Locale) Serve ¶
func (l *Locale) Serve(ctx *Context, cli io.ReadWriteCloser) error
Serve serves incoming connections and handle it with a different handler(ServeProxy/ServeSocks4/ServeSocks5).
func (*Locale) ServeProxy ¶
func (l *Locale) ServeProxy(ctx *Context, cli io.ReadWriteCloser) error
ServeProxy serves traffic in HTTP Proxy/Tunnel format.
Introduction: See https://en.wikipedia.org/wiki/Proxy_server See https://en.wikipedia.org/wiki/HTTP_tunnel See https://www.infoq.com/articles/Web-Sockets-Proxy-Servers/
func (*Locale) ServeSocks4 ¶
func (l *Locale) ServeSocks4(ctx *Context, cli io.ReadWriteCloser) error
ServeSocks4 serves traffic in SOCKS4/SOCKS4a format.
Introduction: See https://en.wikipedia.org/wiki/SOCKS See http://ftp.icm.edu.pl/packages/socks/socks4/SOCKS4.protocol
func (*Locale) ServeSocks5 ¶
func (l *Locale) ServeSocks5(ctx *Context, cli io.ReadWriteCloser) error
ServeSocks5 serves traffic in SOCKS5 format.
Introduction: See https://en.wikipedia.org/wiki/SOCKS See https://tools.ietf.org/html/rfc1928
func (*Locale) ServeSocks5TCP ¶
ServeSocks5TCP serves socks5 TCP protocol.
func (*Locale) ServeSocks5UDP ¶
func (l *Locale) ServeSocks5UDP(ctx *Context, cli io.ReadWriteCloser) error
ServeSocks5UDP serves socks5 UDP protocol.
type RandomReader ¶
type RandomReader struct{}
RandomReader is a simple random number generator. Note that it is not cryptographically secure, but for daze, the randomness it provides is enough.
type ReadWriteCloser ¶
ReadWriteCloser is the interface that groups the basic Read, Write and Close methods.
type Router ¶
type Router interface {
// The host must be a literal IP address, or a host name that can be resolved to IP addresses.
// Examples:
// Road("golang.org")
// Road("192.0.2.1")
Road(ctx *Context, host string) Road
}
Router is a selector that will judge the host address.
type RouterCache ¶
RouterCache cache routing results for next use.
func NewRouterCache ¶
func NewRouterCache(r Router) *RouterCache
NewRouterCache returns a new Cache object.
type RouterChain ¶
type RouterChain struct {
L []Router
}
RouterChain concat multiple routers in series.
func NewRouterChain ¶
func NewRouterChain(router ...Router) *RouterChain
NewRouterChain returns a new RouterChain.
type RouterIPNet ¶
RouterIPNet is a router by IPNets. It judges whether an IP or domain name is within its range.
func NewRouterIPNet ¶
func NewRouterIPNet() *RouterIPNet
NewRouterIPNet returns a new RouterIPNet object.
func (*RouterIPNet) FromFile ¶
func (r *RouterIPNet) FromFile(name string)
FromFile loads a CIDR file.
type RouterRight ¶
type RouterRight struct {
R Road
}
RouterRight always returns the same road.
func NewRouterRight ¶
func NewRouterRight(road Road) *RouterRight
NewRouterRight returns a new RouterRight.
type RouterRules ¶
RouterRules aims to be a minimal configuration file format that's easy to read due to obvious semantics. There are two parts per line on the RULE file: mode and glob. mode is on the left of the space sign and glob is on the right. mode is a character that describes whether the host should be accessed through a proxy, and the glob is a glob-style string.
Glob patterns: * h?llo matches hello, hallo and hxllo * h*llo matches hllo and heeeello * h[ae]llo matches hello and hallo, but not hillo * h[^e]llo matches hallo, hbllo, ... but not hello * h[a-b]llo matches hallo and hbllo
This is a normal RULE document: L a.com a.a.com R b.com *.b.com B c.com
L(ocale) means using locale network R(emote) means using remote network B(anned) means to block it
func (*RouterRules) FromFile ¶
func (r *RouterRules) FromFile(name string)
FromFile loads a RULE file.
type Tester ¶
A remote server for testing.
func (*Tester) TCPServe ¶
func (t *Tester) TCPServe(cli io.ReadWriteCloser)
TCPServe serves incoming connections.
type WireConn ¶
WireConn structure can be used for DoH protocol processing.
func (*WireConn) RemoteAddr ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
daze
command
|
|
|
lib
|
|
|
doa
Package doa stands for "dead or alive".
|
Package doa stands for "dead or alive". |
|
gracefulexit
Package gracefulexit provides a method to exit the program gracefully.
|
Package gracefulexit provides a method to exit the program gracefully. |
|
gracefulexit/cmd/http
command
|
|
|
lru
Package lru implements an LRU cache.
|
Package lru implements an LRU cache. |
|
pretty
Package pretty provides utilities for beautifying console output.
|
Package pretty provides utilities for beautifying console output. |
|
pretty/cmd/progress
command
|
|
|
pretty/cmd/table
command
|
|
|
pretty/cmd/tree
command
|
|
|
priority
Package priority implements a priority mutex.
|
Package priority implements a priority mutex. |
|
priority/cmd/race
command
|
|
|
rate
Package rate provides a rate limiter.
|
Package rate provides a rate limiter. |
|
rate/cmd/race
command
|
|
|
protocol
|
|