tun2Pipe

package
v0.0.0-...-b9f8a21 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SysDialTimeOut    = time.Second * 2
	UDPSessionTimeOut = time.Second * 80
	MTU               = math.MaxInt16
	InnerPivotPort    = 51414 //TODO:: this port should be refactored
)
View Source
const TLSHeaderLength = 5

Variables

This section is empty.

Functions

func ChangePacket

func ChangePacket(ip4 *layers.IPv4, tcp *layers.TCP) []byte

func GetExtensionBlock

func GetExtensionBlock(data []byte) ([]byte, error)

func GetSNBlock

func GetSNBlock(data []byte) ([]byte, error)

func GetSNIBlock

func GetSNIBlock(data []byte) ([]byte, error)

func ParseHost

func ParseHost(data []byte) string

func PrintFlow

func PrintFlow(pre string, ip4 *layers.IPv4, tcp *layers.TCP)

func ProtectConn

func ProtectConn(conn syscall.Conn) error

func WrapIPPacketForUdp

func WrapIPPacketForUdp(srcIp, DstIp net.IP, srcPort, dstPort int, payload []byte) []byte

Types

type ByPassIPs

type ByPassIPs struct {
	Masks map[string]net.IPMask
	IP    map[string]struct{}
	sync.RWMutex
	// contains filtered or unexported fields
}

func ByPassInst

func ByPassInst() *ByPassIPs

func (*ByPassIPs) Hit

func (bp *ByPassIPs) Hit(ip net.IP) bool

func (*ByPassIPs) IsGlobal

func (bp *ByPassIPs) IsGlobal() bool

func (*ByPassIPs) Load

func (bp *ByPassIPs) Load(IPS string)

func (*ByPassIPs) SetGlobal

func (bp *ByPassIPs) SetGlobal(g bool)

type ConnProtect

type ConnProtect func(fd uintptr)
var Protector ConnProtect

type DnsProxy

type DnsProxy struct {
	sync.RWMutex

	VpnWriteBack io.WriteCloser
	// contains filtered or unexported fields
}

func NewDnsCache

func NewDnsCache() (*DnsProxy, error)

func (*DnsProxy) DnsWaitResponse

func (c *DnsProxy) DnsWaitResponse()

func (*DnsProxy) Get

func (c *DnsProxy) Get(id uint16) *QueryState

func (*DnsProxy) Pop

func (c *DnsProxy) Pop(id uint16) *QueryState

func (*DnsProxy) Put

func (c *DnsProxy) Put(qs *QueryState)

type QueryState

type QueryState struct {
	QueryTime     time.Time
	ClientQueryID uint16
	ClientIP      net.IP
	ClientPort    layers.UDPPort
	RemoteIp      net.IP
	RemotePort    layers.UDPPort
}

type Session

type Session struct {
	Pipe       *directPipe
	UPTime     time.Time
	RemoteIP   net.IP
	RemotePort int
	ServerPort int

	HostName string
	// contains filtered or unexported fields
}

func (*Session) ToString

func (s *Session) ToString() string

type Tun2Pipe

type Tun2Pipe struct {
	sync.RWMutex

	SessionCache map[int]*Session
	// contains filtered or unexported fields
}

func New

func New(proxyAddr string, p func(fd uintptr)) (*Tun2Pipe, error)

func (*Tun2Pipe) Finish

func (t2s *Tun2Pipe) Finish()

func (*Tun2Pipe) GetTarget

func (t2s *Tun2Pipe) GetTarget(conn net.Conn) (string, error)

func (*Tun2Pipe) InputPacket

func (t2s *Tun2Pipe) InputPacket(buf []byte)

func (*Tun2Pipe) ProcessTcpPacket

func (t2s *Tun2Pipe) ProcessTcpPacket(ip4 *layers.IPv4, tcp *layers.TCP)

func (*Tun2Pipe) ProxyClose

func (t2s *Tun2Pipe) ProxyClose(conn net.Conn)

func (*Tun2Pipe) Proxying

func (t2s *Tun2Pipe) Proxying(done chan struct{})

TODO::

type UdpProxy

type UdpProxy struct {
	sync.RWMutex
	Done       chan error
	NatSession map[int]*UdpSession
}

func NewUdpProxy

func NewUdpProxy() *UdpProxy

func (*UdpProxy) ExpireOldSession

func (up *UdpProxy) ExpireOldSession()

func (*UdpProxy) ReceivePacket

func (up *UdpProxy) ReceivePacket(ip4 *layers.IPv4, udp *layers.UDP)

type UdpSession

type UdpSession struct {
	sync.RWMutex
	*net.UDPConn
	UTime   time.Time
	SrcIP   net.IP
	SrcPort int
	ID      string
}

TODO::to make sure this is usable

func (*UdpSession) IsExpire

func (s *UdpSession) IsExpire() bool

func (*UdpSession) ProxyOut

func (s *UdpSession) ProxyOut(data []byte) (int, error)

func (*UdpSession) UpdateTime

func (s *UdpSession) UpdateTime()

func (*UdpSession) WaitingIn

func (s *UdpSession) WaitingIn()

type VpnDelegate

type VpnDelegate interface {
	io.Writer
}
var VpnInstance VpnDelegate = nil

Jump to

Keyboard shortcuts

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