Documentation ¶
Overview ¶
gonfapi Package sort provides primitives for sorting slices and user-defined collections.
Index ¶
- Constants
- func PtrToBytes(b *byte, len int) (data []byte)
- type DIRECTION
- type DataCode
- type EventHandler
- type FILTERING_FLAG
- type INT16
- type INT32
- type IpAddress
- type NFApi
- func (a *NFApi) Load(dll string) error
- func (a NFApi) NfAddBindingRule(prule *NF_BINDING_RULE, toHead bool) (NF_STATUS, error)
- func (a NFApi) NfAddFlowCtl(pData *NF_FLOWCTL_DATA, pFcHandle *uint32) (NF_STATUS, error)
- func (a NFApi) NfAddRule(rule *NF_RULE, ToHead bool) (NF_STATUS, error)
- func (a NFApi) NfAddRuleEx(rule *NF_RULE_EX, ToHead bool) (NF_STATUS, error)
- func (a NFApi) NfAdjustProcessPriviledges()
- func (a NFApi) NfCompleteTCPConnectRequest(id uint64, pConnInfo *NF_TCP_CONN_INFO) (NF_STATUS, error)
- func (a NFApi) NfCompleteUDPConnectRequest(id uint64, pConnInfo *NF_UDP_CONN_INFO) (NF_STATUS, error)
- func (a NFApi) NfDeleteBindingRules() (NF_STATUS, error)
- func (a NFApi) NfDeleteFlowCtl(fcHandle uint32) (NF_STATUS, error)
- func (a NFApi) NfDeleteRules() (NF_STATUS, error)
- func (a NFApi) NfFree()
- func (a NFApi) NfGetConnCount() (uint32, error)
- func (a NFApi) NfGetDriverType() (uint32, error)
- func (a NFApi) NfGetFlowCtlStat(fcHandle uint32, pData *NF_FLOWCTL_STAT) (NF_STATUS, error)
- func (a NFApi) NfGetProcessNameFromKernel(processId uint32) (string, bool, error)
- func (a NFApi) NfGetProcessNameW(processId uint32) (string, bool, error)
- func (a NFApi) NfGetTCPConnInfo(id uint64, pConnInfo *NF_TCP_CONN_INFO) (NF_STATUS, error)
- func (a NFApi) NfGetTCPStat(id uint64, pData *NF_FLOWCTL_STAT) (NF_STATUS, error)
- func (a NFApi) NfGetUDPConnInfo(id uint64, pConnInfo *NF_UDP_CONN_INFO) (NF_STATUS, error)
- func (a NFApi) NfGetUDPStat(id uint64, pData *NF_FLOWCTL_STAT) (NF_STATUS, error)
- func (a NFApi) NfInit(driverName string, Ev *NF_EventHandler) (NF_STATUS, error)
- func (a NFApi) NfIpPostReceive(buf []byte, option *NF_IP_PACKET_OPTIONS) (NF_STATUS, error)
- func (a NFApi) NfIpPostSend(buf []byte, option *NF_IP_PACKET_OPTIONS) (NF_STATUS, error)
- func (a NFApi) NfModifyFlowCtl(fcHandle uint32, pData *NF_FLOWCTL_DATA) (NF_STATUS, error)
- func (a NFApi) NfRegisterDriver(driverName string) (NF_STATUS, error)
- func (a NFApi) NfRegisterDriverEx(driverName string, path string) (NF_STATUS, error)
- func (a NFApi) NfSetOptions(nThreads uint16, flag uint16)
- func (a NFApi) NfSetRules(rule []NF_RULE) (NF_STATUS, error)
- func (a NFApi) NfSetRulesEx(rule []NF_RULE_EX) (NF_STATUS, error)
- func (a NFApi) NfSetTCPFlowCtl(id uint64, fcHandle uint32) (NF_STATUS, error)
- func (a NFApi) NfSetTCPTimeout(id uint32) (NF_STATUS, error)
- func (a NFApi) NfSetUDPFlowCtl(id uint64, fcHandle uint32) (NF_STATUS, error)
- func (a NFApi) NfTcpClose(id uint64) (NF_STATUS, error)
- func (a NFApi) NfTcpDisableFiltering(id uint64) (NF_STATUS, error)
- func (a NFApi) NfTcpIsProxy(processId uint32) (bool, error)
- func (a NFApi) NfTcpPostReceive(id uint64, bufer []byte) (NF_STATUS, error)
- func (a NFApi) NfTcpPostSend(id uint64, bufer []byte) (NF_STATUS, error)
- func (a NFApi) NfTcpSetConnectionState(id uint64, suspended bool) (NF_STATUS, error)
- func (a NFApi) NfTcpSetSockOpt(id uint64, optname int32, optval []byte) (NF_STATUS, error)
- func (a NFApi) NfUdpDisableFiltering(id uint64) (NF_STATUS, error)
- func (a NFApi) NfUdpPostReceive(id uint64, remoteAddress []byte, buf []byte, option *NF_UDP_OPTIONS) (NF_STATUS, error)
- func (a NFApi) NfUdpPostSend(id uint64, remoteAddress []byte, buf []byte, option *NF_UDP_OPTIONS) (NF_STATUS, error)
- func (a NFApi) NfUdpSetConnectionState(id uint64, suspended bool) (NF_STATUS, error)
- func (a NFApi) NfUnRegisterDriver(driverName string) (NF_STATUS, error)
- type NF_BINDING_RULE
- type NF_BUFFERS
- type NF_DATA
- type NF_EventHandler
- type NF_FLOWCTL_DATA
- type NF_FLOWCTL_MODIFY_DATA
- type NF_FLOWCTL_SET_DATA
- type NF_FLOWCTL_STAT
- type NF_IP_FLAG
- type NF_IP_PACKET_OPTIONS
- type NF_PORT_RANGE
- type NF_READ_RESULT
- type NF_RULE
- type NF_RULE_EX
- type NF_STATUS
- type NF_TCP_CONN_INFO
- type NF_UDP_CONN_INFO
- type NF_UDP_CONN_REQUEST
- type NF_UDP_OPTIONS
- type SockaddrInx
- type UINT16
- type UINT32
- type UINT64
Constants ¶
View Source
const ( TCP_PACKET_BUF_SIZE int32 = 8192 UDP_PACKET_BUF_SIZE int32 = 2 * 65536 )
C enum and #define is 4Bytes
View Source
const ( MAX_ADDRESS_LENGTH = 28 MAX_IP_ADDRESS_LENGTH = 16 AF_INET = 2 AF_INET6 = 23 IPPROTO_UDP = 17 IPPROTO_TCP = 6 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DataCode ¶
type DataCode int32
const ( TCP_CONNECTED DataCode = iota TCP_CLOSED TCP_RECEIVE TCP_SEND TCP_CAN_RECEIVE TCP_CAN_SEND TCP_REQ_SUSPEND TCP_REQ_RESUME //UDP UDP_CREATED UDP_CLOSED UDP_RECEIVE UDP_SEND UDP_CAN_RECEIVE UDP_CAN_SEND UDP_REQ_SUSPEND UDP_REQ_RESUME //REQ RULE REQ_ADD_HEAD_RULE REQ_ADD_TAIL_RULE REQ_DELETE_RULES //CONNECT TCP_CONNECT_REQUEST UDP_CONNECT_REQUEST //other TCP_DISABLE_USER_MODE_FILTERING UDP_DISABLE_USER_MODE_FILTERING REQ_SET_TCP_OPT REQ_IS_PROXY TCP_REINJECT TCP_REMOVE_CLOSED TCP_DEFERRED_DISCONNECT IP_RECEIVE IP_SEND TCP_RECEIVE_PUSH )
type EventHandler ¶
type EventHandler interface { ThreadStart() uintptr ThreadEnd() uintptr TcpConnectRequest(id uint64, pConnInfo *NF_TCP_CONN_INFO) uintptr TcpConnected(id uint64, pConnInfo *NF_TCP_CONN_INFO) uintptr TcpClosed(id uint64, pConnInfo *NF_TCP_CONN_INFO) uintptr TcpReceive(id uint64, buf *byte, len int32) uintptr TcpSend(id uint64, buf *byte, len int32) uintptr TcpCanReceive(id uint64) uintptr TcpCanSend(id uint64) uintptr UdpCreated(id uint64, pConnInfo *NF_UDP_CONN_INFO) uintptr UdpConnectRequest(id uint64, pConnInfo *NF_UDP_CONN_REQUEST) uintptr UdpClosed(id uint64, pConnInfo *NF_UDP_CONN_INFO) uintptr UdpReceive(id uint64, remoteAddress *SockaddrInx, buf *byte, len int32, options *NF_UDP_OPTIONS) uintptr UdpSend(id uint64, remoteAddress *SockaddrInx, buf *byte, len int32, options *NF_UDP_OPTIONS) uintptr UdpCanReceive(id uint64) uintptr UdpCanSend(id uint64) uintptr }
事件回调接口 所有返回值为0
type FILTERING_FLAG ¶
type FILTERING_FLAG uint32
const ( NF_ALLOW FILTERING_FLAG = 0 // Allow the activity without filtering transmitted packets NF_BLOCK FILTERING_FLAG = 1 // Block the activity NF_FILTER FILTERING_FLAG = 2 // Filter the transmitted packets NF_SUSPENDED FILTERING_FLAG = 4 // Suspend receives from server and sends from client NF_OFFLINE FILTERING_FLAG = 8 // Emulate establishing a TCP connection with remote server NF_INDICATE_CONNECT_REQUESTS FILTERING_FLAG = 16 // Indicate outgoing connect requests to API NF_DISABLE_REDIRECT_PROTECTION FILTERING_FLAG = 32 // Disable blocking indicating connect requests for outgoing connections of local proxies NF_PEND_CONNECT_REQUEST FILTERING_FLAG = 64 // Pend outgoing connect request to complete it later using nf_complete(TCP|UDP)ConnectRequest NF_FILTER_AS_IP_PACKETS FILTERING_FLAG = 128 // Indicate the traffic as IP packets via ipSend/ipReceive NF_READONLY FILTERING_FLAG = 256 // Don't block the IP packets and indicate them to ipSend/ipReceive only for monitoring NF_CONTROL_FLOW FILTERING_FLAG = 512 )
type IpAddress ¶
type IpAddress [16]byte
IP Addres
|0000|0000|0000|0000|
|ipv4|
|------ ipv6 -------|
type NFApi ¶
type NFApi struct {
// contains filtered or unexported fields
}
func (NFApi) NfAddBindingRule ¶
func (a NFApi) NfAddBindingRule(prule *NF_BINDING_RULE, toHead bool) (NF_STATUS, error)
func (NFApi) NfAddFlowCtl ¶
func (a NFApi) NfAddFlowCtl(pData *NF_FLOWCTL_DATA, pFcHandle *uint32) (NF_STATUS, error)
func (NFApi) NfAddRuleEx ¶
func (a NFApi) NfAddRuleEx(rule *NF_RULE_EX, ToHead bool) (NF_STATUS, error)
添加扩展规则
func (NFApi) NfAdjustProcessPriviledges ¶
func (a NFApi) NfAdjustProcessPriviledges()
运行当前进程查看所有进行名称
func (NFApi) NfCompleteTCPConnectRequest ¶
func (a NFApi) NfCompleteTCPConnectRequest(id uint64, pConnInfo *NF_TCP_CONN_INFO) (NF_STATUS, error)
完成TCP请求
func (NFApi) NfCompleteUDPConnectRequest ¶
func (a NFApi) NfCompleteUDPConnectRequest(id uint64, pConnInfo *NF_UDP_CONN_INFO) (NF_STATUS, error)
完成UDP请求
func (NFApi) NfDeleteBindingRules ¶
func (NFApi) NfGetDriverType ¶
func (NFApi) NfGetFlowCtlStat ¶
func (a NFApi) NfGetFlowCtlStat(fcHandle uint32, pData *NF_FLOWCTL_STAT) (NF_STATUS, error)
func (NFApi) NfGetProcessNameFromKernel ¶
获取进程名称(内核)
func (NFApi) NfGetProcessNameW ¶
获取进程名称
func (NFApi) NfGetTCPConnInfo ¶
func (a NFApi) NfGetTCPConnInfo(id uint64, pConnInfo *NF_TCP_CONN_INFO) (NF_STATUS, error)
获取TCP链接信息
func (NFApi) NfGetTCPStat ¶
func (a NFApi) NfGetTCPStat(id uint64, pData *NF_FLOWCTL_STAT) (NF_STATUS, error)
func (NFApi) NfGetUDPConnInfo ¶
func (a NFApi) NfGetUDPConnInfo(id uint64, pConnInfo *NF_UDP_CONN_INFO) (NF_STATUS, error)
获取UDP链接信息
func (NFApi) NfGetUDPStat ¶
func (a NFApi) NfGetUDPStat(id uint64, pData *NF_FLOWCTL_STAT) (NF_STATUS, error)
func (NFApi) NfInit ¶
func (a NFApi) NfInit(driverName string, Ev *NF_EventHandler) (NF_STATUS, error)
初始化
func (NFApi) NfIpPostReceive ¶
func (a NFApi) NfIpPostReceive(buf []byte, option *NF_IP_PACKET_OPTIONS) (NF_STATUS, error)
接收UDP数据
func (NFApi) NfIpPostSend ¶
func (a NFApi) NfIpPostSend(buf []byte, option *NF_IP_PACKET_OPTIONS) (NF_STATUS, error)
发送IP数据
func (NFApi) NfModifyFlowCtl ¶
func (a NFApi) NfModifyFlowCtl(fcHandle uint32, pData *NF_FLOWCTL_DATA) (NF_STATUS, error)
func (NFApi) NfRegisterDriver ¶
注册驱动
func (NFApi) NfRegisterDriverEx ¶
从其他位置注册驱动
func (NFApi) NfSetRulesEx ¶
func (a NFApi) NfSetRulesEx(rule []NF_RULE_EX) (NF_STATUS, error)
设置扩展规则
func (NFApi) NfSetTCPFlowCtl ¶
func (NFApi) NfSetUDPFlowCtl ¶
func (NFApi) NfTcpDisableFiltering ¶
禁用TCP过滤
func (NFApi) NfTcpPostReceive ¶
TCP数据接受
func (NFApi) NfTcpPostSend ¶
TCP数据发送
func (NFApi) NfTcpSetConnectionState ¶
设置TCP链接状态
func (NFApi) NfTcpSetSockOpt ¶
设置TCP链接参数
func (NFApi) NfUdpDisableFiltering ¶
禁用UDP过滤
func (NFApi) NfUdpPostReceive ¶
func (a NFApi) NfUdpPostReceive(id uint64, remoteAddress []byte, buf []byte, option *NF_UDP_OPTIONS) (NF_STATUS, error)
接收UDP数据
func (NFApi) NfUdpPostSend ¶
func (a NFApi) NfUdpPostSend(id uint64, remoteAddress []byte, buf []byte, option *NF_UDP_OPTIONS) (NF_STATUS, error)
发送UDP数据
func (NFApi) NfUdpSetConnectionState ¶
设置UDP链接状态
type NF_BINDING_RULE ¶
type NF_BUFFERS ¶
type NF_BUFFERS struct {
InBuf, InBufLen, OutBuf, OutBufLen uint64
}
type NF_EventHandler ¶
type NF_EventHandler struct { ThreadStart uintptr ThreadEnd uintptr TcpConnectRequest uintptr TcpConnected uintptr TcpClosed uintptr TcpReceive uintptr TcpSend uintptr TcpCanReceive uintptr TcpCanSend uintptr UdpCreated uintptr UdpConnectRequest uintptr UdpClosed uintptr UdpReceive uintptr UdpSend uintptr UdpCanReceive uintptr UdpCanSend uintptr }
NF_EventHandler 传递到dll的结构体 所有字段皆为回调参数指针
type NF_FLOWCTL_DATA ¶
type NF_FLOWCTL_DATA struct {
InLimit, OutLimit UINT64
}
type NF_FLOWCTL_MODIFY_DATA ¶
type NF_FLOWCTL_MODIFY_DATA struct { FcHandle uint32 Data NF_FLOWCTL_DATA }
type NF_FLOWCTL_SET_DATA ¶
type NF_FLOWCTL_STAT ¶
type NF_FLOWCTL_STAT struct {
InBytes, OutBytes UINT64
}
type NF_IP_PACKET_OPTIONS ¶
type NF_IP_PACKET_OPTIONS struct { IpFamily UINT16 IpHeaderSize UINT32 CompartmentId UINT32 InterfaceIndex UINT32 SubInterfaceIndex UINT32 Flags UINT32 }
* * IP options *
type NF_READ_RESULT ¶
type NF_READ_RESULT struct {
Length uint64
}
type NF_RULE ¶
type NF_RULE struct { Protocol INT32 ProcessId UINT32 Direction uint8 LocalPort UINT16 RemotePort UINT16 IpFamily INT16 LocalIpAddress IpAddress LocalIpAddressMask IpAddress RemoteIpAddress IpAddress RemoteIpAddressMask IpAddress FilteringFlag UINT32 }
NF_RULE
type NF_RULE_EX ¶
type NF_RULE_EX struct { NF_RULE LocalPortRange NF_PORT_RANGE RemotePortRange NF_PORT_RANGE RedirectTo SockaddrInx LocalProxyProcessId UINT32 // contains filtered or unexported fields }
NF_RULE_EX
func (*NF_RULE_EX) GetProcessName ¶
func (n *NF_RULE_EX) GetProcessName() string
func (*NF_RULE_EX) SetProcessName ¶
func (n *NF_RULE_EX) SetProcessName(s string)
type NF_TCP_CONN_INFO ¶
type NF_TCP_CONN_INFO struct { FilteringFlag UINT32 ProcessId UINT32 Direction uint8 IpFamily UINT16 LocalAddress SockaddrInx RemoteAddress SockaddrInx }
* * TCP connection properties UNALIGNED *
type NF_UDP_CONN_INFO ¶
type NF_UDP_CONN_INFO struct { ProcessId UINT32 IpFamily UINT16 LocalAddress SockaddrInx }
* * UDP endpoint properties UNALIGNED *
type NF_UDP_CONN_REQUEST ¶
type NF_UDP_CONN_REQUEST struct { FilteringFlag UINT32 ProcessId UINT32 IpFamily UINT16 LocalAddress SockaddrInx RemoteAddress SockaddrInx }
* * UDP TDI_CONNECT request properties UNALIGNED *
type NF_UDP_OPTIONS ¶
type NF_UDP_OPTIONS struct { Flags UINT32 OptionsLength INT32 Options [2048]byte //Options of variable size }
* * UDP options UNALIGNED *
func (NF_UDP_OPTIONS) GetBytes ¶ added in v0.0.2
func (op NF_UDP_OPTIONS) GetBytes() (data []byte)
type SockaddrInx ¶
type SockaddrInx struct { Family UINT16 //AF_INT or AF_INT6. LittleEndian Port UINT16 //Port. BigEndian Data1 [4]byte //ipv4 Adder,ipv6 is zero. BigEndian Data2 [16]byte //ipv6 Adder,ipv4 is zero. BigEndian IPV6ScopeId UINT32 //ipv6 scope id }
sockaddr_in4/6
func (*SockaddrInx) GetPort ¶
func (s *SockaddrInx) GetPort() uint16
func (*SockaddrInx) IsIpv6 ¶
func (s *SockaddrInx) IsIpv6() bool
func (*SockaddrInx) SetPort ¶
func (s *SockaddrInx) SetPort(p uint16)
func (*SockaddrInx) String ¶
func (s *SockaddrInx) String() string
func (*SockaddrInx) ToBytes ¶
func (s *SockaddrInx) ToBytes() (data []byte)
Click to show internal directories.
Click to hide internal directories.