1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-11 04:06:14 +08:00

add cidr hook in unix

This commit is contained in:
fumiama
2021-12-30 17:11:13 +08:00
parent bcfba4418f
commit cd060c7b92
4 changed files with 35 additions and 2 deletions

View File

@@ -18,12 +18,14 @@ type NIC struct {
ifce *water.Interface
ip string
subnet string
cidrs []string
hasstart bool
}
// NewNIC 新建 TUN 网络接口卡
// 网卡地址为 ip, 所属子网为 subnet
func NewNIC(ip, subnet string) (n *NIC) {
// 所有路由为 cidrs
func NewNIC(ip, subnet string, cidrs ...string) (n *NIC) {
ifce, err := water.New(water.Config{DeviceType: water.TUN})
if err != nil {
panic(err)
@@ -31,6 +33,7 @@ func NewNIC(ip, subnet string) (n *NIC) {
n = &NIC{
ifce: ifce,
ip: ip,
cidrs: cidrs,
subnet: subnet,
}
n.prepare()