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