This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
forked from imgk/divert-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.go
158 lines (141 loc) · 3.13 KB
/
const.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//go:build windows
// +build windows
package divert
const (
StatusOpen = 1
StatusShutdown = 2
StatusClosed = 3
StatusEnded = 4
)
const (
PacketBufferSize = 1500
PacketChanCapacity = 256
)
const (
LayerNetwork Layer = 0
LayerNetworkForward Layer = 1
LayerFlow Layer = 2
LayerSocket Layer = 3
LayerReflect Layer = 4
)
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
)
const (
ShutdownRecv Shutdown = 0
ShutdownSend Shutdown = 1
ShutdownBoth Shutdown = 2
)
const (
QueueLength Param = 0
QueueTime Param = 1
QueueSize Param = 2
VersionMajor Param = 3
VersionMinor Param = 4
)
const (
FlagDefault = 0x0000
FlagSniff = 0x0001
FlagDrop = 0x0002
FlagRecvOnly = 0x0004
FlagSendOnly = 0x0008
FlagNoInstall = 0x0010
FlagFragments = 0x0020
)
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
)
type Layer int
func (l Layer) String() string {
switch l {
case LayerNetwork:
return "WINDIVERT_LAYER_NETWORK"
case LayerNetworkForward:
return "WINDIVERT_LAYER_NETWORK_FORWARD"
case LayerFlow:
return "WINDIVERT_LAYER_FLOW"
case LayerSocket:
return "WINDIVERT_LAYER_SOCKET"
case LayerReflect:
return "WINDIVERT_LAYER_REFLECT"
default:
return ""
}
}
type Event int
func (e Event) String() string {
switch e {
case EventNetworkPacket:
return "WINDIVERT_EVENT_NETWORK_PACKET"
case EventFlowEstablished:
return "WINDIVERT_EVENT_FLOW_ESTABLISHED"
case EventFlowDeleted:
return "WINDIVERT_EVENT_FLOW_DELETED"
case EventSocketBind:
return "WINDIVERT_EVENT_SOCKET_BIND"
case EventSocketConnect:
return "WINDIVERT_EVENT_SOCKET_CONNECT"
case EventSocketListen:
return "WINDIVERT_EVENT_SOCKET_LISTEN"
case EventSocketAccept:
return "WINDIVERT_EVENT_SOCKET_ACCEPT"
case EventSocketClose:
return "WINDIVERT_EVENT_SOCKET_CLOSE"
case EventReflectOpen:
return "WINDIVERT_EVENT_REFLECT_OPEN"
case EventReflectClose:
return "WINDIVERT_EVENT_REFLECT_CLOSE"
default:
return ""
}
}
type Shutdown int
func (s Shutdown) String() string {
switch s {
case ShutdownRecv:
return "WINDIVERT_SHUTDOWN_RECV"
case ShutdownSend:
return "WINDIVERT_SHUTDOWN_SEND"
case ShutdownBoth:
return "WINDIVERT_SHUTDOWN_BOTH"
default:
return ""
}
}
type Param int
func (p Param) String() string {
switch p {
case QueueLength:
return "WINDIVERT_PARAM_QUEUE_LENGTH"
case QueueTime:
return "WINDIVERT_PARAM_QUEUE_TIME"
case QueueSize:
return "WINDIVERT_PARAM_QUEUE_SIZE"
case VersionMajor:
return "WINDIVERT_PARAM_VERSION_MAJOR"
case VersionMinor:
return "WINDIVERT_PARAM_VERSION_MINOR"
default:
return ""
}
}