From 8282a9a474947488ab7102be8b092111fdba399b Mon Sep 17 00:00:00 2001 From: chen08209 Date: Mon, 14 Oct 2024 10:03:23 +0800 Subject: [PATCH] Update core version Update flutter version Optimize ip check Optimize url-test --- .github/workflows/build.yaml | 37 ++++--- .../kotlin/com/follow/clash/MainActivity.kt | 2 - core/Clash.Meta | 2 +- core/common.go | 104 ++++++++++++------ core/go.mod | 30 +++-- core/go.sum | 54 +++++---- lib/common/common.dart | 3 +- lib/common/font.dart | 3 + lib/common/measure.dart | 4 +- lib/common/other.dart | 17 +-- lib/controller.dart | 15 ++- .../dashboard/network_detection.dart | 2 +- lib/manager/clash_manager.dart | 5 +- lib/manager/window_manager.dart | 2 +- lib/widgets/text.dart | 3 +- pubspec.lock | 24 ++-- pubspec.yaml | 2 +- release.py | 59 ++++++++++ setup.dart | 30 ++--- 19 files changed, 262 insertions(+), 136 deletions(-) create mode 100644 lib/common/font.dart create mode 100644 release.py diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1dd2461a..5dff1fcb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -86,7 +86,7 @@ jobs: - name: Setup Flutter uses: subosito/flutter-action@v2 with: - flutter-version: 3.22.x + flutter-version: '3.x' channel: 'stable' cache: true @@ -108,6 +108,14 @@ jobs: permissions: write-all needs: [ build ] runs-on: ubuntu-latest + services: + telegram-bot-api: + image: aiogram/telegram-bot-api:latest + env: + TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }} + TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }} + ports: + - 8081:8081 steps: - name: Checkout uses: actions/checkout@v4 @@ -121,12 +129,10 @@ jobs: pattern: artifact-* merge-multiple: true - - name: Generate release + - name: Generate release.md run: | tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate)) preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "") - version=$(echo "${{ github.ref_name }}" | sed 's/^v//') - sed "s|VERSION|$version|g" ./.github/release_template.md > release.md currentTag="" for ((i = 0; i <= ${#tags[@]}; i++)); do if (( i < ${#tags[@]} )); then @@ -140,8 +146,6 @@ jobs: fi fi if [ -n "$currentTag" ]; then - echo "## $currentTag" >> release.md - echo "" >> release.md if [ -n "$tag" ]; then git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md else @@ -152,14 +156,19 @@ jobs: currentTag=$tag done - - name: Upload - if: ${{ contains(github.ref, '+') }} - uses: actions/upload-artifact@v4 - with: - name: artifact - path: ./dist - retention-days: 7 - overwrite: true + - name: Push to telegram + env: + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} + TAG: ${{ github.ref_name }} + run: | + python -m pip install --upgrade pip + pip install requests + python release.py + + - name: Patch release.md + run: | + version=$(echo "${{ github.ref_name }}" | sed 's/^v//') + sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md - name: Release if: ${{ !contains(github.ref, '+') }} diff --git a/android/app/src/main/kotlin/com/follow/clash/MainActivity.kt b/android/app/src/main/kotlin/com/follow/clash/MainActivity.kt index ee12d5a0..388379b6 100644 --- a/android/app/src/main/kotlin/com/follow/clash/MainActivity.kt +++ b/android/app/src/main/kotlin/com/follow/clash/MainActivity.kt @@ -1,8 +1,6 @@ package com.follow.clash -import android.content.Intent -import android.os.Bundle import com.follow.clash.plugins.AppPlugin import com.follow.clash.plugins.ServicePlugin import com.follow.clash.plugins.VpnPlugin diff --git a/core/Clash.Meta b/core/Clash.Meta index e8956991..8472840f 160000 --- a/core/Clash.Meta +++ b/core/Clash.Meta @@ -1 +1 @@ -Subproject commit e89569916a07bd0cac0899fb41252dd59ad4a26e +Subproject commit 8472840f4719e59f9f41cfab2643bf73bb9d5799 diff --git a/core/common.go b/core/common.go index 3ecf1522..66e593fb 100644 --- a/core/common.go +++ b/core/common.go @@ -5,13 +5,15 @@ import ( "context" "core/state" "errors" + "fmt" "github.com/metacubex/mihomo/constant/features" "github.com/metacubex/mihomo/hub/route" - "math" + "github.com/samber/lo" "os" "os/exec" "path/filepath" "runtime" + "strings" "sync" "syscall" "time" @@ -155,6 +157,14 @@ func getRawConfigWithId(id string) *config.RawConfig { continue } mapping["path"] = filepath.Join(getProfileProvidersPath(id), value) + if configParams.TestURL != nil { + hc := mapping["health-check"].(map[string]any) + if hc != nil { + if hc["url"] != nil { + hc["url"] = *configParams.TestURL + } + } + } } for _, mapping := range prof.RuleProvider { value, exist := mapping["path"].(string) @@ -212,16 +222,16 @@ func sideUpdateExternalProvider(p cp.Provider, bytes []byte) error { switch p.(type) { case *provider.ProxySetProvider: psp := p.(*provider.ProxySetProvider) - elm, same, err := psp.SideUpdate(bytes) - if err == nil && !same { - psp.OnUpdate(elm) + _, _, err := psp.SideUpdate(bytes) + if err == nil { + return err } return nil case rp.RuleSetProvider: rsp := p.(*rp.RuleSetProvider) - elm, same, err := rsp.SideUpdate(bytes) - if err == nil && !same { - rsp.OnUpdate(elm) + _, _, err := rsp.SideUpdate(bytes) + if err == nil { + return err } return nil default: @@ -387,6 +397,37 @@ func genHosts(hosts, patchHosts map[string]any) { } } +func trimArr(arr []string) (r []string) { + for _, e := range arr { + r = append(r, strings.Trim(e, " ")) + } + return +} + +var ips = []string{"ipinfo.io", "ipapi.co", "api.ip.sb", "ipwho.is"} + +func overrideRules(rules *[]string) { + var target = "" + for _, line := range *rules { + rule := trimArr(strings.Split(line, ",")) + l := len(rule) + if l != 2 { + return + } + if strings.ToUpper(rule[0]) == "MATCH" { + target = rule[1] + break + } + } + if target == "" { + return + } + var rulesExt = lo.Map(ips, func(ip string, index int) string { + return fmt.Sprintf("DOMAIN %s %s", ip, target) + }) + *rules = append(rulesExt, *rules...) +} + func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig) { targetConfig.ExternalController = patchConfig.ExternalController targetConfig.ExternalUI = "" @@ -425,6 +466,7 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi targetConfig.DNS.Enable = true } } + overrideRules(&targetConfig.Rule) //if runtime.GOOS == "android" { // targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder) //} else if runtime.GOOS == "windows" { @@ -437,9 +479,8 @@ func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfi //} } -func patchConfig(general *config.General, controller *config.Controller) { +func patchConfig(general *config.General, controller *config.Controller, tls *config.TLS) { log.Infoln("[Apply] patch") - route.ReStartServer(controller.ExternalController) tunnel.SetSniffing(general.Sniffing) tunnel.SetFindProcessMode(general.FindProcessMode) dialer.SetTcpConcurrent(general.TCPConcurrent) @@ -448,6 +489,22 @@ func patchConfig(general *config.General, controller *config.Controller) { tunnel.SetMode(general.Mode) log.SetLevel(general.LogLevel) resolver.DisableIPv6 = !general.IPv6 + + route.ReCreateServer(&route.Config{ + Addr: controller.ExternalController, + TLSAddr: controller.ExternalControllerTLS, + UnixAddr: controller.ExternalControllerUnix, + PipeAddr: controller.ExternalControllerPipe, + Secret: controller.Secret, + Certificate: tls.Certificate, + PrivateKey: tls.PrivateKey, + DohServer: controller.ExternalDohServer, + IsDebug: false, + Cors: route.Cors{ + AllowOrigins: controller.Cors.AllowOrigins, + AllowPrivateNetwork: controller.Cors.AllowPrivateNetwork, + }, + }) } var isRunning = false @@ -460,6 +517,7 @@ func updateListeners(general *config.General, listeners map[string]constant.Inbo } runLock.Lock() defer runLock.Unlock() + stopListeners() listener.PatchInboundListeners(listeners, tunnel.Tunnel, true) listener.SetAllowLan(general.AllowLan) inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes) @@ -483,27 +541,6 @@ func stopListeners() { listener.StopListener() } -func hcCompatibleProvider(proxyProviders map[string]cp.ProxyProvider) { - wg := sync.WaitGroup{} - ch := make(chan struct{}, math.MaxInt) - for _, proxyProvider := range proxyProviders { - proxyProvider := proxyProvider - if proxyProvider.VehicleType() == cp.Compatible { - log.Infoln("Start initial Compatible provider %s", proxyProvider.Name()) - wg.Add(1) - ch <- struct{}{} - go func() { - defer func() { <-ch; wg.Done() }() - if err := proxyProvider.Initial(); err != nil { - log.Errorln("initial Compatible provider %s error: %v", proxyProvider.Name(), err) - } - }() - } - - } - -} - func patchSelectGroup() { mapping := configParams.SelectedMap if mapping == nil { @@ -535,17 +572,14 @@ func applyConfig() error { cfg, _ = config.ParseRawConfig(config.DefaultRawConfig()) } if configParams.IsPatch { - patchConfig(cfg.General, cfg.Controller) + patchConfig(cfg.General, cfg.Controller, cfg.TLS) } else { closeConnections() runtime.GC() - hub.UltraApplyConfig(cfg) + hub.ApplyConfig(cfg) patchSelectGroup() } updateListeners(cfg.General, cfg.Listeners) - if isRunning { - hcCompatibleProvider(cfg.Providers) - } externalProviders = getExternalProvidersRaw() return err } diff --git a/core/go.mod b/core/go.mod index a265e6a3..be6f6a40 100644 --- a/core/go.mod +++ b/core/go.mod @@ -6,6 +6,14 @@ replace github.com/metacubex/mihomo => ./Clash.Meta require github.com/metacubex/mihomo v1.17.1 +require ( + github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab // indirect + github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 // indirect + github.com/sagernet/cors v1.2.1 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect +) + replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 require ( @@ -17,7 +25,7 @@ require ( github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/coreos/go-iptables v0.7.0 // indirect + github.com/coreos/go-iptables v0.8.0 // indirect github.com/dlclark/regexp2 v1.11.4 // indirect github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9 // indirect github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 // indirect @@ -26,7 +34,6 @@ require ( github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gaukas/godicttls v0.0.4 // indirect github.com/go-chi/chi/v5 v5.1.0 // indirect - github.com/go-chi/cors v1.2.1 // indirect github.com/go-chi/render v1.0.3 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect @@ -38,7 +45,7 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect github.com/hashicorp/yamux v0.1.1 // indirect - github.com/insomniacslk/dhcp v0.0.0-20240812123929-b105c29bd1b5 // indirect + github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475 // indirect github.com/josharian/native v1.1.0 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect @@ -58,8 +65,8 @@ require ( github.com/metacubex/sing-shadowsocks2 v0.2.2 // indirect github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 // indirect github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 // indirect - github.com/metacubex/sing-wireguard v0.0.0-20240826061955-1e4e67afe5cd // indirect - github.com/metacubex/tfo-go v0.0.0-20240830120620-c5e019b67785 // indirect + github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 // indirect + github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa // indirect github.com/metacubex/utls v1.6.6 // indirect github.com/miekg/dns v1.1.62 // indirect github.com/mroth/weightedrand/v2 v2.1.0 // indirect @@ -79,8 +86,7 @@ require ( github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect github.com/sagernet/sing-shadowtls v0.1.4 // indirect github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect - github.com/sagernet/wireguard-go v0.0.0-20231209092712-9a439356a62e // indirect - github.com/samber/lo v1.47.0 // indirect + github.com/samber/lo v1.47.0 github.com/shirou/gopsutil/v3 v3.24.5 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b // indirect @@ -97,13 +103,13 @@ require ( gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect go.uber.org/mock v0.4.0 // indirect go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect - golang.org/x/crypto v0.26.0 // indirect - golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect golang.org/x/mod v0.20.0 // indirect - golang.org/x/net v0.28.0 // indirect + golang.org/x/net v0.30.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/core/go.sum b/core/go.sum index 18840e68..9b517063 100644 --- a/core/go.sum +++ b/core/go.sum @@ -19,8 +19,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/coreos/go-iptables v0.7.0 h1:XWM3V+MPRr5/q51NuWSgU0fqMad64Zyxs8ZUoMsamr8= -github.com/coreos/go-iptables v0.7.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q= +github.com/coreos/go-iptables v0.8.0 h1:MPc2P89IhuVpLI7ETL/2tx3XZ61VeICZjYqDEgNsPRc= +github.com/coreos/go-iptables v0.8.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -42,8 +42,6 @@ github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXb github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI= github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= -github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= -github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4= github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= @@ -76,8 +74,8 @@ github.com/google/tink/go v1.6.1/go.mod h1:IGW53kTgag+st5yPhKKwJ6u2l+SSp5/v9XF7s github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/insomniacslk/dhcp v0.0.0-20240812123929-b105c29bd1b5 h1:GkMacU5ftc+IEg1449N3UEy2XLDz58W4fkrRu2fibb8= -github.com/insomniacslk/dhcp v0.0.0-20240812123929-b105c29bd1b5/go.mod h1:KclMyHxX06VrVr0DJmeFSUb1ankt7xTfoOA35pCkoic= +github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475 h1:hxST5pwMBEOWmxpkX20w9oZG+hXdhKmAIPQ3NGGAxas= +github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475/go.mod h1:KclMyHxX06VrVr0DJmeFSUb1ankt7xTfoOA35pCkoic= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA= @@ -96,6 +94,8 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/ github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw= github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= +github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab h1:Chbw+/31UC14YFNr78pESt5Vowlc62zziw05JCUqoL4= +github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab/go.mod h1:xVKK8jC5Sd3hfh7WjmCq+HorehIbrBijaUWmcuKjPcI= github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399 h1:oBowHVKZycNtAFbZ6avaCSZJYeme2Nrj+4RpV2cNJig= github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399/go.mod h1:4xcieuIK+M4bGQmQYZVqEaIYqjS1ahO4kXG7EmDgEro= github.com/metacubex/chacha v0.1.0 h1:tg9RSJ18NvL38cCWNyYH1eiG6qDCyyXIaTLQthon0sc= @@ -120,12 +120,14 @@ github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 h1:ypfofGDZbP github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1/go.mod h1:olbEx9yVcaw5tHTNlRamRoxmMKcvDvcVS1YLnQGzvWE= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 h1:OAXiCosqY8xKDp3pqTW3qbrCprZ1l6WkrXSFSCwyY4I= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY= -github.com/metacubex/sing-wireguard v0.0.0-20240826061955-1e4e67afe5cd h1:r7alry8u4qlUFLNMwGvG1A8ZcfPM6AMSmrm6E2yKdB4= -github.com/metacubex/sing-wireguard v0.0.0-20240826061955-1e4e67afe5cd/go.mod h1:uY+BYb0UEknLrqvbGcwi9i++KgrKxsurysgI6G1Pveo= -github.com/metacubex/tfo-go v0.0.0-20240830120620-c5e019b67785 h1:NNmI+ZV0DzNuqaAInRQuZFLHlWVuyHeow8jYpdKjHjo= -github.com/metacubex/tfo-go v0.0.0-20240830120620-c5e019b67785/go.mod h1:c7bVFM9f5+VzeZ/6Kg77T/jrg1Xp8QpqlSHvG/aXVts= +github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 h1:xg71VmzLS6ByAzi/57phwDvjE+dLLs+ozH00k4DnOns= +github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3/go.mod h1:6nitcmzPDL3MXnLdhu6Hm126Zk4S1fBbX3P7jxUxSFw= +github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa h1:9mcjV+RGZVC3reJBNDjjNPyS8PmFG97zq56X7WNaFO4= +github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa/go.mod h1:4tLB5c8U0CxpkFM+AJJB77jEaVDbLH5XQvy42vAGsWw= github.com/metacubex/utls v1.6.6 h1:3D12YKHTf2Z41UPhQU2dWerNWJ5TVQD9gKoQ+H+iLC8= github.com/metacubex/utls v1.6.6/go.mod h1:+WLFUnXjcpdxXCnyX25nggw8C6YonZ8zOK2Zm/oRvdo= +github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 h1:hJLQviGySBuaynlCwf/oYgIxbVbGRUIKZCxdya9YrbQ= +github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181/go.mod h1:phewKljNYiTVT31Gcif8RiCKnTUOgVWFJjccqYM8s+Y= github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= github.com/mroth/weightedrand/v2 v2.1.0 h1:o1ascnB1CIVzsqlfArQQjeMy1U0NcIbBO5rfd5E/OeU= @@ -156,6 +158,8 @@ github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs= github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/sagernet/cors v1.2.1 h1:Cv5Z8y9YSD6Gm+qSpNrL3LO4lD3eQVvbFYJSG7JCMHQ= +github.com/sagernet/cors v1.2.1/go.mod h1:O64VyOjjhrkLmQIjF4KGRrJO/5dVXFdpEmCW/eISRAI= github.com/sagernet/fswatch v0.1.1 h1:YqID+93B7VRfqIH3PArW/XpJv5H4OLEVWDfProGoRQs= github.com/sagernet/fswatch v0.1.1/go.mod h1:nz85laH0mkQqJfaOrqPpkwtU1znMFNVTpT/5oRsVz/o= github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZNjr6sGeT00J8uU7JF4cNUdb44/Duis= @@ -168,8 +172,6 @@ github.com/sagernet/sing-shadowtls v0.1.4 h1:aTgBSJEgnumzFenPvc+kbD9/W0PywzWevnV github.com/sagernet/sing-shadowtls v0.1.4/go.mod h1:F8NBgsY5YN2beQavdgdm1DPlhaKQlaL6lpDdcBglGK4= github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ= github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo= -github.com/sagernet/wireguard-go v0.0.0-20231209092712-9a439356a62e h1:iGH0RMv2FzELOFNFQtvsxH7NPmlo7X5JizEK51UCojo= -github.com/sagernet/wireguard-go v0.0.0-20231209092712-9a439356a62e/go.mod h1:YbL4TKHRR6APYQv3U2RGfwLDpPYSyWz6oUlpISBEzBE= github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc= github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU= github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= @@ -209,6 +211,10 @@ github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17 github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= @@ -223,18 +229,18 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= -golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= -golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= @@ -254,13 +260,13 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= diff --git a/lib/common/common.dart b/lib/common/common.dart index fcea8499..f3fd19aa 100644 --- a/lib/common/common.dart +++ b/lib/common/common.dart @@ -29,4 +29,5 @@ export 'scroll.dart'; export 'icons.dart'; export 'http.dart'; export 'keyboard.dart'; -export 'network.dart'; \ No newline at end of file +export 'network.dart'; +export 'font.dart'; \ No newline at end of file diff --git a/lib/common/font.dart b/lib/common/font.dart new file mode 100644 index 00000000..c1eb1e75 --- /dev/null +++ b/lib/common/font.dart @@ -0,0 +1,3 @@ +class Fonts{ + static String get twEmoji => "Twemoji"; +} \ No newline at end of file diff --git a/lib/common/measure.dart b/lib/common/measure.dart index 040d66c3..7dae911c 100644 --- a/lib/common/measure.dart +++ b/lib/common/measure.dart @@ -8,7 +8,8 @@ class Measure { Measure.of(this.context) : _textScale = TextScaler.linear( - WidgetsBinding.instance.platformDispatcher.textScaleFactor); + WidgetsBinding.instance.platformDispatcher.textScaleFactor, + ); Size computeTextSize(Text text) { final textPainter = TextPainter( @@ -38,7 +39,6 @@ class Measure { return _bodyMediumHeight!; } - Size get bodyLargeSize { _bodyLargeSize ??= computeTextSize( Text( diff --git a/lib/common/other.dart b/lib/common/other.dart index ef347d53..00368378 100644 --- a/lib/common/other.dart +++ b/lib/common/other.dart @@ -104,14 +104,17 @@ class Other { required bool isStart, required Brightness brightness, }) { + if(Platform.isMacOS){ + return "assets/images/icon_white.png"; + } final suffix = Platform.isWindows ? "ico" : "png"; - if (!isStart && Platform.isWindows) { - return switch (brightness) { - Brightness.dark => "assets/images/icon_white.$suffix", - Brightness.light => "assets/images/icon_black.$suffix", - }; + if (isStart && Platform.isWindows) { + return "assets/images/icon.$suffix"; } - return "assets/images/icon.$suffix"; + return switch (brightness) { + Brightness.dark => "assets/images/icon_white.$suffix", + Brightness.light => "assets/images/icon_black.$suffix", + }; } int compareVersions(String version1, String version2) { @@ -193,7 +196,7 @@ class Other { List parseReleaseBody(String? body) { if (body == null) return []; - const pattern = r'- (.+?)\. \[.+?\]'; + const pattern = r'- \s*(.*)'; final regex = RegExp(pattern); return regex .allMatches(body) diff --git a/lib/controller.dart b/lib/controller.dart index 6fdde22a..9170137d 100644 --- a/lib/controller.dart +++ b/lib/controller.dart @@ -610,14 +610,18 @@ class AppController { Future _updateSystemTray({ required bool isStart, required Brightness? brightness, + bool force = false, }) async { - await trayManager.destroy(); + if (Platform.isLinux || force) { + await trayManager.destroy(); + } await trayManager.setIcon( other.getTrayIconPath( isStart: isStart, brightness: brightness ?? WidgetsBinding.instance.platformDispatcher.platformBrightness, ), + isTemplate: true, ); if (!Platform.isLinux) { await trayManager.setToolTip( @@ -626,11 +630,12 @@ class AppController { } } - updateTray() async { + updateTray([bool focus = false]) async { if (!Platform.isLinux) { await _updateSystemTray( isStart: appFlowingState.isStart, brightness: appState.brightness, + force: focus, ); } List menuItems = []; @@ -642,8 +647,9 @@ class AppController { ); menuItems.add(showMenuItem); final startMenuItem = MenuItem.checkbox( - label: - appFlowingState.isStart ? appLocalizations.stop : appLocalizations.start, + label: appFlowingState.isStart + ? appLocalizations.stop + : appLocalizations.start, onClick: (_) async { globalState.appController.updateStart(); }, @@ -714,6 +720,7 @@ class AppController { await _updateSystemTray( isStart: appFlowingState.isStart, brightness: appState.brightness, + force: focus, ); } } diff --git a/lib/fragments/dashboard/network_detection.dart b/lib/fragments/dashboard/network_detection.dart index de3329f6..48ec7a43 100644 --- a/lib/fragments/dashboard/network_detection.dart +++ b/lib/fragments/dashboard/network_detection.dart @@ -155,7 +155,7 @@ class _NetworkDetectionState extends State { .textTheme .titleLarge ?.copyWith( - fontFamily: "Twemoji", + fontFamily: Fonts.twEmoji, ), ), ) diff --git a/lib/manager/clash_manager.dart b/lib/manager/clash_manager.dart index 714c6345..6c68cfaf 100644 --- a/lib/manager/clash_manager.dart +++ b/lib/manager/clash_manager.dart @@ -142,7 +142,6 @@ class _ClashContainerState extends State with AppMessageListener { if (log.logLevel == LogLevel.error) { globalState.appController.showSnackBar(log.payload ?? ''); } - // debugPrint("$log"); super.onLog(log); } @@ -159,14 +158,14 @@ class _ClashContainerState extends State with AppMessageListener { } @override - void onLoaded(String providerName) { + Future onLoaded(String providerName) async { final appController = globalState.appController; appController.appState.setProvider( clashCore.getExternalProvider( providerName, ), ); - // appController.addCheckIpNumDebounce(); + await appController.updateGroupDebounce(); super.onLoaded(providerName); } } diff --git a/lib/manager/window_manager.dart b/lib/manager/window_manager.dart index 90edfd1e..b427f906 100644 --- a/lib/manager/window_manager.dart +++ b/lib/manager/window_manager.dart @@ -88,7 +88,7 @@ class _WindowContainerState extends State with WindowListener, Wi @override void onTaskbarCreated() { - globalState.appController.updateTray(); + globalState.appController.updateTray(true); super.onTaskbarCreated(); } diff --git a/lib/widgets/text.dart b/lib/widgets/text.dart index 7d4dec10..ba3a6aab 100644 --- a/lib/widgets/text.dart +++ b/lib/widgets/text.dart @@ -1,3 +1,4 @@ +import 'package:fl_clash/common/common.dart'; import 'package:flutter/material.dart'; import 'package:emoji_regex/emoji_regex.dart'; @@ -62,7 +63,7 @@ class EmojiText extends StatelessWidget { TextSpan( text:match.group(0), style: style?.copyWith( - fontFamily: "Twemoji", + fontFamily: Fonts.twEmoji, ), ), ); diff --git a/pubspec.lock b/pubspec.lock index 005b45ed..52c2a579 100755 --- a/pubspec.lock +++ b/pubspec.lock @@ -665,18 +665,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.4" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -721,10 +721,10 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" menu_base: dependency: transitive description: @@ -737,10 +737,10 @@ packages: dependency: transitive description: name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.15.0" mime: dependency: transitive description: @@ -1149,10 +1149,10 @@ packages: dependency: transitive description: name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.0" + version: "0.7.2" timing: dependency: transitive description: @@ -1269,10 +1269,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.1" + version: "14.2.5" watcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8dcfc333..1cc98f1b 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: fl_clash description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free. publish_to: 'none' -version: 0.8.64+202410121 +version: 0.8.65+202410261 environment: sdk: '>=3.1.0 <4.0.0' diff --git a/release.py b/release.py new file mode 100644 index 00000000..f5408044 --- /dev/null +++ b/release.py @@ -0,0 +1,59 @@ +import os +import json +import requests + +TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN") +TAG = os.getenv("TAG") + +IS_RELEASE = "+" not in TAG + +CHAT_ID = "@FlClash" +API_URL = f"http://localhost:8081/bot{TELEGRAM_BOT_TOKEN}/sendMediaGroup" + +DIST_DIR = os.path.join(os.getcwd(), "dist") +release = os.path.join(os.getcwd(), "release.md") + +text = "" + +media = [] +files = {} + +i = 1 +for file in os.listdir(DIST_DIR): + file_path = os.path.join(DIST_DIR, file) + if os.path.isfile(file_path): + file_key = f"file{i}" + media.append({ + "type": "document", + "media": f"attach://{file_key}" + }) + files[file_key] = open(file_path, 'rb') + i += 1 + +if TAG: + text += f"\n**{TAG}**\n" + +if IS_RELEASE: + text += f"\nhttps://github.com/chen08209/FlClash/releases/tag/{TAG}\n" + + +if os.path.exists(release): + text += "\n" + with open(release, 'r') as f: + text += f.read() + text += "\n" + +if media: + media[-1]["caption"] = text + media[-1]["parse_mode"] = "Markdown" + +response = requests.post( + API_URL, + data={ + "chat_id": CHAT_ID, + "media": json.dumps(media) + }, + files=files +) + +print("Response JSON:", response.json()) \ No newline at end of file diff --git a/setup.dart b/setup.dart index 9684d4d1..4f04e60d 100755 --- a/setup.dart +++ b/setup.dart @@ -55,8 +55,7 @@ class BuildLibItem { } class Build { - static List get buildItems => - [ + static List get buildItems => [ BuildLibItem( platform: PlatformType.macos, arch: Arch.amd64, @@ -115,7 +114,7 @@ class Build { final ndk = environment["ANDROID_NDK"]; assert(ndk != null); final prebuiltDir = - Directory(join(ndk!, "toolchains", "llvm", "prebuilt")); + Directory(join(ndk!, "toolchains", "llvm", "prebuilt")); final prebuiltDirList = prebuiltDir.listSync(); final map = { "armeabi-v7a": "armv7a-linux-androideabi21-clang", @@ -134,7 +133,8 @@ class Build { static get tags => "with_gvisor"; - static Future exec(List executable, { + static Future exec( + List executable, { String? name, Map? environment, String? workingDirectory, @@ -163,7 +163,7 @@ class Build { Arch? arch, }) async { final items = buildItems.where( - (element) { + (element) { return element.platform == platform && (arch == null ? true : element.arch == arch); }, @@ -276,11 +276,10 @@ class BuildCommand extends Command { @override String get name => platform.name; - List get arches => - Build.buildItems - .where((element) => element.platform == platform) - .map((e) => e.arch) - .toList(); + List get arches => Build.buildItems + .where((element) => element.platform == platform) + .map((e) => e.arch) + .toList(); Future _buildLib(Arch? arch) async { await Build.buildLib(platform: platform, arch: arch); @@ -337,11 +336,13 @@ class BuildCommand extends Command { String args = '', }) async { await Build.getDistributor(); +/* final tag = Platform.environment["TAG"] ?? "+"; + final isDev = tag.contains("+"); + final channelArgs = isDev && platform == PlatformType.android ? "--build-flavor dev" : "";*/ await Build.exec( name: name, Build.getExecutable( - "flutter_distributor package --skip-clean --platform ${platform - .name} --targets $targets --flutter-build-args=verbose $args", + "flutter_distributor package --skip-clean --platform ${platform.name} --targets $targets --flutter-build-args=verbose $args", ), ); } @@ -351,7 +352,7 @@ class BuildCommand extends Command { final String build = argResults?['build'] ?? 'all'; final archName = argResults?['arch']; final currentArches = - arches.where((element) => element.name == archName).toList(); + arches.where((element) => element.name == archName).toList(); final arch = currentArches.isEmpty ? null : currentArches.first; if (arch == null && platform == PlatformType.windows) { throw "Invalid arch"; @@ -389,8 +390,7 @@ class BuildCommand extends Command { platform: platform, targets: "apk", args: - "--flutter-build-args split-per-abi --build-target-platform ${defaultTargets - .join(",")}", + "--flutter-build-args split-per-abi --build-target-platform ${defaultTargets.join(",")}", ); case PlatformType.macos: await _getMacosDependencies();