mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
[fix]Linux TProxy
This commit is contained in:
parent
a3ec549dbf
commit
934efb3d85
3
Makefile
3
Makefile
|
@ -47,6 +47,9 @@ linux-386:
|
|||
linux-amd64:
|
||||
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-arm64:
|
||||
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-armv5:
|
||||
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ package executor
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
|
@ -24,7 +21,6 @@ import (
|
|||
"github.com/Dreamacro/clash/dns"
|
||||
P "github.com/Dreamacro/clash/listener"
|
||||
authStore "github.com/Dreamacro/clash/listener/auth"
|
||||
"github.com/Dreamacro/clash/listener/tproxy"
|
||||
"github.com/Dreamacro/clash/listener/tun/dev"
|
||||
"github.com/Dreamacro/clash/log"
|
||||
"github.com/Dreamacro/clash/tunnel"
|
||||
|
@ -78,7 +74,7 @@ func ApplyConfig(cfg *config.Config, force bool) {
|
|||
updateRules(cfg.Rules, cfg.RuleProviders)
|
||||
updateHosts(cfg.Hosts)
|
||||
updateProfile(cfg)
|
||||
updateIPTables(cfg.DNS, cfg.General)
|
||||
//updateIPTables(cfg.DNS, cfg.General)
|
||||
updateDNS(cfg.DNS, cfg.General)
|
||||
updateGeneral(cfg.General, force)
|
||||
updateExperimental(cfg)
|
||||
|
@ -288,35 +284,35 @@ func patchSelectGroup(proxies map[string]C.Proxy) {
|
|||
}
|
||||
}
|
||||
|
||||
func updateIPTables(dns *config.DNS, general *config.General) {
|
||||
if runtime.GOOS != "linux" || dns.Listen == "" || general.TProxyPort == 0 || general.Tun.Enable {
|
||||
return
|
||||
}
|
||||
|
||||
_, dnsPortStr, err := net.SplitHostPort(dns.Listen)
|
||||
if dnsPortStr == "0" || dnsPortStr == "" || err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
dnsPort, err := strconv.Atoi(dnsPortStr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
tproxy.CleanUpTProxyLinuxIPTables()
|
||||
|
||||
err = tproxy.SetTProxyLinuxIPTables(general.Interface, general.TProxyPort, dnsPort)
|
||||
|
||||
if err != nil {
|
||||
log.Errorln("Can not setting iptables for TProxy on linux, %s", err.Error())
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
//func updateIPTables(dns *config.DNS, general *config.General) {
|
||||
// if runtime.GOOS != "linux" || dns.Listen == "" || general.TProxyPort == 0 || general.Tun.Enable {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// _, dnsPortStr, err := net.SplitHostPort(dns.Listen)
|
||||
// if dnsPortStr == "0" || dnsPortStr == "" || err != nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// dnsPort, err := strconv.Atoi(dnsPortStr)
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// tproxy.CleanUpTProxyLinuxIPTables()
|
||||
//
|
||||
// err = tproxy.SetTProxyLinuxIPTables(general.Interface, general.TProxyPort, dnsPort)
|
||||
//
|
||||
// if err != nil {
|
||||
// log.Errorln("Can not setting iptables for TProxy on linux, %s", err.Error())
|
||||
// os.Exit(2)
|
||||
// }
|
||||
//}
|
||||
|
||||
func CleanUp() {
|
||||
P.CleanUp()
|
||||
|
||||
if runtime.GOOS == "linux" {
|
||||
tproxy.CleanUpTProxyLinuxIPTables()
|
||||
}
|
||||
//if runtime.GOOS == "linux" {
|
||||
// tproxy.CleanUpTProxyLinuxIPTables()
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/clash/hub/executor"
|
||||
"github.com/Dreamacro/clash/transport/socks5"
|
||||
"github.com/Dreamacro/Clash.Meta/adapter/outbound"
|
||||
C "github.com/Dreamacro/Clash.Meta/constant"
|
||||
"github.com/Dreamacro/Clash.Meta/hub/executor"
|
||||
"github.com/Dreamacro/Clash.Meta/transport/socks5"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/client"
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/Clash.Meta/adapter/outbound"
|
||||
C "github.com/Dreamacro/Clash.Meta/constant"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
"github.com/Dreamacro/Clash.Meta/adapter/outbound"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/Clash.Meta/adapter/outbound"
|
||||
C "github.com/Dreamacro/Clash.Meta/constant"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/Clash.Meta/adapter/outbound"
|
||||
C "github.com/Dreamacro/Clash.Meta/constant"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/Clash.Meta/adapter/outbound"
|
||||
C "github.com/Dreamacro/Clash.Meta/constant"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
Loading…
Reference in New Issue
Block a user