Documentation
¶
Index ¶
Constants ¶
View Source
const ( ProtoTCP = 6 ProtoUDP = 17 )
View Source
const ( TCPFlagFIN = 0x01 TCPFlagSYN = 0x02 TCPFlagRST = 0x04 TCPFlagACK = 0x10 )
View Source
const ( // TUN device MTU — matches common VPN MTU to avoid fragmentation. DefaultMTU = 1500 // TUN subnet used for the virtual interface. TunAddr = "10.0.85.1" TunGateway = "10.0.85.0" TunMask = "255.255.255.0" TunCIDR = "10.0.85.1/24" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Device ¶
type Device struct {
Iface *water.Interface
Name string
ServerIP string
OriginalGW string
OriginalIF string
}
Device wraps a TUN interface with its configuration.
func NewDevice ¶
NewDevice creates and configures a TUN interface. serverIP is the SOCKS5 server's LAN IP — we add a static route for it so the proxy control traffic bypasses the TUN.
func (*Device) Setup ¶
Setup configures the TUN interface IP, brings it up, and reroutes the default gateway through the tunnel. It preserves the original gateway so it can be restored on teardown.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine reads IP packets from a TUN device, identifies TCP/UDP flows, and forwards them through the binary tunnel protocol.
type IPv4Header ¶
type IPv4Header struct {
Version int
IHL int // header length in bytes
TotalLen int
Protocol int // 6=TCP, 17=UDP
SrcIP net.IP
DstIP net.IP
Raw []byte
PayloadOff int // offset where transport header begins
}
IPv4Header represents a parsed IPv4 header.
func ParseIPv4 ¶
func ParseIPv4(pkt []byte) (*IPv4Header, error)
ParseIPv4 parses an IPv4 header from a raw packet.
Click to show internal directories.
Click to hide internal directories.