This repository has been archived by the owner on Apr 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
ip_filter_rule.go
69 lines (55 loc) · 1.71 KB
/
ip_filter_rule.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
//go:binary-only-package
package flowdesc
import (
"errors"
"net"
"regexp"
"strconv"
"strings"
)
type IPFilterRule interface {
// initial structure
//Init() error
// Set action of IPFilterRule
SetAction(bool) error
// Set Direction of IPFilterRule
SetDirection(bool) error
// Set Protocol of IPFilterRule
// 0xfc stand for ip (any)
SetProtocal(int) error
// Set Source IP of IPFilterRule
// format: IP or IP/mask or "any"
SetSourceIp(string) error
// Set Source port of IPFilterRule
// format: {port/port-port}[,ports[,...]]
SetSourcePorts(string) error
// Set Destination IP of IPFilterRule
// format: IP or IP/mask or "assigned"
SetDestinationIp(string) error
// Set Destination port of IPFilterRule
// format: {port/port-port}[,ports[,...]]
SetDestinationPorts(string) error
// Encode the IPFilterRule
Encode() (string, error)
// Decode the IPFilterRule
Decode() error
}
type ipFilterRule struct {
action bool // true: permit, false: deny
dir bool // false: in, true: out
proto int // protocal number
srcIp string // <address/mask>
srcPorts string // [ports]
dstIp string // <address/mask>
dstPorts string // [ports]
}
func NewIPFilterRule() *ipFilterRule {}
func (r *ipFilterRule) SetAction(action bool) error {}
func (r *ipFilterRule) SetDirection(dir bool) error {}
func (r *ipFilterRule) SetProtocal(proto int) error {}
func (r *ipFilterRule) SetSourceIp(networkStr string) error {}
func (r *ipFilterRule) SetSourcePorts(ports string) error {}
func (r *ipFilterRule) SetDestinationIp(networkStr string) error {}
func (r *ipFilterRule) SetDestinationPorts(ports string) error {}
func (r *ipFilterRule) Encode() (string, error) {}
func (r *ipFilterRule) Decode() error {}