driver

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIPv4 = errors.New(`invalid IPv4 address`)
View Source
var ErrInvalidIPv6 = errors.New(`invalid IPv6 address`)
View Source
var ErrInvalidRuleNumber = errors.New(`invalid rule number`)
View Source
var ErrNatIPOrNatPortRequired = errors.New(`NAT IP 和 NAT 端口 不能同时为空`)
View Source
var ErrUnsupported = errors.New(`unsupported`)
View Source
var ErrUnsupportedChain = fmt.Errorf(`%w chain`, ErrUnsupported)
View Source
var ErrUnsupportedTable = fmt.Errorf(`%w table`, ErrUnsupported)

Functions

This section is empty.

Types

type Driver added in v1.1.0

type Driver interface {
	Enabled(on bool) error
	Reset() error
	Import(wfwFile string) error
	Export(wfwFile string) error
	Insert(rules ...Rule) error
	AsWhitelist(table, chain string) error
	Append(rules ...Rule) error
	Update(rule Rule) error
	Delete(rules ...Rule) error
	Exists(rule Rule) (bool, error)
	Stats(table, chain string) ([]map[string]string, error)
	List(table, chain string) ([]*Rule, error)
}

type Protocol added in v1.3.2

type Protocol byte

Protocol to differentiate between IPv4 and IPv6

const (
	ProtocolIPv4 Protocol = iota
	ProtocolIPv6
)

type Rule

type Rule struct {
	ID        uint   `json:"id,omitempty" xml:"id,omitempty"`
	Number    uint64 `json:"num,omitempty" xml:"num,omitempty"`
	Type      string `json:"type" xml:"type"` // filter / nat / etc.
	Name      string `json:"name" xml:"name"`
	Direction string `json:"direction" xml:"direction"` // INPUT / OUTPUT / etc.
	Action    string `json:"action" xml:"action"`       // ACCEPT / DROP / etc.
	Protocol  string `json:"protocol" xml:"protocol"`   // tcp / udp / etc.

	// interface 网口
	Interface string `json:"interface" xml:"interface"` // 网络入口网络接口
	Outerface string `json:"outerface" xml:"outerface"` // 网络出口网络接口

	// state
	State string `json:"state" xml:"state"`

	// IP or Port
	RemoteIP   string `json:"remoteIP" xml:"remoteIP"`
	LocalIP    string `json:"localIP" xml:"localIP"`
	NatIP      string `json:"natIP" xml:"natIP"`
	RemotePort string `json:"remotePort" xml:"remotePort"` // 支持指定范围
	LocalPort  string `json:"localPort" xml:"localPort"`   // 支持指定范围
	NatPort    string `json:"natPort" xml:"natPort"`       // 支持指定范围
	IPVersion  string `json:"ipVersion"  xml:"ipVersion"`  // 4 or 6

	// Limit
	ConnLimit uint64 `json:"connLimit"  xml:"connLimit"` // 每个IP最大连接数
	RateLimit string `json:"rateLimit"  xml:"rateLimit"` // 频率限制规则(格式:200/pkt/second)
	RateBurst uint   `json:"rateBurst"  xml:"rateBurst"` // 频率最大峰值
}

func (*Rule) IDBytes added in v1.3.2

func (r *Rule) IDBytes() []byte

func (*Rule) IDString added in v1.3.2

func (r *Rule) IDString() string

type Stat added in v1.3.2

type Stat struct {
	Number      uint64     `json:"num,omitempty"`
	Packets     uint64     `json:"pkts"`
	Bytes       uint64     `json:"bytes"`
	Target      string     `json:"target"`
	Protocol    string     `json:"prot"`
	Opt         string     `json:"opt"`
	Input       string     `json:"in"`
	Output      string     `json:"out"`
	Source      *net.IPNet `json:"source"`
	Destination *net.IPNet `json:"destination"`
	Options     string     `json:"options"`
}

Stat represents a structured statistic entry.

Directories

Path Synopsis
Package netsh for windows
Package netsh for windows

Jump to

Keyboard shortcuts

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