libsocks

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 6 Imported by: 2

README

libsocks

a socks library

Documentation

Index

Constants

View Source
const Version = 5

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Type AddressType
	IP   net.IP
	Host string
	Port uint16
}

func UnmarshalAddress

func UnmarshalAddress(b []byte) (Address, error)

func UnmarshalAddressFrom

func UnmarshalAddressFrom(r io.Reader) (Address, error)

func (Address) Bytes

func (address Address) Bytes() []byte

func (Address) String

func (address Address) String() string

type AddressType

type AddressType = uint8
const (
	TypeIPv4   AddressType = 1
	TypeIPv6   AddressType = 4
	TypeDomain AddressType = 3
)

type Authentication

type Authentication interface {
	AuthFunc(conn net.Conn) (bool, error)
	Code() uint8
}

type NoAuth

type NoAuth struct{}

func (NoAuth) AuthFunc

func (na NoAuth) AuthFunc(conn net.Conn) (bool, error)

func (NoAuth) Code

func (na NoAuth) Code() uint8

type ResponseType

type ResponseType = uint8
const (
	Success ResponseType = iota
	ServerFailed
	ConnNotAllowed
	NetworkUnreachable
	ConnRefused
	TTLExpired
	CmdNotSupport
	AddrTypeNotSupport
)

type SocksServer

type SocksServer struct {
	net.Conn
	Auth Authentication

	Target Address
}

func NewSocks

func NewSocks(conn net.Conn, auth Authentication) (*SocksServer, error)

NewSocks NewSocks will auth socks client and read socks request, if error, conn will be closed

func (*SocksServer) Reply

func (server *SocksServer) Reply(ip net.IP, port uint16, field ResponseType) error

type VersionErr

type VersionErr struct {
	SourceAddr   net.Addr
	SocksVersion uint8
}

func (VersionErr) Error

func (e VersionErr) Error() string

Jump to

Keyboard shortcuts

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