Skip to content

Commit 8282a9a

Browse files
committed
Update core version
Update flutter version Optimize ip check Optimize url-test
1 parent dfa6d31 commit 8282a9a

File tree

19 files changed

+262
-136
lines changed

19 files changed

+262
-136
lines changed

.github/workflows/build.yaml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
- name: Setup Flutter
8787
uses: subosito/flutter-action@v2
8888
with:
89-
flutter-version: 3.22.x
89+
flutter-version: '3.x'
9090
channel: 'stable'
9191
cache: true
9292

@@ -108,6 +108,14 @@ jobs:
108108
permissions: write-all
109109
needs: [ build ]
110110
runs-on: ubuntu-latest
111+
services:
112+
telegram-bot-api:
113+
image: aiogram/telegram-bot-api:latest
114+
env:
115+
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
116+
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
117+
ports:
118+
- 8081:8081
111119
steps:
112120
- name: Checkout
113121
uses: actions/checkout@v4
@@ -121,12 +129,10 @@ jobs:
121129
pattern: artifact-*
122130
merge-multiple: true
123131

124-
- name: Generate release
132+
- name: Generate release.md
125133
run: |
126134
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
127135
preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
128-
version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
129-
sed "s|VERSION|$version|g" ./.github/release_template.md > release.md
130136
currentTag=""
131137
for ((i = 0; i <= ${#tags[@]}; i++)); do
132138
if (( i < ${#tags[@]} )); then
@@ -140,8 +146,6 @@ jobs:
140146
fi
141147
fi
142148
if [ -n "$currentTag" ]; then
143-
echo "## $currentTag" >> release.md
144-
echo "" >> release.md
145149
if [ -n "$tag" ]; then
146150
git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
147151
else
@@ -152,14 +156,19 @@ jobs:
152156
currentTag=$tag
153157
done
154158
155-
- name: Upload
156-
if: ${{ contains(github.ref, '+') }}
157-
uses: actions/upload-artifact@v4
158-
with:
159-
name: artifact
160-
path: ./dist
161-
retention-days: 7
162-
overwrite: true
159+
- name: Push to telegram
160+
env:
161+
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
162+
TAG: ${{ github.ref_name }}
163+
run: |
164+
python -m pip install --upgrade pip
165+
pip install requests
166+
python release.py
167+
168+
- name: Patch release.md
169+
run: |
170+
version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
171+
sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md
163172
164173
- name: Release
165174
if: ${{ !contains(github.ref, '+') }}

android/app/src/main/kotlin/com/follow/clash/MainActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.follow.clash
22

33

4-
import android.content.Intent
5-
import android.os.Bundle
64
import com.follow.clash.plugins.AppPlugin
75
import com.follow.clash.plugins.ServicePlugin
86
import com.follow.clash.plugins.VpnPlugin

core/Clash.Meta

Submodule Clash.Meta updated 110 files

core/common.go

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import (
55
"context"
66
"core/state"
77
"errors"
8+
"fmt"
89
"github.com/metacubex/mihomo/constant/features"
910
"github.com/metacubex/mihomo/hub/route"
10-
"math"
11+
"github.com/samber/lo"
1112
"os"
1213
"os/exec"
1314
"path/filepath"
1415
"runtime"
16+
"strings"
1517
"sync"
1618
"syscall"
1719
"time"
@@ -155,6 +157,14 @@ func getRawConfigWithId(id string) *config.RawConfig {
155157
continue
156158
}
157159
mapping["path"] = filepath.Join(getProfileProvidersPath(id), value)
160+
if configParams.TestURL != nil {
161+
hc := mapping["health-check"].(map[string]any)
162+
if hc != nil {
163+
if hc["url"] != nil {
164+
hc["url"] = *configParams.TestURL
165+
}
166+
}
167+
}
158168
}
159169
for _, mapping := range prof.RuleProvider {
160170
value, exist := mapping["path"].(string)
@@ -212,16 +222,16 @@ func sideUpdateExternalProvider(p cp.Provider, bytes []byte) error {
212222
switch p.(type) {
213223
case *provider.ProxySetProvider:
214224
psp := p.(*provider.ProxySetProvider)
215-
elm, same, err := psp.SideUpdate(bytes)
216-
if err == nil && !same {
217-
psp.OnUpdate(elm)
225+
_, _, err := psp.SideUpdate(bytes)
226+
if err == nil {
227+
return err
218228
}
219229
return nil
220230
case rp.RuleSetProvider:
221231
rsp := p.(*rp.RuleSetProvider)
222-
elm, same, err := rsp.SideUpdate(bytes)
223-
if err == nil && !same {
224-
rsp.OnUpdate(elm)
232+
_, _, err := rsp.SideUpdate(bytes)
233+
if err == nil {
234+
return err
225235
}
226236
return nil
227237
default:
@@ -387,6 +397,37 @@ func genHosts(hosts, patchHosts map[string]any) {
387397
}
388398
}
389399

400+
func trimArr(arr []string) (r []string) {
401+
for _, e := range arr {
402+
r = append(r, strings.Trim(e, " "))
403+
}
404+
return
405+
}
406+
407+
var ips = []string{"ipinfo.io", "ipapi.co", "api.ip.sb", "ipwho.is"}
408+
409+
func overrideRules(rules *[]string) {
410+
var target = ""
411+
for _, line := range *rules {
412+
rule := trimArr(strings.Split(line, ","))
413+
l := len(rule)
414+
if l != 2 {
415+
return
416+
}
417+
if strings.ToUpper(rule[0]) == "MATCH" {
418+
target = rule[1]
419+
break
420+
}
421+
}
422+
if target == "" {
423+
return
424+
}
425+
var rulesExt = lo.Map(ips, func(ip string, index int) string {
426+
return fmt.Sprintf("DOMAIN %s %s", ip, target)
427+
})
428+
*rules = append(rulesExt, *rules...)
429+
}
430+
390431
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig) {
391432
targetConfig.ExternalController = patchConfig.ExternalController
392433
targetConfig.ExternalUI = ""
@@ -425,6 +466,7 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
425466
targetConfig.DNS.Enable = true
426467
}
427468
}
469+
overrideRules(&targetConfig.Rule)
428470
//if runtime.GOOS == "android" {
429471
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder)
430472
//} else if runtime.GOOS == "windows" {
@@ -437,9 +479,8 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi
437479
//}
438480
}
439481

440-
func patchConfig(general *config.General, controller *config.Controller) {
482+
func patchConfig(general *config.General, controller *config.Controller, tls *config.TLS) {
441483
log.Infoln("[Apply] patch")
442-
route.ReStartServer(controller.ExternalController)
443484
tunnel.SetSniffing(general.Sniffing)
444485
tunnel.SetFindProcessMode(general.FindProcessMode)
445486
dialer.SetTcpConcurrent(general.TCPConcurrent)
@@ -448,6 +489,22 @@ func patchConfig(general *config.General, controller *config.Controller) {
448489
tunnel.SetMode(general.Mode)
449490
log.SetLevel(general.LogLevel)
450491
resolver.DisableIPv6 = !general.IPv6
492+
493+
route.ReCreateServer(&route.Config{
494+
Addr: controller.ExternalController,
495+
TLSAddr: controller.ExternalControllerTLS,
496+
UnixAddr: controller.ExternalControllerUnix,
497+
PipeAddr: controller.ExternalControllerPipe,
498+
Secret: controller.Secret,
499+
Certificate: tls.Certificate,
500+
PrivateKey: tls.PrivateKey,
501+
DohServer: controller.ExternalDohServer,
502+
IsDebug: false,
503+
Cors: route.Cors{
504+
AllowOrigins: controller.Cors.AllowOrigins,
505+
AllowPrivateNetwork: controller.Cors.AllowPrivateNetwork,
506+
},
507+
})
451508
}
452509

453510
var isRunning = false
@@ -460,6 +517,7 @@ func updateListeners(general *config.General, listeners map[string]constant.Inbo
460517
}
461518
runLock.Lock()
462519
defer runLock.Unlock()
520+
stopListeners()
463521
listener.PatchInboundListeners(listeners, tunnel.Tunnel, true)
464522
listener.SetAllowLan(general.AllowLan)
465523
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
@@ -483,27 +541,6 @@ func stopListeners() {
483541
listener.StopListener()
484542
}
485543

486-
func hcCompatibleProvider(proxyProviders map[string]cp.ProxyProvider) {
487-
wg := sync.WaitGroup{}
488-
ch := make(chan struct{}, math.MaxInt)
489-
for _, proxyProvider := range proxyProviders {
490-
proxyProvider := proxyProvider
491-
if proxyProvider.VehicleType() == cp.Compatible {
492-
log.Infoln("Start initial Compatible provider %s", proxyProvider.Name())
493-
wg.Add(1)
494-
ch <- struct{}{}
495-
go func() {
496-
defer func() { <-ch; wg.Done() }()
497-
if err := proxyProvider.Initial(); err != nil {
498-
log.Errorln("initial Compatible provider %s error: %v", proxyProvider.Name(), err)
499-
}
500-
}()
501-
}
502-
503-
}
504-
505-
}
506-
507544
func patchSelectGroup() {
508545
mapping := configParams.SelectedMap
509546
if mapping == nil {
@@ -535,17 +572,14 @@ func applyConfig() error {
535572
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
536573
}
537574
if configParams.IsPatch {
538-
patchConfig(cfg.General, cfg.Controller)
575+
patchConfig(cfg.General, cfg.Controller, cfg.TLS)
539576
} else {
540577
closeConnections()
541578
runtime.GC()
542-
hub.UltraApplyConfig(cfg)
579+
hub.ApplyConfig(cfg)
543580
patchSelectGroup()
544581
}
545582
updateListeners(cfg.General, cfg.Listeners)
546-
if isRunning {
547-
hcCompatibleProvider(cfg.Providers)
548-
}
549583
externalProviders = getExternalProvidersRaw()
550584
return err
551585
}

core/go.mod

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ replace github.com/metacubex/mihomo => ./Clash.Meta
66

77
require github.com/metacubex/mihomo v1.17.1
88

9+
require (
10+
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab // indirect
11+
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 // indirect
12+
github.com/sagernet/cors v1.2.1 // indirect
13+
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
14+
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
15+
)
16+
917
replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297
1018

1119
require (
@@ -17,7 +25,7 @@ require (
1725
github.com/bahlo/generic-list-go v0.2.0 // indirect
1826
github.com/buger/jsonparser v1.1.1 // indirect
1927
github.com/cloudflare/circl v1.3.7 // indirect
20-
github.com/coreos/go-iptables v0.7.0 // indirect
28+
github.com/coreos/go-iptables v0.8.0 // indirect
2129
github.com/dlclark/regexp2 v1.11.4 // indirect
2230
github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9 // indirect
2331
github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 // indirect
@@ -26,7 +34,6 @@ require (
2634
github.com/fsnotify/fsnotify v1.7.0 // indirect
2735
github.com/gaukas/godicttls v0.0.4 // indirect
2836
github.com/go-chi/chi/v5 v5.1.0 // indirect
29-
github.com/go-chi/cors v1.2.1 // indirect
3037
github.com/go-chi/render v1.0.3 // indirect
3138
github.com/go-ole/go-ole v1.3.0 // indirect
3239
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
@@ -38,7 +45,7 @@ require (
3845
github.com/google/go-cmp v0.6.0 // indirect
3946
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
4047
github.com/hashicorp/yamux v0.1.1 // indirect
41-
github.com/insomniacslk/dhcp v0.0.0-20240812123929-b105c29bd1b5 // indirect
48+
github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475 // indirect
4249
github.com/josharian/native v1.1.0 // indirect
4350
github.com/klauspost/compress v1.17.9 // indirect
4451
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
@@ -58,8 +65,8 @@ require (
5865
github.com/metacubex/sing-shadowsocks2 v0.2.2 // indirect
5966
github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 // indirect
6067
github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 // indirect
61-
github.com/metacubex/sing-wireguard v0.0.0-20240826061955-1e4e67afe5cd // indirect
62-
github.com/metacubex/tfo-go v0.0.0-20240830120620-c5e019b67785 // indirect
68+
github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 // indirect
69+
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa // indirect
6370
github.com/metacubex/utls v1.6.6 // indirect
6471
github.com/miekg/dns v1.1.62 // indirect
6572
github.com/mroth/weightedrand/v2 v2.1.0 // indirect
@@ -79,8 +86,7 @@ require (
7986
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect
8087
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
8188
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
82-
github.com/sagernet/wireguard-go v0.0.0-20231209092712-9a439356a62e // indirect
83-
github.com/samber/lo v1.47.0 // indirect
89+
github.com/samber/lo v1.47.0
8490
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
8591
github.com/shoenig/go-m1cpu v0.1.6 // indirect
8692
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b // indirect
@@ -97,13 +103,13 @@ require (
97103
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
98104
go.uber.org/mock v0.4.0 // indirect
99105
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
100-
golang.org/x/crypto v0.26.0 // indirect
101-
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
106+
golang.org/x/crypto v0.28.0 // indirect
107+
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
102108
golang.org/x/mod v0.20.0 // indirect
103-
golang.org/x/net v0.28.0 // indirect
109+
golang.org/x/net v0.30.0 // indirect
104110
golang.org/x/sync v0.8.0 // indirect
105-
golang.org/x/sys v0.24.0 // indirect
106-
golang.org/x/text v0.17.0 // indirect
111+
golang.org/x/sys v0.26.0 // indirect
112+
golang.org/x/text v0.19.0 // indirect
107113
golang.org/x/time v0.5.0 // indirect
108114
golang.org/x/tools v0.24.0 // indirect
109115
google.golang.org/protobuf v1.34.2 // indirect

0 commit comments

Comments
 (0)