Versions in this module Expand all Collapse all v1 v1.0.2 Dec 4, 2024 Changes in this version + var GlobalKey = "" + func NewNegotiateKeyRequest(r io.Reader) (string, error) type Client + Key string v1.0.1 Dec 4, 2024 Changes in this version + const ATYPDomain + const ATYPIPv4 + const ATYPIPv6 + const CmdBind + const CmdConnect + const CmdUDP + const MethodGSSAPI + const MethodNone + const MethodUnsupportAll + const MethodUsernamePassword + const RepAddressNotSupported + const RepCommandNotSupported + const RepConnectionRefused + const RepHostUnreachable + const RepNetworkUnreachable + const RepNotAllowed + const RepServerFailure + const RepSuccess + const RepTTLExpired + const UserPassStatusFailure + const UserPassStatusSuccess + const UserPassVer + const Ver + var BuffSize = 32 << 10 + var ErrBadReply = errors.New("bad Reply") + var ErrBadRequest = errors.New("bad Request") + var ErrEmptyAddr = errors.New("invalid Addr") + var ErrHandler = errors.New("data handler is not set") + var ErrTCPConnClose = errors.New("TCP connection is closed") + var ErrUnsupportCmd = errors.New("unsupport Command") + var ErrUserPassAuth = errors.New("invalid Username or Password for Auth") + var ErrUserPassVersion = errors.New("invalid Version of Username Password Auth") + var ErrVersion = errors.New("invalid Version") + func ParseAddress(address string) (a byte, addr []byte, port []byte, err error) + func ParseBytesAddress(b []byte) (a byte, addr []byte, port []byte, err error) + type Client struct + DialTCP func(network string, laddr, raddr *net.TCPAddr) (net.Conn, error) + Password string + Server string + Username string + func (c *Client) Dial(network, addr string) (net.Conn, error) + func (c Client) DialWithLocalAddr(network, src, dst string) (net.Conn, error) + type Cmd []byte + type DatagramUDP struct + Atyp byte + Data []byte + DstAddr []byte + DstPort []byte + Frag byte + Rsv []byte + func NewRequestUDP(atyp byte, dstaddr []byte, dstport []byte, data []byte) *DatagramUDP + func ReadRequestUDP(bb []byte) (*DatagramUDP, error) + func (d *DatagramUDP) Address() string + func (d *DatagramUDP) Bytes() []byte + type DefaultHandle struct + BuffSize int + func (T *DefaultHandle) TCP(cconn net.Conn, r *RequestTCP) error + func (T *DefaultHandle) UDP(proxyUDP *net.UDPConn, cAddr *net.UDPAddr, d *DatagramUDP) error + type Dialer struct + Dial func(network, address string) (net.Conn, error) + DialContext func(ctx context.Context, network, address string) (net.Conn, error) + type Handler interface + TCP func(net.Conn, *RequestTCP) error + UDP func(*net.UDPConn, *net.UDPAddr, *DatagramUDP) error + type Negotiate struct + func (T *Negotiate) Auth(username, password string) error + type NegotiationReply struct + Method byte + Ver byte + func NewNegotiateMethodReply(method byte) *NegotiationReply + func ReadNegotiateMethodReply(r io.Reader) (*NegotiationReply, error) + func (r *NegotiationReply) WriteTo(w io.Writer) (int64, error) + type NegotiationReplyAuth struct + Status byte + Ver byte + func NewNegotiateAuthReply(status byte) *NegotiationReplyAuth + func ReadNegotiateAuthReply(r io.Reader) (*NegotiationReplyAuth, error) + func (r *NegotiationReplyAuth) WriteTo(w io.Writer) (int64, error) + type NegotiationRequest struct + Methods []byte + NMethods byte + Ver byte + func NewNegotiateMethodRequest(methods []byte) *NegotiationRequest + func ReadNegotiateMethodRequest(r io.Reader) (*NegotiationRequest, error) + func (r *NegotiationRequest) WriteTo(w io.Writer) (int64, error) + type NegotiationRequestAuth struct + Passwd []byte + Plen byte + Ulen byte + Uname []byte + Ver byte + func NewNegotiateAuthRequest(username []byte, password []byte) *NegotiationRequestAuth + func ReadNegotiateAuthRequest(r io.Reader) (*NegotiationRequestAuth, error) + func (r *NegotiationRequestAuth) WriteTo(w io.Writer) (int64, error) + type ReplyTCP struct + Atyp byte + BndAddr []byte + BndPort []byte + Rep byte + Rsv byte + Ver byte + func NewReplyTCP(rep byte, atyp byte, bndaddr []byte, bndport []byte) *ReplyTCP + func ReadReplyTCP(r io.Reader) (*ReplyTCP, error) + func (r *ReplyTCP) Address() string + func (r *ReplyTCP) WriteTo(w io.Writer) (int64, error) + type RequestTCP struct + Atyp byte + Cmd byte + DstAddr []byte + DstPort []byte + Rsv byte + Ver byte + func NewRequestTCP(cmd byte, atyp byte, dstaddr []byte, dstport []byte) *RequestTCP + func ReadRequestTCP(r io.Reader) (*RequestTCP, error) + func (r *RequestTCP) Address() string + func (r *RequestTCP) RemoteConnect(dial *Dialer, w io.Writer) (rc net.Conn, err error) + func (r *RequestTCP) ReplyError(rep byte, w io.Writer) error + func (r *RequestTCP) UDP(cconn net.Conn, proxyAddr *net.UDPAddr) (caddr *net.UDPAddr, err error) + func (r *RequestTCP) WriteTo(w io.Writer) (int64, error) + type Server struct + Addr string + Auth func(username, password string) bool + ErrorLog *log.Logger + Handle Handler + Method byte + Supported Cmd + func (T *Server) Close() error + func (T *Server) ListenAndServe() error + func (T *Server) ServerTCP() error + func (T *Server) ServerUDP() error