sockstrans

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserPassword = 0x02
	None         = 0x00
)
View Source
const (
	VerifySuccess = 0x00
	VerifyFailure = 0x01
)

Variables

This section is empty.

Functions

func Dial

func Dial(network, targetAddress, proxyAddress string, auth *proxy.Auth, forward proxy.Dialer) (net.Conn, error)

func ParseDestConnFrom

func ParseDestConnFrom(src net.Conn, auth *proxy.Auth) (net.Conn, error)

func Transfer

func Transfer(src net.Conn, closed bool, auth *proxy.Auth, recovered bool) (chan iokit.Direction, error)

func TransferFromListen

func TransferFromListen(lAddr *net.TCPAddr, auth *proxy.Auth, keepListening bool, output *SocksTransferContext) error

func TransferFromListenAddress

func TransferFromListenAddress(lAddress string, auth *proxy.Auth, keepListening bool, output *SocksTransferContext) error

Types

type Credential

type Credential struct {
	Username string
	Password string
}

type SocksAuthenticationPacket

type SocksAuthenticationPacket struct {
	Packet    []byte
	Version   byte
	NUserName byte
	UserName  []byte
	NPassword byte
	Password  []byte
}

type SocksBasicPacket

type SocksBasicPacket struct {
	Raw      []byte
	Version  byte
	NMethods byte
	Methods  []byte
}

*

   The localConn connects to the dstServer, and sends a ver
   identifier/method selection message:
	          +----+----------+----------+
	          |VER | NMETHODS | METHODS  |
	          +----+----------+----------+
	          | 1  |    1     | 1 to 255 |
	          +----+----------+----------+
   The VER field is set to X'05' for this ver of the protocol.  The
   NMETHODS field contains the number of method identifier octets that
   appear in the METHODS field.

第一个字段VER代表Socks的版本,Socks5默认为0x05,其固定长度为1个字节

type SocksConfig

type SocksConfig struct {
	Authentication *proxy.Auth
}

type SocksDetailPacket

type SocksDetailPacket struct {
	Packet   []byte
	Version  byte
	CMD      byte
	RSV      byte
	ATYP     byte
	DST_ADDR []byte
	DST_PORT []byte
}

*

+----+-----+-------+------+----------+----------+
|VER | CMD |  RSV  | ATYP | DST.ADDR | DST.PORT |
+----+-----+-------+------+----------+----------+
| 1  |  1  | X'00' |  1   | Variable |    2     |
+----+-----+-------+------+----------+----------+

func (SocksDetailPacket) GetAddr

func (p SocksDetailPacket) GetAddr() (string, error)

func (SocksDetailPacket) GetAddress

func (p SocksDetailPacket) GetAddress() (string, error)

func (SocksDetailPacket) GetPort

func (p SocksDetailPacket) GetPort() int

type SocksServer

type SocksServer struct {
	Conn net.Conn
	Auth *proxy.Auth
}

func (SocksServer) ParseIntoPacket

func (s SocksServer) ParseIntoPacket() (*SocksDetailPacket, error)

type SocksTransferContext

type SocksTransferContext struct {
	LAddr         *net.TCPAddr
	DAddr         *net.TCPAddr
	KeepListening bool
	LListener     *net.TCPListener
	DListener     *net.TCPListener
	StopChan      *chan os.Signal
}

func BuildTransfer

func BuildTransfer(lAddress string, keepListening bool) (*SocksTransferContext, error)

func (SocksTransferContext) GetDListener

func (t SocksTransferContext) GetDListener() *net.TCPListener

func (SocksTransferContext) GetLListener

func (t SocksTransferContext) GetLListener() *net.TCPListener

func (SocksTransferContext) Stop

func (t SocksTransferContext) Stop()

func (SocksTransferContext) TransferFromListen

func (t SocksTransferContext) TransferFromListen(auth *proxy.Auth) error

Jump to

Keyboard shortcuts

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