Documentation ¶
Index ¶
- Constants
- Variables
- func CancelLocalServiceEvent(id string)
- func CancelLocalTunnelEvent(id string)
- func CancelRemoteServiceEvent(id string)
- func CancelRemoteTunnelEvent(id string)
- func CheckDohClients(isDirect bool, clients []*DohClient, domain string)
- func CheckDohs(isDirect bool, dohs []*xnet.Doh, domain string, notify event.Notify)
- func CheckPoints(points []*xnet.Point, notify event.Notify)
- func ClearLocalTunnels()
- func CloseLocalTunnel(id string)
- func Copy(dst net.Conn, src net.Conn, ctx context.Context, sendOrReceive bool) (written int64, er error, ew error)
- func DialNetAddr(point *xnet.Point, addr xnet.Addr) (net.Conn, error)
- func DialPeerAddr(point *xnet.Point, addr xnet.Addr) (net.Conn, error)
- func DnsLocalQuery(b []byte) (p []byte)
- func DnsMustQuery(b []byte) (p []byte)
- func DnsRemoteQuery(b []byte) (p []byte)
- func DohQuery(b []byte, isDirect bool) (p []byte, err error)
- func GetErrorCode(err error) (code byte)
- func GetErrorCodeFromTags(err error) (code byte)
- func InitDoh()
- func LocalDo(tunnel *Tunnel) (err error)
- func OrderPoints()
- func ParseQueryDomain(b []byte) (domain string)
- func RegProtocol(name string, p *Protocol) error
- func SortDohClients(clients []*DohClient)
- func StartLocal()
- func StartRemote()
- func StopLocal()
- func StopRemote()
- func SubLocalServiceEvent(s event.Stream) string
- func SubLocalTunnelEvent(s event.Stream) string
- func SubRemoteServiceEvent(s event.Stream) string
- func SubRemoteTunnelEvent(s event.Stream) string
- type Create
- type DialAddr
- type Dialer
- type Do
- type DohClient
- func (d DohClient) Close() (err error)
- func (d *DohClient) Do(req *http.Request, isDirect bool) (rsp *http.Response, err error)
- func (d DohClient) NewGetRequest(b []byte) (req *http.Request, err error)
- func (d DohClient) NewPostRequest(b []byte) (req *http.Request, err error)
- func (d *DohClient) Query(b []byte, isDirect bool) (p []byte, err error)
- type FatalError
- type Filter
- type Peer
- type PointStat
- type Proto
- func (p *Proto) ClearConn()
- func (p *Proto) Close() error
- func (p *Proto) GetProto() *Proto
- func (p *Proto) Handle(conn net.Conn)
- func (p *Proto) NewTunnel(id string, src net.Conn, method byte, addr xnet.Addr) *Tunnel
- func (p *Proto) Open(t *Tunnel) error
- func (p *Proto) ReadFull(r io.Reader, b []byte) (n int, err error)
- func (p *Proto) Stat() *PointStat
- type Protocol
- type ServiceEventNotifier
- type Stat
- type Tunnel
- type TunnelData
- type TunnelEvent
- type TunnelEventNotifier
- type WriteTimeOutError
Constants ¶
View Source
const ( //socks5 error code ERR byte = 1 ERR_RULE byte = 2 ERR_NET byte = 3 ERR_DST byte = 4 ERR_DST_REFUSE byte = 5 ERR_TTL_EXPIRED byte = 6 ERR_COMMAND_UNKNOWN byte = 7 ERR_ADDR_TYPE byte = 8 ERR_REPEAT_ID byte = 9 ERR_CONN_TIMEOUT byte = 10 ERR_DIAL_TIMEOUT byte = 11 ERR_DST_RESET byte = 12 ERR_FORCE_CLOSE byte = 13 ERR_ABORT byte = 14 ERR_TIMEOUT byte = 16 ERR_INVALID_ADDR byte = 17 ERR_UNKNOWN_NETWORK byte = 18 ERR_DNS byte = 19 ERR_DNS_CONFIG byte = 20 ERR_REFUSE byte = 21 ERR_ADDR byte = 22 ERR_SRC_ABORT byte = 23 ERR_DST_TIMEOUT byte = 24 ERR_DST_DOWN byte = 25 ERR_DST_UNREACH byte = 26 ERR_RESET byte = 27 ERR_READ_TIMEOUT byte = 28 ERR_CLOSED byte = 29 ERR_DST_ABORT byte = 30 ERR_UNKNOWN byte = 50 )
View Source
const ( CONNECT byte = 1 ASSOCIATE byte = 3 UDP byte = 5 //udp relay DNS byte = 6 //dns query SERVICE_START byte = 1 SERVICE_STOP byte = 2 SERVICE_DATA byte = 3 SERVICE_ERROR byte = 4 SERVICE_FATAL byte = 5 SERVICE_STAT byte = 6 TUNNEL_OPEN byte = 1 TUNNEL_SENT byte = 2 TUNNEL_RECIVE byte = 3 TUNNEL_CLOSE byte = 4 TUNNEL_Error byte = 5 TunnelEvent_MAX int = 300 )
Variables ¶
View Source
var Break_Time int64 = 5 * 1000
View Source
var CopyBuffers = sync.Pool{ New: func() interface{} { buf := make([]byte, 8096) return &buf }, }
View Source
var Copy_Read_Loop_Max = Copy_Read_Timeout / 45
View Source
var Copy_Read_Timeout int = 5 * 60 //second
View Source
var DefaultFilter = &defautFilter{filter: EmptyFilter}
View Source
var EmptyFilter = &filter{}
View Source
var ErrTags = map[string]byte{ "established connection was aborted": ERR_SRC_ABORT, "connection was forcibly closed by the remote ": ERR_DST_ABORT, "connected host has failed to respond": ERR_DST_TIMEOUT, "broken pipe": ERR_RESET, }
View Source
var ErrTip = map[byte]string{ ERR: "proxy server error", ERR_RULE: "proxy server rule refuse", ERR_NET: "use of closed network connection", ERR_DST_UNREACH: "The server is unreachable", ERR_DST_REFUSE: "The remote host actively refused the attempt to connect to it", ERR_TTL_EXPIRED: "TTL expired", ERR_COMMAND_UNKNOWN: "command not supported", ERR_ADDR_TYPE: "address type not supported", ERR_REPEAT_ID: "repeat stream id", ERR_DIAL_TIMEOUT: "dial dst i/o timeout", ERR_DST_RESET: "reset by peer", ERR_CONN_TIMEOUT: "forcibly closed by the remote host", ERR_FORCE_CLOSE: "forcibly closed by proxy", ERR_ABORT: "aborted by your host software", ERR_DST_TIMEOUT: "The connection failed due to an error or timeout", ERR_TIMEOUT: "net timeout", ERR_INVALID_ADDR: "invalid error", ERR_UNKNOWN_NETWORK: "unknown network", ERR_DNS: "dns error", ERR_DNS_CONFIG: "dns config error", ERR_REFUSE: "connection refuse", ERR_RESET: "reset by peer", ERR_ADDR: "addr error", ERR_SRC_ABORT: "aborted by the software in your host machine, possibly because of timeout or protocol error", ERR_DST_ABORT: "forcibly closed by the remote host", ERR_DST_DOWN: "The server is temporarily or permanently unreachable", ERR_READ_TIMEOUT: "read timeout", ERR_CLOSED: "use of closed network connection", ERR_UNKNOWN: "unknown error", }
View Source
var Err_Manually_Close = fmt.Errorf("forceibly closed manually")
View Source
var GOOGLE = xnet.DomainToAddr("google.com", 443)
View Source
var Header_TimeOut int64 = 10 * 1000
Functions ¶
func CancelLocalServiceEvent ¶
func CancelLocalServiceEvent(id string)
func CancelLocalTunnelEvent ¶
func CancelLocalTunnelEvent(id string)
func CancelRemoteServiceEvent ¶
func CancelRemoteServiceEvent(id string)
func CancelRemoteTunnelEvent ¶
func CancelRemoteTunnelEvent(id string)
func CheckDohClients ¶
func ClearLocalTunnels ¶
func ClearLocalTunnels()
func CloseLocalTunnel ¶
func CloseLocalTunnel(id string)
func DnsLocalQuery ¶
func DnsMustQuery ¶
func DnsRemoteQuery ¶
func GetErrorCode ¶
func GetErrorCodeFromTags ¶ added in v0.9.3
func OrderPoints ¶
func OrderPoints()
func ParseQueryDomain ¶
func RegProtocol ¶
func SortDohClients ¶
func SortDohClients(clients []*DohClient)
func StartLocal ¶
func StartLocal()
func StartRemote ¶
func StartRemote()
func StopRemote ¶
func StopRemote()
func SubLocalServiceEvent ¶
func SubLocalTunnelEvent ¶
func SubRemoteServiceEvent ¶
func SubRemoteTunnelEvent ¶
Types ¶
type DohClient ¶
func (DohClient) NewGetRequest ¶
func (DohClient) NewPostRequest ¶
type FatalError ¶ added in v0.9.3
type FatalError struct {
// contains filtered or unexported fields
}
func NewFatalError ¶ added in v0.9.3
func NewFatalError(s string) FatalError
func (FatalError) Error ¶ added in v0.9.3
func (e FatalError) Error() string
type Filter ¶
type Filter interface { BeforeDial(t *Tunnel, err error) error AfterDial(t *Tunnel, err error) error BeforeSend(t *Tunnel) error AfterSend(t *Tunnel) error BeforeReceive(t *Tunnel) error AfterReceive(t *Tunnel) error }
protocol filter
type PointStat ¶
type PointStat struct { Id string Code string Name string Transport string Protocol string ConnCount int StreamCount int IsDirect bool }
func NewPointStat ¶
type Proto ¶
type Proto struct { *xnet.Point Filter Do Do DialAddr ServiceEventNotifier TunnelEventNotifier IsDirect bool // contains filtered or unexported fields }
all proxy protocol proto implement
type Protocol ¶
func GetProtocol ¶
type ServiceEventNotifier ¶
type ServiceEventNotifier interface { OnStart() OnStop(err error) OnError(err error) OnFatal(err error) SubServiceEvent(s event.Stream) string CancelServiceEvent(id string) }
event type: start|close|error|fatal|data|stat
type Tunnel ¶
type Tunnel struct { Id string Method byte Addr xnet.Addr Src net.Conn Dst net.Conn SrcPeer Peer DstPeer Peer StartTime int64 OpenDuration int64 Sent int64 SentDuration int64 Received int64 RecvDuration int64 CloseTime int64 PassMode byte Connected bool AutoTry bool Multiple bool Error error Closed bool SendDone bool RecvDone bool WriteSrcErr error ReadSrcErr error WriteDstErr error ReadDstErr error TunnelEventNotifier // contains filtered or unexported fields }
func (*Tunnel) CloseWithError ¶
type TunnelData ¶
type TunnelData map[string]interface{}
func LocalStatTunnel ¶
func LocalStatTunnel() []*TunnelData
func NewTunnelData ¶
func NewTunnelData(t *Tunnel) *TunnelData
type TunnelEvent ¶
type TunnelEvent struct { Type byte Id string Bytes int64 Duration int64 Error string Timestamp int64 }
func NewTunnelEvent ¶
func NewTunnelEvent(t *Tunnel) *TunnelEvent
type TunnelEventNotifier ¶
type TunnelEventNotifier interface { OnTunnelOpen(t *Tunnel) OnTunnelClose(t *Tunnel) OnTunnelSent(t *Tunnel) OnTunnelReceived(t *Tunnel) SubTunnelEvent(s event.Stream) string CancelTunnelEvent(id string) }
event type: open|close|send|receive
type WriteTimeOutError ¶ added in v0.9.3
type WriteTimeOutError error
Click to show internal directories.
Click to hide internal directories.