socks2rtc

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_MSG_SIZE = 65535
)
View Source
const (
	SERVER_COMM_TIMEOUT = 30 * time.Second // more than 30s no read/write, close the connection
)

Variables

View Source
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) Close

func (c *Conn) Close() error

Close implements the net.Conn Close method.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr implements the net.Conn LocalAddr method.

func (*Conn) Read

func (c *Conn) Read(p []byte) (int, error)

Read implements the net.Conn Read method.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr implements the net.Conn RemoteAddr method.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(deadline time.Time) error

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

func (c *Conn) SetReadDeadline(deadline time.Time) error

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

func (c *Conn) SetWriteDeadline(deadline time.Time) error

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.

func (*Conn) Write

func (c *Conn) Write(p []byte) (int, error)

Write implements the net.Conn Write method.

type Request

type Request struct {
	Command     byte
	NetworkType string
	Address     string
}

func ReadRequest

func ReadRequest(r io.Reader) (*Request, error)

func (*Request) WriteTo

func (r *Request) WriteTo(w io.Writer) (int64, error)

type Response

type Response = Request

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
}

func (*Server) Start

func (s *Server) Start() error

Start starts the server.

func (*Server) Stop

func (s *Server) Stop() error

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) Bind

func (*Socks5Proxy) Bind(_ net.Addr) (chanConn chan net.Conn, chanAddr chan net.Addr, err error)

func (*Socks5Proxy) Connect

func (p *Socks5Proxy) Connect(dst net.Addr) (conn net.Conn, addr net.Addr, err error)

func (*Socks5Proxy) UDPAssociate

func (*Socks5Proxy) UDPAssociate() (ua socks5.UDPAssociation, err error)

type WebAnswer

type WebAnswer struct {
	Expiry   time.Time `json:"expiry"`
	OwnerUID uint64    `json:"owner_uid"`
	Answer   string    `json:"answer"`
}

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)

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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