mirror of https://github.com/bjdgyc/anylink.git
设置 gosysctl
This commit is contained in:
parent
e9622fa543
commit
13498fc125
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/bjdgyc/anylink/sessdata"
|
"github.com/bjdgyc/anylink/sessdata"
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
gosysctl "github.com/lorenzosaino/go-sysctl"
|
||||||
"github.com/songgao/packets/ethernet"
|
"github.com/songgao/packets/ethernet"
|
||||||
"github.com/songgao/water"
|
"github.com/songgao/water"
|
||||||
"github.com/songgao/water/waterutil"
|
"github.com/songgao/water/waterutil"
|
||||||
|
@ -88,8 +89,12 @@ func LinkTap(cSess *sessdata.ConnSession) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
// cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
||||||
execCmd([]string{cmdstr3})
|
// 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 allTapRead(ifce, cSess)
|
||||||
go allTapWrite(ifce, cSess)
|
go allTapWrite(ifce, cSess)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/bjdgyc/anylink/pkg/utils"
|
"github.com/bjdgyc/anylink/pkg/utils"
|
||||||
"github.com/bjdgyc/anylink/sessdata"
|
"github.com/bjdgyc/anylink/sessdata"
|
||||||
"github.com/coreos/go-iptables/iptables"
|
"github.com/coreos/go-iptables/iptables"
|
||||||
|
gosysctl "github.com/lorenzosaino/go-sysctl"
|
||||||
"github.com/songgao/water"
|
"github.com/songgao/water"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -100,8 +101,12 @@ func LinkTun(cSess *sessdata.ConnSession) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
// cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifce.Name())
|
||||||
execCmd([]string{cmdstr3})
|
// 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 tunRead(ifce, cSess)
|
||||||
go tunWrite(ifce, cSess)
|
go tunWrite(ifce, cSess)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/bjdgyc/anylink/base"
|
"github.com/bjdgyc/anylink/base"
|
||||||
"github.com/bjdgyc/anylink/pkg/utils"
|
"github.com/bjdgyc/anylink/pkg/utils"
|
||||||
"github.com/bjdgyc/anylink/sessdata"
|
"github.com/bjdgyc/anylink/sessdata"
|
||||||
|
gosysctl "github.com/lorenzosaino/go-sysctl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// link vtap
|
// link vtap
|
||||||
|
@ -64,8 +65,12 @@ func LinkMacvtap(cSess *sessdata.ConnSession) error {
|
||||||
base.Error(err)
|
base.Error(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifName)
|
// cmdstr3 := fmt.Sprintf("sysctl -w net.ipv6.conf.%s.disable_ipv6=1", ifName)
|
||||||
execCmd([]string{cmdstr3})
|
// 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)
|
return createVtap(cSess, ifName)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue