Documentation
¶
Index ¶
- Constants
- func NewPCAPAdaptor(ifaceName string, promisc bool) (*pcapAdaptor, error)
- type Config
- type NIC
- type NetStackVirtualMachine
- func (vm *NetStackVirtualMachine) AllowTCP(destinationAddr string)
- func (vm *NetStackVirtualMachine) AllowTCPWithSrc(destinationAddr string, srcAddr string)
- func (vm *NetStackVirtualMachine) DialTCP(timeout time.Duration, hostport string) (net.Conn, error)
- func (vm *NetStackVirtualMachine) DisallowTCP(destinationAddr string)
- func (vm *NetStackVirtualMachine) DisallowTCPWithSrc(destinationAddr string, srcAddr string)
- func (vm *NetStackVirtualMachine) GetMTU() int
- func (vm *NetStackVirtualMachine) GetMainNICIPv4Address() net.IP
- func (vm *NetStackVirtualMachine) GetMainNICIPv4Gateway() net.IP
- func (vm *NetStackVirtualMachine) GetMainNICIPv4Netmask() *net.IPNet
- func (vm *NetStackVirtualMachine) GetMainNICLinkAddress() net.HardwareAddr
- func (vm *NetStackVirtualMachine) GetOSNetStackIPv4() (net.IP, net.IP, net.IPMask)
- func (vm *NetStackVirtualMachine) GetOSNetStackIPv6() (net.IP, net.IP, net.IPMask)
- func (vm *NetStackVirtualMachine) GetStack() *stack.Stack
- func (vm *NetStackVirtualMachine) GetSystemInterface() *net.Interface
- func (vm *NetStackVirtualMachine) InheritPcapInterfaceIP() error
- func (vm *NetStackVirtualMachine) MainNICID() tcpip.NICID
- func (vm *NetStackVirtualMachine) SetDefaultRoute(gateway net.IP) error
- func (vm *NetStackVirtualMachine) SetFilterForSynScan()
- func (vm *NetStackVirtualMachine) SetMainNICv4(ipAddr net.IP, netmask *net.IPNet, getaway net.IP) error
- func (m *NetStackVirtualMachine) StartAnnounceARP() error
- func (vm *NetStackVirtualMachine) StartDHCP() error
- func (vm *NetStackVirtualMachine) Wait()
- func (t *NetStackVirtualMachine) WaitDHCPFinished(ctx context.Context) error
- type Option
- func WithARPDisabled(disabled bool) Option
- func WithContext(ctx context.Context) Option
- func WithDHCPDisabled(disabled bool) Option
- func WithDisableForwarding(v bool) Option
- func WithDisallowPacketEndpointWrite(disallow bool) Option
- func WithEnableLinkLayer(enable bool) Option
- func WithHandleLocal(handleLocal bool) Option
- func WithICMPDisabled(disabled bool) Option
- func WithIPv4Disabled(disabled bool) Option
- func WithIPv6Disabled(disabled bool) Option
- func WithMainNICIPAddress(ipAddress string) Option
- func WithMainNICLinkAddress(linkAddress string) Option
- func WithOnTCPConnectionRequested(fn func(*tcpip.FullAddress, *tcpip.FullAddress)) Option
- func WithPCAPInboundFilter(filter func(packet gopacket.Packet) bool) Option
- func WithPCAPOutboundFilter(filter func(packet gopacket.Packet) bool) Option
- func WithPcapDevice(device string) Option
- func WithPcapPromisc(promisc bool) Option
- func WithRandomMainNICLinkAddress() Option
- func WithTCPDisabled(disabled bool) Option
- func WithUDPDisabled(disabled bool) Option
- type PCAPEndpoint
- func (p *PCAPEndpoint) AllowTCP(addr string)
- func (p *PCAPEndpoint) AllowTCPWithSrc(addr string, src string)
- func (p *PCAPEndpoint) Attach(dispatcher stack.NetworkDispatcher)
- func (p *PCAPEndpoint) Capabilities() stack.LinkEndpointCapabilities
- func (p *PCAPEndpoint) Close()
- func (p *PCAPEndpoint) DisallowTCP(addr string)
- func (p *PCAPEndpoint) DisallowTCPWithSrc(addr string, src string)
- func (p *PCAPEndpoint) SetGatewayHardwareAddr(hwAddr net.HardwareAddr)
- func (p *PCAPEndpoint) SetGatewayIP(g net.IP)
- func (p *PCAPEndpoint) SetPCAPInboundFilter(filter func(packet gopacket.Packet) bool)
- func (p *PCAPEndpoint) SetPCAPOutboundFilter(filter func(packet gopacket.Packet) bool)
- func (p *PCAPEndpoint) Wait()
- type TunVirtualMachine
- func (t *TunVirtualMachine) Close() error
- func (t *TunVirtualMachine) GetTunnelName() string
- func (vm *TunVirtualMachine) HijackDomain(domain string) error
- func (vm *TunVirtualMachine) HijackIP(ip string) error
- func (vm *TunVirtualMachine) HijackIPNet(ipNet *net.IPNet) error
- func (t *TunVirtualMachine) SetHijackTCPHandler(handle func(conn netstack.TCPConn)) error
Constants ¶
View Source
const TUN_MTU = 1420
TUN_MTU is the default MTU for TUN device. 1420 is wg default MTU, use it for compatibility.
View Source
const UTUNINDEXSTART = 410
Variables ¶
This section is empty.
Functions ¶
func NewPCAPAdaptor ¶
NewPCAPAdaptor creates a new pcap adaptor for the given interface. It reuses existing adaptors if one already exists for the interface.
Types ¶
type Config ¶
type Config struct { // stack options IPv4Disabled bool IPv6Disabled bool DHCPDisabled bool ARPDisabled bool ICMPDisabled bool HandleLocal bool TCPDisabled bool UDPDisabled bool DisallowPacketEndpointWrite bool EnableLinkLayer bool OnTCPConnectionRequested func(*tcpip.FullAddress, *tcpip.FullAddress) DisableForwarding bool //dhcp config DHCPAcquireTimeout time.Duration DHCPAcquireInterval time.Duration DHCPAcquireRetryInterval time.Duration DHCPAcquireCallback func(ctx context.Context, lost, acquired tcpip.AddressWithPrefix, cfg gvisorDHCP.Config) //arp config ARPAnnouncementFastInterval time.Duration ARPAnnouncementFastTimes int ARPAnnouncementSlowInterval time.Duration // nic options MainNICIPv4Address string MainNICIPv4AddressNetmask string MainNICIPv6Address string MainNICIPv6AddressNetmask string MainNICLinkAddress net.HardwareAddr // tcp options // DefaultTTL specifies the default TTL used by stack DefaultTTL uint8 // ICMPBurst is the number of ICMP messages that can be sent in a single burst ICMPBurst int // ICMPLimit is the maximum number of ICMP messages permitted by rate limiter ICMPLimit rate.Limit // TCPSendBufferSizeMin is the smallest size of a send buffer TCPSendBufferSizeMin int // TCPSendBufferSizeMax is the maximum permitted size of a send buffer TCPSendBufferSizeMax int // TCPSendBufferSizeDefault is the default size of the send buffer TCPSendBufferSizeDefault int // TCPReceiveBufferSizeMin is the smallest size of a receive buffer TCPReceiveBufferSizeMin int // TCPReceiveBufferSizeMax is the maximum permitted size of a receive buffer TCPReceiveBufferSizeMax int // TCPReceiveBufferSizeDefault is the default size of the receive buffer TCPReceiveBufferSizeDefault int // TCPCongestionControl is the congestion control algorithm used by TCP (reno or cubic) TCPCongestionControl string // TCPDelayEnabled enables/disables Nagle's algorithm for TCP TCPDelayEnabled bool // TCPModerateReceiveBuffer enables/disables TCP receive buffer auto-tuning TCPModerateReceiveBuffer bool // TCPSACKEnabled enables/disables TCP selective acknowledgment TCPSACKEnabled bool // TCPRACKLossDetection specifies the TCP loss detection algorithm TCPRACKLossDetection tcpip.TCPRecovery // contains filtered or unexported fields }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type NetStackVirtualMachine ¶
type NetStackVirtualMachine struct {
// contains filtered or unexported fields
}
func NewNetStackVirtualMachine ¶
func NewNetStackVirtualMachine(opts ...Option) (*NetStackVirtualMachine, error)
func (*NetStackVirtualMachine) AllowTCP ¶
func (vm *NetStackVirtualMachine) AllowTCP(destinationAddr string)
func (*NetStackVirtualMachine) AllowTCPWithSrc ¶
func (vm *NetStackVirtualMachine) AllowTCPWithSrc(destinationAddr string, srcAddr string)
func (*NetStackVirtualMachine) DisallowTCP ¶
func (vm *NetStackVirtualMachine) DisallowTCP(destinationAddr string)
func (*NetStackVirtualMachine) DisallowTCPWithSrc ¶
func (vm *NetStackVirtualMachine) DisallowTCPWithSrc(destinationAddr string, srcAddr string)
func (*NetStackVirtualMachine) GetMTU ¶
func (vm *NetStackVirtualMachine) GetMTU() int
func (*NetStackVirtualMachine) GetMainNICIPv4Address ¶
func (vm *NetStackVirtualMachine) GetMainNICIPv4Address() net.IP
func (*NetStackVirtualMachine) GetMainNICIPv4Gateway ¶
func (vm *NetStackVirtualMachine) GetMainNICIPv4Gateway() net.IP
func (*NetStackVirtualMachine) GetMainNICIPv4Netmask ¶
func (vm *NetStackVirtualMachine) GetMainNICIPv4Netmask() *net.IPNet
func (*NetStackVirtualMachine) GetMainNICLinkAddress ¶
func (vm *NetStackVirtualMachine) GetMainNICLinkAddress() net.HardwareAddr
func (*NetStackVirtualMachine) GetOSNetStackIPv4 ¶
func (*NetStackVirtualMachine) GetOSNetStackIPv6 ¶
func (*NetStackVirtualMachine) GetStack ¶
func (vm *NetStackVirtualMachine) GetStack() *stack.Stack
func (*NetStackVirtualMachine) GetSystemInterface ¶
func (vm *NetStackVirtualMachine) GetSystemInterface() *net.Interface
func (*NetStackVirtualMachine) InheritPcapInterfaceIP ¶
func (vm *NetStackVirtualMachine) InheritPcapInterfaceIP() error
func (*NetStackVirtualMachine) MainNICID ¶
func (vm *NetStackVirtualMachine) MainNICID() tcpip.NICID
func (*NetStackVirtualMachine) SetDefaultRoute ¶
func (vm *NetStackVirtualMachine) SetDefaultRoute(gateway net.IP) error
func (*NetStackVirtualMachine) SetFilterForSynScan ¶
func (vm *NetStackVirtualMachine) SetFilterForSynScan()
func (*NetStackVirtualMachine) SetMainNICv4 ¶
func (*NetStackVirtualMachine) StartAnnounceARP ¶
func (m *NetStackVirtualMachine) StartAnnounceARP() error
func (*NetStackVirtualMachine) StartDHCP ¶
func (vm *NetStackVirtualMachine) StartDHCP() error
func (*NetStackVirtualMachine) Wait ¶
func (vm *NetStackVirtualMachine) Wait()
func (*NetStackVirtualMachine) WaitDHCPFinished ¶
func (t *NetStackVirtualMachine) WaitDHCPFinished(ctx context.Context) error
type Option ¶
func WithARPDisabled ¶
func WithContext ¶
func WithDHCPDisabled ¶
func WithDisableForwarding ¶
func WithEnableLinkLayer ¶
func WithHandleLocal ¶
func WithICMPDisabled ¶
func WithIPv4Disabled ¶
func WithIPv6Disabled ¶
func WithMainNICIPAddress ¶
func WithMainNICLinkAddress ¶
func WithOnTCPConnectionRequested ¶
func WithOnTCPConnectionRequested(fn func(*tcpip.FullAddress, *tcpip.FullAddress)) Option
func WithPCAPInboundFilter ¶
func WithPCAPOutboundFilter ¶
func WithPcapDevice ¶
func WithPcapPromisc ¶
func WithRandomMainNICLinkAddress ¶
func WithRandomMainNICLinkAddress() Option
func WithTCPDisabled ¶
func WithUDPDisabled ¶
type PCAPEndpoint ¶
func NewPCAPEndpoint ¶
func NewPCAPEndpoint(ctx context.Context, stackIns *stack.Stack, device string, macAddr net.HardwareAddr, promisc bool) (*PCAPEndpoint, error)
func (*PCAPEndpoint) AllowTCP ¶
func (p *PCAPEndpoint) AllowTCP(addr string)
func (*PCAPEndpoint) AllowTCPWithSrc ¶
func (p *PCAPEndpoint) AllowTCPWithSrc(addr string, src string)
func (*PCAPEndpoint) Attach ¶
func (p *PCAPEndpoint) Attach(dispatcher stack.NetworkDispatcher)
func (*PCAPEndpoint) Capabilities ¶
func (p *PCAPEndpoint) Capabilities() stack.LinkEndpointCapabilities
func (*PCAPEndpoint) Close ¶
func (p *PCAPEndpoint) Close()
func (*PCAPEndpoint) DisallowTCP ¶
func (p *PCAPEndpoint) DisallowTCP(addr string)
func (*PCAPEndpoint) DisallowTCPWithSrc ¶
func (p *PCAPEndpoint) DisallowTCPWithSrc(addr string, src string)
func (*PCAPEndpoint) SetGatewayHardwareAddr ¶
func (p *PCAPEndpoint) SetGatewayHardwareAddr(hwAddr net.HardwareAddr)
func (*PCAPEndpoint) SetGatewayIP ¶
func (p *PCAPEndpoint) SetGatewayIP(g net.IP)
func (*PCAPEndpoint) SetPCAPInboundFilter ¶
func (p *PCAPEndpoint) SetPCAPInboundFilter(filter func(packet gopacket.Packet) bool)
func (*PCAPEndpoint) SetPCAPOutboundFilter ¶
func (p *PCAPEndpoint) SetPCAPOutboundFilter(filter func(packet gopacket.Packet) bool)
func (*PCAPEndpoint) Wait ¶
func (p *PCAPEndpoint) Wait()
type TunVirtualMachine ¶
type TunVirtualMachine struct {
// contains filtered or unexported fields
}
func NewTunVirtualMachine ¶
func NewTunVirtualMachine(ctx context.Context) (*TunVirtualMachine, error)
func (*TunVirtualMachine) Close ¶
func (t *TunVirtualMachine) Close() error
func (*TunVirtualMachine) GetTunnelName ¶
func (t *TunVirtualMachine) GetTunnelName() string
func (*TunVirtualMachine) HijackDomain ¶
func (vm *TunVirtualMachine) HijackDomain(domain string) error
func (*TunVirtualMachine) HijackIP ¶
func (vm *TunVirtualMachine) HijackIP(ip string) error
func (*TunVirtualMachine) HijackIPNet ¶
func (vm *TunVirtualMachine) HijackIPNet(ipNet *net.IPNet) error
func (*TunVirtualMachine) SetHijackTCPHandler ¶
func (t *TunVirtualMachine) SetHijackTCPHandler(handle func(conn netstack.TCPConn)) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.