[Fix] Linux Tun
This commit is contained in:
parent
a06382cebc
commit
013b839678
1 changed files with 20 additions and 20 deletions
|
@ -22,36 +22,36 @@ type TunDevice interface {
|
||||||
func SetLinuxAutoRoute() {
|
func SetLinuxAutoRoute() {
|
||||||
log.Infoln("Tun adapter auto setting global route")
|
log.Infoln("Tun adapter auto setting global route")
|
||||||
addLinuxSystemRoute("0")
|
addLinuxSystemRoute("0")
|
||||||
addLinuxSystemRoute("1")
|
//addLinuxSystemRoute("1")
|
||||||
addLinuxSystemRoute("2/7")
|
//addLinuxSystemRoute("2/7")
|
||||||
addLinuxSystemRoute("4/6")
|
//addLinuxSystemRoute("4/6")
|
||||||
addLinuxSystemRoute("8/5")
|
//addLinuxSystemRoute("8/5")
|
||||||
addLinuxSystemRoute("16/4")
|
//addLinuxSystemRoute("16/4")
|
||||||
addLinuxSystemRoute("32/3")
|
//addLinuxSystemRoute("32/3")
|
||||||
addLinuxSystemRoute("64/2")
|
//addLinuxSystemRoute("64/2")
|
||||||
addLinuxSystemRoute("128.0/1")
|
//addLinuxSystemRoute("128.0/1")
|
||||||
addLinuxSystemRoute("198.18.0/16")
|
//addLinuxSystemRoute("198.18.0/16")
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveLinuxAutoRoute() {
|
func RemoveLinuxAutoRoute() {
|
||||||
log.Infoln("Tun adapter removing global route")
|
log.Infoln("Tun adapter removing global route")
|
||||||
delLinuxSystemRoute("0")
|
delLinuxSystemRoute("0")
|
||||||
delLinuxSystemRoute("1")
|
//delLinuxSystemRoute("1")
|
||||||
delLinuxSystemRoute("2/7")
|
//delLinuxSystemRoute("2/7")
|
||||||
delLinuxSystemRoute("4/6")
|
//delLinuxSystemRoute("4/6")
|
||||||
delLinuxSystemRoute("8/5")
|
//delLinuxSystemRoute("8/5")
|
||||||
delLinuxSystemRoute("16/4")
|
//delLinuxSystemRoute("16/4")
|
||||||
delLinuxSystemRoute("32/3")
|
//delLinuxSystemRoute("32/3")
|
||||||
delLinuxSystemRoute("64/2")
|
//delLinuxSystemRoute("64/2")
|
||||||
delLinuxSystemRoute("128.0/1")
|
//delLinuxSystemRoute("128.0/1")
|
||||||
delLinuxSystemRoute("198.18.0/16")
|
//delLinuxSystemRoute("198.18.0/16")
|
||||||
}
|
}
|
||||||
|
|
||||||
func addLinuxSystemRoute(net string) {
|
func addLinuxSystemRoute(net string) {
|
||||||
if runtime.GOOS != "darwin" && runtime.GOOS != "linux" {
|
if runtime.GOOS != "darwin" && runtime.GOOS != "linux" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cmd := exec.Command("route", "add", "-net", net, "198.18.0.1")
|
cmd := exec.Command("route", "add", "-net", net, "meta")
|
||||||
var stderr bytes.Buffer
|
var stderr bytes.Buffer
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
|
@ -63,7 +63,7 @@ func delLinuxSystemRoute(net string) {
|
||||||
if runtime.GOOS != "darwin" && runtime.GOOS != "linux" {
|
if runtime.GOOS != "darwin" && runtime.GOOS != "linux" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cmd := exec.Command("route", "delete", "-net", net, "198.18.0.1")
|
cmd := exec.Command("route", "delete", "-net", net, "meta")
|
||||||
_ = cmd.Run()
|
_ = cmd.Run()
|
||||||
//if err := cmd.Run(); err != nil {
|
//if err := cmd.Run(); err != nil {
|
||||||
// log.Errorln("[auto route]Failed to delete system route: %s, cmd: %s", err.Error(), cmd.String())
|
// log.Errorln("[auto route]Failed to delete system route: %s, cmd: %s", err.Error(), cmd.String())
|
||||||
|
|
Loading…
Reference in a new issue