netrelay

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ATYPIPv4 is ipv4 address type
	ATYPIPv4 byte = 0x01 // 4 octets
	// ATYPDomain is domain address type
	ATYPDomain byte = 0x03 // The first octet of the address field contains the number of octets of name that follow, there is no terminating NUL octet.
	// ATYPIPv6 is ipv6 address type
	ATYPIPv6 byte = 0x04 // 16 octets
)

Variables

View Source
var (
	ErrVersion    = errors.New("invalid Version")
	ErrBadRequest = errors.New("bad Request")
)

Functions

func ParseAddress added in v1.4.1

func ParseAddress(address string) (a byte, addr []byte, port []byte, err error)

ParseAddress format address x.x.x.x:xx to raw address. addr contains domain length

Types

type Datagram added in v1.4.1

type Datagram struct {
	Rsv     []byte // 0x00 0x00
	Frag    byte
	Atyp    byte
	DstAddr []byte
	DstPort []byte // 2 bytes
	Data    []byte
}

Datagram is the UDP packet

func NewDatagram added in v1.4.1

func NewDatagram(atyp byte, dstaddr []byte, dstport []byte, data []byte) *Datagram

func (*Datagram) Address added in v1.4.1

func (d *Datagram) Address() string

Address return datagram address like ip:xx

func (*Datagram) Bytes added in v1.4.1

func (d *Datagram) Bytes() []byte

Bytes return []byte

type NetRelay

type NetRelay interface {
	RelayHttpDo(w http.ResponseWriter, r *http.Request, address boson.Address)
}

type Reply added in v1.4.1

type Reply struct {
	Ver  byte
	Rep  byte
	Rsv  byte // 0x00
	Atyp byte
	// CONNECT socks server's address which used to connect to dst addr
	// BIND ...
	// UDP socks server's address which used to connect to dst addr
	BndAddr []byte
	// CONNECT socks server's port which used to connect to dst addr
	// BIND ...
	// UDP socks server's port which used to connect to dst addr
	BndPort []byte // 2 bytes
}

Reply is the reply packet

func NewReply added in v1.4.1

func NewReply(rep byte, atyp byte, bndaddr []byte, bndport []byte) *Reply

NewReply return reply packet can be written into client, bndaddr should not have domain length

func (*Reply) WriteTo added in v1.4.1

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

WriteTo write reply packet into client

type Request added in v1.4.1

type Request struct {
	Rsv     byte // 0x00
	Atyp    byte
	DstAddr []byte
	DstPort []byte // 2 bytes
}

Request is the request packet

func NewRequestFrom added in v1.4.1

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

func (*Request) Address added in v1.4.1

func (r *Request) Address() string

Address return request address like ip:xx

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(streamer p2p.Streamer, logging logging.Logger, groups []model.ConfigNodeGroup, route routetab.RouteTab, multicast multicast.GroupInterface) *Service

func (*Service) CreateTun added in v1.4.1

func (s *Service) CreateTun(config VpnConfig) (iface *water.Interface)

CreateTun creates a tun interface

func (*Service) NewVpnService added in v1.4.1

func (s *Service) NewVpnService(group string) http.Handler

func (*Service) Protocol

func (s *Service) Protocol() p2p.ProtocolSpec

func (*Service) RelayHttpDo

func (s *Service) RelayHttpDo(w http.ResponseWriter, r *http.Request, addr boson.Address)

func (*Service) SetProxyGroup added in v1.4.1

func (s *Service) SetProxyGroup(group string) error

func (*Service) SetVpnGroup added in v1.4.1

func (s *Service) SetVpnGroup(group string) error

func (*Service) StartProxy added in v1.4.1

func (s *Service) StartProxy(addr, natAddr, group string)

type UDPExchange added in v1.4.1

type UDPExchange struct {
	ClientAddr *net.UDPAddr
	RemoteConn *net.UDPConn
}

UDPExchange used to store client address and remote connection

type VpnConfig added in v1.4.1

type VpnConfig struct {
	ServerIP   string
	ServerIPv6 string
	CIDR       string
	CIDRv6     string
	MTU        int
	Group      string
	Listen     string
}

type VpnService added in v1.4.1

type VpnService struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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