windivert

package module
v0.0.0-...-34f9fc7 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

README

go-WinDivert2

Go bindings for WinDivert 2.x

ChangeLogs

Thanks

Documentation

Index

Constants

View Source
const (
	FlagDefault   = 0x0000
	FlagSniff     = 0x0001
	FlagDrop      = 0x0002
	FlagRecvOnly  = 0x0004
	FlagSendOnly  = 0x0008
	FlagNoInstall = 0x0010
	FlagFragments = 0x0020
)
View Source
const (
	PriorityDefault    = 0
	PriorityHighest    = 3000
	PriorityLowest     = -3000
	QueueLengthDefault = 4096
	QueueLengthMin     = 32
	QueueLengthMax     = 16384
	QueueTimeDefault   = 2000
	QueueTimeMin       = 100
	QueueTimeMax       = 16000
	QueueSizeDefault   = 4194304
	QueueSizeMin       = 65535
	QueueSizeMax       = 33554432
)
View Source
const (
	ChecksumDefault  = 0
	NoIPChecksum     = 1
	NoICMPChekcsum   = 2
	NoICMPV6Checksum = 4
	NoTCPChekcsum    = 8
	NoUDPChecksum    = 16
)
View Source
const (
	BatchMax = 0xff
	MTUMax   = 40 + 0xffff
)
View Source
const (
	FIN = 1 << 0
	SYN = 1 << 1
	RST = 1 << 2
	PSH = 1 << 3
	ACK = 1 << 4
	UGR = 1 << 5
	ECE = 1 << 6
	CWR = 1 << 7
)
View Source
const (
	ErrInsufficientBuffer = Error(windows.ERROR_INSUFFICIENT_BUFFER)
	ErrNoData             = Error(windows.ERROR_NO_DATA)
	ErrIOPending          = Error(windows.ERROR_IO_PENDING)
	ErrHostUnreachable    = Error(windows.ERROR_HOST_UNREACHABLE)
)
View Source
const (
	METHOD_BUFFERED   = 0
	METHOD_IN_DIRECT  = 1
	METHOD_OUT_DIRECT = 2
	METHOD_NEITHER    = 3
)
View Source
const (
	FILE_READ_DATA  = 1
	FILE_WRITE_DATA = 2
)
View Source
const (
	FILE_DEVICE_NETWORK             = 0x00000012
	FILE_DEVICE_NETWORK_BROWSER     = 0x00000013
	FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014
	FILE_DEVICE_NETWORK_REDIRECTOR  = 0x00000028
)

Variables

View Source
var (
	DeviceName = windows.StringToUTF16Ptr("WinDivert")
)

Functions

func CloseMutex

func CloseMutex(mutex windows.Handle)

func DialIPv4

func DialIPv4(wg *sync.WaitGroup)

func DialIPv6

func DialIPv6(wg *sync.WaitGroup)

func Download

func Download() error

func GetDriverFileName

func GetDriverFileName() (string, error)

func GetInterfaceIndex

func GetInterfaceIndex() (uint32, uint32, error)

func InstallDriver

func InstallDriver() error

func IoControl

func IoControl(h windows.Handle, code CtlCode, ioctl unsafe.Pointer, buf *byte, bufLen uint32) (iolen uint32, err error)

func IoControlEx

func IoControlEx(h windows.Handle, code CtlCode, ioctl unsafe.Pointer, buf *byte, bufLen uint32, overlapped *windows.Overlapped) (iolen uint32, err error)

func RegisterEventSource

func RegisterEventSource(sys string) error

func RemoveDriver

func RemoveDriver() error

Types

type Address

type Address struct {
	Timestamp int64

	Flags uint8
	// contains filtered or unexported fields
}

func (*Address) Ethernet

func (a *Address) Ethernet() *Ethernet

func (*Address) Event

func (a *Address) Event() Event

func (*Address) Flow

func (a *Address) Flow() *Flow

func (*Address) IPChecksum

func (a *Address) IPChecksum() bool

func (*Address) IPv6

func (a *Address) IPv6() bool

func (*Address) Impostor

func (a *Address) Impostor() bool

func (*Address) Layer

func (a *Address) Layer() Layer

func (*Address) Length

func (a *Address) Length() uint32

func (*Address) Loopback

func (a *Address) Loopback() bool

func (*Address) Network

func (a *Address) Network() *Network

func (*Address) Outbound

func (a *Address) Outbound() bool

func (*Address) Reflect

func (a *Address) Reflect() *Reflect

func (*Address) SetEvent

func (a *Address) SetEvent(event Event)

func (*Address) SetIPChecksum

func (a *Address) SetIPChecksum()

func (*Address) SetIPv6

func (a *Address) SetIPv6()

func (*Address) SetImpostor

func (a *Address) SetImpostor()

func (*Address) SetLayer

func (a *Address) SetLayer(layer Layer)

func (*Address) SetLength

func (a *Address) SetLength(n uint32)

func (*Address) SetLoopback

func (a *Address) SetLoopback()

func (*Address) SetOutbound

func (a *Address) SetOutbound()

func (*Address) SetSniffed

func (a *Address) SetSniffed()

func (*Address) SetTCPChecksum

func (a *Address) SetTCPChecksum()

func (*Address) SetUDPChecksum

func (a *Address) SetUDPChecksum()

func (*Address) Sniffed

func (a *Address) Sniffed() bool

func (*Address) Socket

func (a *Address) Socket() *Socket

func (*Address) TCPChecksum

func (a *Address) TCPChecksum() bool

func (*Address) UDPChecksum

func (a *Address) UDPChecksum() bool

func (*Address) UnsetIPChecksum

func (a *Address) UnsetIPChecksum()

func (*Address) UnsetIPv6

func (a *Address) UnsetIPv6()

func (*Address) UnsetImpostor

func (a *Address) UnsetImpostor()

func (*Address) UnsetLoopback

func (a *Address) UnsetLoopback()

func (*Address) UnsetOutbound

func (a *Address) UnsetOutbound()

func (*Address) UnsetSniffed

func (a *Address) UnsetSniffed()

func (*Address) UnsetTCPChecksum

func (a *Address) UnsetTCPChecksum()

func (*Address) UnsetUDPChecksum

func (a *Address) UnsetUDPChecksum()

type CtlCode

type CtlCode uint32

func CTL_CODE

func CTL_CODE(DeviceType, Function, Method, Access uint32) CtlCode

func (CtlCode) String

func (code CtlCode) String() string

type Device

type Device struct {
	*Address
	*io.PipeReader
	*io.PipeWriter
	*utils.AppFilter
	*utils.IPFilter
	*Handle
	TCP  [65536]uint8
	UDP  [65536]uint8
	TCP6 [65536]uint8
	UDP6 [65536]uint8
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(filter string) (dev *Device, err error)

func (*Device) CheckIPv4

func (d *Device) CheckIPv4(b []byte) bool

func (*Device) CheckIPv6

func (d *Device) CheckIPv6(b []byte) bool

func (*Device) CheckTCP4

func (d *Device) CheckTCP4(b []byte) bool

func (*Device) CheckTCP6

func (d *Device) CheckTCP6(b []byte) bool

func (*Device) CheckUDP4

func (d *Device) CheckUDP4(b []byte) bool

func (*Device) CheckUDP6

func (d *Device) CheckUDP6(b []byte) bool

func (*Device) Close

func (d *Device) Close() error

func (*Device) Write

func (d *Device) Write(b []byte) (int, error)

func (*Device) WriteTo

func (d *Device) WriteTo(w io.Writer) (n int64, err error)

type Error

type Error syscall.Errno

func (Error) Error

func (e Error) Error() string

type Ethernet

type Ethernet struct {
	InterfaceIndex    uint32
	SubInterfaceIndex uint32
	// contains filtered or unexported fields
}

type Event

type Event int
const (
	EventNetworkPacket   Event = 0
	EventFlowEstablished Event = 1
	EventFlowDeleted     Event = 2
	EventSocketBind      Event = 3
	EventSocketConnect   Event = 4
	EventSocketListen    Event = 5
	EventSocketAccept    Event = 6
	EventSocketClose     Event = 7
	EventReflectOpen     Event = 8
	EventReflectClose    Event = 9
	EventEthernetFrame   Event = 10
)

func (Event) String

func (e Event) String() string

type Flow

type Flow struct {
	EndpointID       uint64
	ParentEndpointID uint64
	ProcessID        uint32
	LocalAddress     [16]uint8
	RemoteAddress    [16]uint8
	LocalPort        uint16
	RemotePort       uint16
	Protocol         uint8
	// contains filtered or unexported fields
}

type Handle

type Handle struct {
	sync.Mutex
	windows.Handle
	// contains filtered or unexported fields
}

func Open

func Open(filter string, layer Layer, priority int16, flags uint64) (*Handle, error)

func (*Handle) Close

func (h *Handle) Close() error

func (*Handle) GetParam

func (h *Handle) GetParam(p Param) (uint64, error)

func (*Handle) Recv

func (h *Handle) Recv(buffer []byte, address *Address) (uint, error)

func (*Handle) RecvEx

func (h *Handle) RecvEx(buffer []byte, address []Address, overlapped *windows.Overlapped) (uint, uint, error)

func (*Handle) Send

func (h *Handle) Send(buffer []byte, address *Address) (uint, error)

func (*Handle) SendEx

func (h *Handle) SendEx(buffer []byte, address []Address, overlapped *windows.Overlapped) (uint, error)

func (*Handle) SetParam

func (h *Handle) SetParam(p Param, v uint64) error

func (*Handle) Shutdown

func (h *Handle) Shutdown(how Shutdown) error

type IoCtl

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

type Layer

type Layer int
const (
	LayerNetwork        Layer = 0
	LayerNetworkForward Layer = 1
	LayerFlow           Layer = 2
	LayerSocket         Layer = 3
	LayerReflect        Layer = 4
	LayerEthernet       Layer = 5
)

func (Layer) String

func (l Layer) String() string

type Network

type Network struct {
	InterfaceIndex    uint32
	SubInterfaceIndex uint32
	// contains filtered or unexported fields
}

type Param

type Param int
const (
	QueueLength  Param = 0
	QueueTime    Param = 1
	QueueSize    Param = 2
	VersionMajor Param = 3
	VersionMinor Param = 4
)

func (Param) String

func (p Param) String() string

type Reflect

type Reflect struct {
	TimeStamp int64
	ProcessID uint32

	Flags    uint64
	Priority int16
	// contains filtered or unexported fields
}

func (*Reflect) Layer

func (r *Reflect) Layer() Layer

type Shutdown

type Shutdown int
const (
	ShutdownRecv Shutdown = 0
	ShutdownSend Shutdown = 1
	ShutdownBoth Shutdown = 2
)

func (Shutdown) String

func (h Shutdown) String() string

type Socket

type Socket struct {
	EndpointID       uint64
	ParentEndpointID uint64
	ProcessID        uint32
	LocalAddress     [16]uint8
	RemoteAddress    [16]uint8
	LocalPort        uint16
	RemotePort       uint16
	Protocol         uint8
	// contains filtered or unexported fields
}

Directories

Path Synopsis
internal
iana
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
utils/iptree
Package iptree implements radix tree data structure for IPv4 and IPv6 networks.
Package iptree implements radix tree data structure for IPv4 and IPv6 networks.

Jump to

Keyboard shortcuts

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