This commit is contained in:
gVisor bot 2021-12-04 17:41:13 +08:00
parent 934efb3d85
commit 165e7ccc76
5 changed files with 60 additions and 33 deletions

View file

@ -6,6 +6,11 @@ GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clas
-X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" \ -X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" \
-w -s -buildid=' -w -s -buildid='
GOBUILDOP=CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=$(VERSION)" \
-X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" \
-X "github.com/Dreamacro/clash/constant.OpenWrt:=true" \
-w -s -buildid='
PLATFORM_LIST = \ PLATFORM_LIST = \
darwin-amd64 \ darwin-amd64 \
darwin-arm64 \ darwin-arm64 \
@ -30,7 +35,7 @@ WINDOWS_ARCH_LIST = \
windows-amd64 \ windows-amd64 \
windows-arm32v7 windows-arm32v7
all: linux-amd64 darwin-amd64 windows-amd64 # Most used all: linux-arm64-openwrt linux-amd64-openwrt linux-arm64 linux-amd64 darwin-amd64 darwin-arm64 windows-amd64 windows-386 # Most used
docker: docker:
$(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
@ -47,21 +52,39 @@ linux-386:
linux-amd64: linux-amd64:
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-amd64-openwrt:
GOARCH=amd64 GOOS=linux $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
linux-arm64: linux-arm64:
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-arm64-openwrt:
GOARCH=arm64 GOOS=linux $(GOBUILDOP) -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)-$@
linux-armv5-openwrt:
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
linux-armv6: linux-armv6:
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-armv6-openwrt:
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
linux-armv7: linux-armv7:
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-armv7-openwrt:
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
linux-armv8: linux-armv8:
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-armv8-openwrt:
GOARCH=arm64 GOOS=linux $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
linux-mips-softfloat: linux-mips-softfloat:
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
@ -94,7 +117,7 @@ windows-386:
windows-amd64: windows-amd64:
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
windows-arm32v7: windows-arm32v7:
GOARCH=arm GOOS=windows GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe GOARCH=arm GOOS=windows GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe

View file

@ -4,4 +4,5 @@ var (
Meta = true Meta = true
Version = "1.8.0" Version = "1.8.0"
BuildTime = "unknown time" BuildTime = "unknown time"
OpenWrt bool
) )

View file

@ -2,7 +2,11 @@ package executor
import ( import (
"fmt" "fmt"
"github.com/Dreamacro/clash/listener/tproxy"
"net"
"os" "os"
"runtime"
"strconv"
"strings" "strings"
"sync" "sync"
@ -74,7 +78,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)
@ -284,35 +288,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 || C.OpenWrt {
// 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" && C.OpenWrt {
// tproxy.CleanUpTProxyLinuxIPTables() tproxy.CleanUpTProxyLinuxIPTables()
//} }
} }

View file

@ -20,7 +20,7 @@ var (
const ( const (
PROXY_FWMARK = "0x2d0" PROXY_FWMARK = "0x2d0"
PROXY_ROUTE_TABLE = "0x2d0" PROXY_ROUTE_TABLE = "0x2d0"
USERNAME = "clash" USERNAME = "Clash.Meta"
) )
func SetTProxyLinuxIPTables(ifname string, tport int, dport int) error { func SetTProxyLinuxIPTables(ifname string, tport int, dport int) error {

View file

@ -27,9 +27,8 @@ func (ps *Process) Match(metadata *C.Metadata) bool {
if metadata.Process != "" { if metadata.Process != "" {
return strings.EqualFold(metadata.Process, ps.process) return strings.EqualFold(metadata.Process, ps.process)
} }
// ignore match in proxy type "tproxy" // ignore match in proxy type "tproxy"
if metadata.Type == C.TPROXY { if metadata.Type == C.TPROXY || !C.OpenWrt {
return false return false
} }