[style]
This commit is contained in:
parent
58552447ef
commit
8580ee8898
5 changed files with 60 additions and 33 deletions
25
Makefile
25
Makefile
|
@ -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)" \
|
||||
-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 = \
|
||||
darwin-amd64 \
|
||||
darwin-arm64 \
|
||||
|
@ -30,7 +35,7 @@ WINDOWS_ARCH_LIST = \
|
|||
windows-amd64 \
|
||||
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:
|
||||
$(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
@ -47,21 +52,39 @@ linux-386:
|
|||
linux-amd64:
|
||||
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-amd64-openwrt:
|
||||
GOARCH=amd64 GOOS=linux $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-arm64:
|
||||
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-arm64-openwrt:
|
||||
GOARCH=arm64 GOOS=linux $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-armv5:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-armv8-openwrt:
|
||||
GOARCH=arm64 GOOS=linux $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
linux-mips-softfloat:
|
||||
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||
|
||||
|
|
|
@ -4,4 +4,5 @@ var (
|
|||
Meta = true
|
||||
Version = "1.8.0"
|
||||
BuildTime = "unknown time"
|
||||
OpenWrt bool
|
||||
)
|
||||
|
|
|
@ -2,7 +2,11 @@ package executor
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Dreamacro/clash/listener/tproxy"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
|
@ -74,7 +78,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)
|
||||
|
@ -284,35 +288,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 || C.OpenWrt {
|
||||
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" && C.OpenWrt {
|
||||
tproxy.CleanUpTProxyLinuxIPTables()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ var (
|
|||
const (
|
||||
PROXY_FWMARK = "0x2d0"
|
||||
PROXY_ROUTE_TABLE = "0x2d0"
|
||||
USERNAME = "clash"
|
||||
USERNAME = "Clash.Meta"
|
||||
)
|
||||
|
||||
func SetTProxyLinuxIPTables(ifname string, tport int, dport int) error {
|
|
@ -27,9 +27,8 @@ func (ps *Process) Match(metadata *C.Metadata) bool {
|
|||
if metadata.Process != "" {
|
||||
return strings.EqualFold(metadata.Process, ps.process)
|
||||
}
|
||||
|
||||
// ignore match in proxy type "tproxy"
|
||||
if metadata.Type == C.TPROXY {
|
||||
if metadata.Type == C.TPROXY || !C.OpenWrt {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue