mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-11 18:59:17 +08:00
设置 gosysctl
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/bjdgyc/anylink/sessdata"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
gosysctl "github.com/lorenzosaino/go-sysctl"
|
||||
"github.com/songgao/packets/ethernet"
|
||||
"github.com/songgao/water"
|
||||
"github.com/songgao/water/waterutil"
|
||||
@@ -88,8 +89,12 @@ func LinkTap(cSess *sessdata.ConnSession) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
||||
execCmd([]string{cmdstr3})
|
||||
// cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
||||
// execCmd([]string{cmdstr3})
|
||||
err = gosysctl.Set(fmt.Sprintf("net.ipv6.conf.%s.disable_ipv6", ifce.Name()), "1")
|
||||
if err != nil {
|
||||
base.Warn(err)
|
||||
}
|
||||
|
||||
go allTapRead(ifce, cSess)
|
||||
go allTapWrite(ifce, cSess)
|
||||
|
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/bjdgyc/anylink/pkg/utils"
|
||||
"github.com/bjdgyc/anylink/sessdata"
|
||||
"github.com/coreos/go-iptables/iptables"
|
||||
gosysctl "github.com/lorenzosaino/go-sysctl"
|
||||
"github.com/songgao/water"
|
||||
)
|
||||
|
||||
@@ -100,8 +101,12 @@ func LinkTun(cSess *sessdata.ConnSession) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
||||
execCmd([]string{cmdstr3})
|
||||
// cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
||||
// execCmd([]string{cmdstr3})
|
||||
err = gosysctl.Set(fmt.Sprintf("net.ipv6.conf.%s.disable_ipv6", ifce.Name()), "1")
|
||||
if err != nil {
|
||||
base.Warn(err)
|
||||
}
|
||||
|
||||
go tunRead(ifce, cSess)
|
||||
go tunWrite(ifce, cSess)
|
||||
|
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/bjdgyc/anylink/base"
|
||||
"github.com/bjdgyc/anylink/pkg/utils"
|
||||
"github.com/bjdgyc/anylink/sessdata"
|
||||
gosysctl "github.com/lorenzosaino/go-sysctl"
|
||||
)
|
||||
|
||||
// link vtap
|
||||
@@ -64,8 +65,12 @@ func LinkMacvtap(cSess *sessdata.ConnSession) error {
|
||||
base.Error(err)
|
||||
return err
|
||||
}
|
||||
cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifName)
|
||||
execCmd([]string{cmdstr3})
|
||||
// cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifName)
|
||||
// execCmd([]string{cmdstr3})
|
||||
err = gosysctl.Set(fmt.Sprintf("net.ipv6.conf.%s.disable_ipv6", ifName), "1")
|
||||
if err != nil {
|
||||
base.Warn(err)
|
||||
}
|
||||
|
||||
return createVtap(cSess, ifName)
|
||||
}
|
||||
|
Reference in New Issue
Block a user