Documentation ¶
Index ¶
- Constants
- func HelperCheckFilter(filter string) (bool, int)
- func HelperEvalFilter(packet *Packet, filter string) (bool, error)
- func LoadDLL(path64, path32 string)
- type Direction
- type Packet
- func (p *Packet) CalcNewChecksum(wd *WinDivertHandle)
- func (p *Packet) Direction() Direction
- func (p *Packet) DstIP() net.IP
- func (p *Packet) DstPort() (uint16, error)
- func (p *Packet) EvalFilter(filter string) (bool, error)
- func (p *Packet) IpVersion() int
- func (p *Packet) NextHeaderProtocolName() string
- func (p *Packet) NextHeaderType() uint8
- func (p *Packet) ParseHeaders()
- func (p *Packet) Send(wd *WinDivertHandle) (uint, error)
- func (p *Packet) SetDstIP(ip net.IP)
- func (p *Packet) SetDstPort(port uint16) error
- func (p *Packet) SetSrcIP(ip net.IP)
- func (p *Packet) SetSrcPort(port uint16) error
- func (p *Packet) SrcIP() net.IP
- func (p *Packet) SrcPort() (uint16, error)
- func (p *Packet) String() string
- func (p *Packet) VerifyParsed()
- type WinDivertAddress
- func (w *WinDivertAddress) Direction() Direction
- func (w *WinDivertAddress) Impostor() bool
- func (w *WinDivertAddress) Loopback() bool
- func (w *WinDivertAddress) PseudoIPChecksum() bool
- func (w *WinDivertAddress) PseudoTCPChecksum() bool
- func (w *WinDivertAddress) PseudoUDPChecksum() bool
- func (w *WinDivertAddress) String() string
- type WinDivertHandle
Constants ¶
const ( PacketBufferSize = 1500 PacketChanCapacity = 256 WinDivertDirectionOutbound Direction = false WinDivertDirectionInbound Direction = true )
Variables ¶
This section is empty.
Functions ¶
func HelperCheckFilter ¶
Take the given filter and check if it contains any error https://reqrypt.org/windivert-doc.html#divert_helper_check_filter
func HelperEvalFilter ¶
Take a packet and compare it with the given filter Returns true if the packet matches the filter https://reqrypt.org/windivert-doc.html#divert_helper_eval_filter
Types ¶
type Packet ¶
type Packet struct { Raw []byte Addr *WinDivertAddress PacketLen uint IpHdr header.IPHeader NextHeader header.ProtocolHeader // contains filtered or unexported fields }
Represents a packet
func (*Packet) CalcNewChecksum ¶
func (p *Packet) CalcNewChecksum(wd *WinDivertHandle)
Recalculate the packet's checksum Shortcut for WinDivertHelperCalcChecksum
func (*Packet) Direction ¶
Returns the Direction of the packet WinDivertDirectionInbound (true) for inbound Packets WinDivertDirectionOutbound (false) for outbound packets Shortcut for Addr.Direction()
func (*Packet) DstPort ¶
Returns the destination port of the packet Shortcut for NextHeader.DstPort()
func (*Packet) EvalFilter ¶
Check the packet with the filter Returns true if the packet matches the filter
func (*Packet) NextHeaderProtocolName ¶
Returns the name of the protocol
func (*Packet) NextHeaderType ¶
Returns the IP Protocol number of the next Header https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers
func (*Packet) Send ¶
func (p *Packet) Send(wd *WinDivertHandle) (uint, error)
Inject the packet on the Network Stack If the packet has been modified calls WinDivertHelperCalcChecksum to get a new checksum
func (*Packet) SetDstPort ¶
Sets the destination port of the packet Shortcut for NextHeader.SetDstPort()
func (*Packet) SetSrcPort ¶
Sets the source port of the packet Shortcut for NextHeader.SetSrcPort()
func (*Packet) VerifyParsed ¶
func (p *Packet) VerifyParsed()
Check if the headers have already been parsed and call ParseHeaders() if not
type WinDivertAddress ¶
Represents a WinDivertAddress struct See : https://reqrypt.org/windivert-doc.html#divert_address As go doesn't not support bit fields we use a little trick to get the Direction, Loopback, Import and PseudoChecksum fields
func (*WinDivertAddress) Direction ¶
func (w *WinDivertAddress) Direction() Direction
Returns the direction of the packet WinDivertDirectionInbound (true) for inbounds packets WinDivertDirectionOutbounds (false) for outbounds packets
func (*WinDivertAddress) Impostor ¶
func (w *WinDivertAddress) Impostor() bool
Returns true if the packet is an impostor See https://reqrypt.org/windivert-doc.html#divert_address for more information
func (*WinDivertAddress) Loopback ¶
func (w *WinDivertAddress) Loopback() bool
Returns true if the packet is a loopback packet
func (*WinDivertAddress) PseudoIPChecksum ¶
func (w *WinDivertAddress) PseudoIPChecksum() bool
Returns true if the packet uses a pseudo IP checksum
func (*WinDivertAddress) PseudoTCPChecksum ¶
func (w *WinDivertAddress) PseudoTCPChecksum() bool
Returns true if the packet uses a pseudo TCP checksum
func (*WinDivertAddress) PseudoUDPChecksum ¶
func (w *WinDivertAddress) PseudoUDPChecksum() bool
Returns true if the packet uses a pseudo UDP checksum
func (*WinDivertAddress) String ¶
func (w *WinDivertAddress) String() string
type WinDivertHandle ¶
type WinDivertHandle struct {
// contains filtered or unexported fields
}
Used to call WinDivert's functions
func NewWinDivertHandle ¶
func NewWinDivertHandle(filter string) (*WinDivertHandle, error)
Create a new WinDivertHandle by calling WinDivertOpen and returns it The string parameter is the fiter that packets have to match https://reqrypt.org/windivert-doc.html#divert_open
func NewWinDivertHandleWithFlags ¶
func NewWinDivertHandleWithFlags(filter string, flags uint8) (*WinDivertHandle, error)
Create a new WinDivertHandle by calling WinDivertOpen and returns it The string parameter is the fiter that packets have to match and flags are the used flags used https://reqrypt.org/windivert-doc.html#divert_open
func WinDivertOpen ¶
func WinDivertOpen(filter string, layer uint8, priority uint16, flags uint8) (*WinDivertHandle, error)
Create a new WinDivertHandle by calling WinDivertOpen and returns it https://reqrypt.org/windivert-doc.html#divert_open
func (*WinDivertHandle) Close ¶
func (wd *WinDivertHandle) Close() error
Close the Handle See https://reqrypt.org/windivert-doc.html#divert_close
func (*WinDivertHandle) HelperCalcChecksum ¶
func (wd *WinDivertHandle) HelperCalcChecksum(packet *Packet)
Calls WinDivertHelperCalcChecksum to calculate the packet's chacksum https://reqrypt.org/windivert-doc.html#divert_helper_calc_checksums
func (*WinDivertHandle) Packets ¶
func (wd *WinDivertHandle) Packets() (chan *Packet, error)
Create a new channel that will be used to pass captured packets and returns it calls recvLoop to maintain a loop
func (*WinDivertHandle) Recv ¶
func (wd *WinDivertHandle) Recv() (*Packet, error)
Divert a packet from the Network Stack https://reqrypt.org/windivert-doc.html#divert_recv
func (*WinDivertHandle) Send ¶
func (wd *WinDivertHandle) Send(packet *Packet) (uint, error)
Inject the packet on the Network Stack https://reqrypt.org/windivert-doc.html#divert_send