Documentation ¶
Index ¶
- Constants
- Variables
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(p []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(deadline time.Time) error
- func (c *Conn) SetReadDeadline(deadline time.Time) error
- func (c *Conn) SetWriteDeadline(deadline time.Time) error
- func (c *Conn) Write(p []byte) (int, error)
- type Request
- type Response
- type Server
- type Socks5Proxy
- type WebAnswer
- type WebSignalClient
- type WebSignalServer
- func (wss *WebSignalServer) AddPassword(uid uint64, password []byte)
- func (wss *WebSignalServer) Answer(offerID uint64, answer []byte) error
- func (*WebSignalServer) GetAnswer(_ uint64) (answer []byte, err error)
- func (wss *WebSignalServer) GetOffer() (offerID uint64, offerBody []byte, err error)
- func (wss *WebSignalServer) Listen(addr string)
- func (*WebSignalServer) MakeOffer(_ []byte) (offerID uint64, err error)
- func (wss *WebSignalServer) RemovePassword(uid uint64)
Constants ¶
const ( CONNECT = socks5.REQUEST_CMD_CONNECT BIND = socks5.REQUEST_CMD_BIND UDP = socks5.REQUEST_CMD_UDP_ASSOCIATE TCP = socks5.REQUEST_ATYP_DOMAINNAME TCP4 = socks5.REQUEST_ATYP_IPV4 TCP6 = socks5.REQUEST_ATYP_IPV6 )
const (
MAX_MSG_SIZE = 65535
)
const (
SERVER_COMM_TIMEOUT = 30 * time.Second // more than 30s no read/write, close the connection
)
Variables ¶
var ReadResponse func(io.Reader) (*Response, error) = ReadRequest
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn implements a net.Conn interface Currently it is a wrapper around transportc.Conn.
Keep for future.
func (*Conn) RemoteAddr ¶
RemoteAddr implements the net.Conn RemoteAddr method.
func (*Conn) SetDeadline ¶
SetDeadline implements the net.Conn SetDeadline method. It sets both read and write deadlines in a single call.
See SetReadDeadline and SetWriteDeadline for the behavior of the deadlines.
func (*Conn) SetReadDeadline ¶
SetReadDeadline implements the net.Conn SetReadDeadline method. It sets the read deadline for the connection.
If the deadline is reached, Read will return an error. If the deadline is zero, Read will not time out.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline implements the net.Conn SetWriteDeadline method. It sets the write deadline for the connection.
If the deadline is reached, Write will return an error. If the deadline is zero, Write will not time out.
type Server ¶
type Server struct { // Config specifies the configuration for the underlying transportc.Listener. // If set to nil, use a default configuration. Config *transportc.Config // ListenAddr specifies the IP address to listen on. ListenAddr string // contains filtered or unexported fields }
type Socks5Proxy ¶
type Socks5Proxy struct { // Config specifies the configuration for the underlying transportc.Dialer. // If set to nil, use a default configuration. Config *transportc.Config // Timeout specifies a time limit for dialing to the remote peer. // If zero, no timeout is set. Timeout time.Duration // contains filtered or unexported fields }
func (*Socks5Proxy) UDPAssociate ¶
func (*Socks5Proxy) UDPAssociate() (ua socks5.UDPAssociation, err error)
type WebSignalClient ¶
type WebSignalClient struct { // BaseURL is the base URL of the server, where offer will be sent and // answer will be received from. // // Not including the trailing slash or the protocol prefix (https://). BaseURL string // e.g. example.com:8443 // UserID is the ID of the user. UserID uint64 // Password is the password of the user used for HMAC authentication. Password []byte }
func (*WebSignalClient) Answer ¶
func (*WebSignalClient) Answer(_ uint64, _ []byte) error
Answer isn't implemented by WebSignalClient.
func (*WebSignalClient) GetAnswer ¶
func (wsc *WebSignalClient) GetAnswer(offerID uint64) (answer []byte, err error)
GetAnswer gets the answer from the server.
GET https://example.com:8443/answer?offer_id=<hex offer ID>&uid=<hex user ID>
The response will be:
{ status: "success", answer: <base64 encoded answer> }
func (*WebSignalClient) GetOffer ¶
func (*WebSignalClient) GetOffer() (offerID uint64, offerBody []byte, err error)
GetOffer isn't implemented by WebSignalClient.
func (*WebSignalClient) MakeOffer ¶
func (wsc *WebSignalClient) MakeOffer(offer []byte) (offerID uint64, err error)
MakeOffer makes an offer and returns the offer ID.
POST https://example.com:8443/offer { offer: <base64 encoded offer>, sig: <base64 encoded signature of offer raw bytes>, pub_key: <base64 encoded public key> }
The response will be:
{ status: "success", offer_id: <hex offer ID> }
type WebSignalServer ¶
type WebSignalServer struct {
// contains filtered or unexported fields
}
func NewWebSignalServer ¶
func NewWebSignalServer(passwords map[uint64][]byte, antiProbeHandler gin.HandlerFunc) (*WebSignalServer, error)
NewWebSignalServer creates a new WebSignalServer. passwords is a map of user ID to password. antiProbe
func (*WebSignalServer) AddPassword ¶
func (wss *WebSignalServer) AddPassword(uid uint64, password []byte)
func (*WebSignalServer) Answer ¶
func (wss *WebSignalServer) Answer(offerID uint64, answer []byte) error
func (*WebSignalServer) GetAnswer ¶
func (*WebSignalServer) GetAnswer(_ uint64) (answer []byte, err error)
func (*WebSignalServer) GetOffer ¶
func (wss *WebSignalServer) GetOffer() (offerID uint64, offerBody []byte, err error)
func (*WebSignalServer) Listen ¶
func (wss *WebSignalServer) Listen(addr string)
func (*WebSignalServer) MakeOffer ¶
func (*WebSignalServer) MakeOffer(_ []byte) (offerID uint64, err error)
func (*WebSignalServer) RemovePassword ¶
func (wss *WebSignalServer) RemovePassword(uid uint64)