diff --git a/.github/update.log b/.github/update.log index e0c9c88a8b..22e3acef8d 100644 --- a/.github/update.log +++ b/.github/update.log @@ -742,3 +742,4 @@ Update On Mon Aug 19 20:32:09 CEST 2024 Update On Tue Aug 20 20:32:25 CEST 2024 Update On Wed Aug 21 20:32:11 CEST 2024 Update On Thu Aug 22 20:34:16 CEST 2024 +Update On Fri Aug 23 20:31:39 CEST 2024 diff --git a/clash-meta/listener/shadowsocks/tcp.go b/clash-meta/listener/shadowsocks/tcp.go index c08667de6b..c38438142d 100644 --- a/clash-meta/listener/shadowsocks/tcp.go +++ b/clash-meta/listener/shadowsocks/tcp.go @@ -22,7 +22,7 @@ type Listener struct { var _listener *Listener -func New(config LC.ShadowsocksServer, tunnel C.Tunnel) (*Listener, error) { +func New(config LC.ShadowsocksServer, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) { pickCipher, err := core.PickCipher(config.Cipher, nil, config.Password) if err != nil { return nil, err @@ -36,7 +36,7 @@ func New(config LC.ShadowsocksServer, tunnel C.Tunnel) (*Listener, error) { if config.Udp { //UDP - ul, err := NewUDP(addr, pickCipher, tunnel) + ul, err := NewUDP(addr, pickCipher, tunnel, additions...) if err != nil { return nil, err } @@ -60,7 +60,7 @@ func New(config LC.ShadowsocksServer, tunnel C.Tunnel) (*Listener, error) { continue } N.TCPKeepAlive(c) - go sl.HandleConn(c, tunnel) + go sl.HandleConn(c, tunnel, additions...) } }() } diff --git a/clash-meta/listener/shadowsocks/udp.go b/clash-meta/listener/shadowsocks/udp.go index 4336db2253..77932ed1b1 100644 --- a/clash-meta/listener/shadowsocks/udp.go +++ b/clash-meta/listener/shadowsocks/udp.go @@ -17,7 +17,7 @@ type UDPListener struct { closed bool } -func NewUDP(addr string, pickCipher core.Cipher, tunnel C.Tunnel) (*UDPListener, error) { +func NewUDP(addr string, pickCipher core.Cipher, tunnel C.Tunnel, additions ...inbound.Addition) (*UDPListener, error) { l, err := net.ListenPacket("udp", addr) if err != nil { return nil, err @@ -42,7 +42,7 @@ func NewUDP(addr string, pickCipher core.Cipher, tunnel C.Tunnel) (*UDPListener, } continue } - handleSocksUDP(conn, tunnel, data, put, remoteAddr) + handleSocksUDP(conn, tunnel, data, put, remoteAddr, additions...) } }() diff --git a/clash-meta/listener/sing_shadowsocks/server.go b/clash-meta/listener/sing_shadowsocks/server.go index bd5002a464..1cb798f7d0 100644 --- a/clash-meta/listener/sing_shadowsocks/server.go +++ b/clash-meta/listener/sing_shadowsocks/server.go @@ -72,7 +72,7 @@ func New(config LC.ShadowsocksServer, tunnel C.Tunnel, additions ...inbound.Addi sl.service, err = shadowaead_2022.NewServiceWithPassword(config.Cipher, config.Password, udpTimeout, h, ntp.Now) default: err = fmt.Errorf("shadowsocks: unsupported method: %s", config.Cipher) - return embedSS.New(config, tunnel) + return embedSS.New(config, tunnel, additions...) } if err != nil { return nil, err diff --git a/clash-nyanpasu/manifest/version.json b/clash-nyanpasu/manifest/version.json index 89bb88ab53..1435af305b 100644 --- a/clash-nyanpasu/manifest/version.json +++ b/clash-nyanpasu/manifest/version.json @@ -2,7 +2,7 @@ "manifest_version": 1, "latest": { "mihomo": "v1.18.7", - "mihomo_alpha": "alpha-c4660e1", + "mihomo_alpha": "alpha-41efc5e", "clash_rs": "v0.2.0", "clash_premium": "2023-09-05-gdcc8d87" }, @@ -36,5 +36,5 @@ "darwin-x64": "clash-darwin-amd64-n{}.gz" } }, - "updated_at": "2024-08-21T22:20:11.969Z" + "updated_at": "2024-08-22T22:20:28.984Z" } diff --git a/clash-verge-rev/scripts/updater-fixed-webview2.mjs b/clash-verge-rev/scripts/updater-fixed-webview2.mjs index 0ae00345ea..64426d94a8 100644 --- a/clash-verge-rev/scripts/updater-fixed-webview2.mjs +++ b/clash-verge-rev/scripts/updater-fixed-webview2.mjs @@ -100,7 +100,7 @@ async function resolveUpdater() { Object.entries(updateDataNew.platforms).forEach(([key, value]) => { if (value.url) { updateDataNew.platforms[key].url = - "https://mirror.ghproxy.com/" + value.url; + "https://download.clashverge.dev/" + value.url; } else { console.log(`[Error]: updateDataNew.platforms.${key} is null`); } diff --git a/clash-verge-rev/scripts/updater.mjs b/clash-verge-rev/scripts/updater.mjs index 6ecb62dcf2..fc4cbe35e0 100644 --- a/clash-verge-rev/scripts/updater.mjs +++ b/clash-verge-rev/scripts/updater.mjs @@ -150,7 +150,7 @@ async function resolveUpdater() { Object.entries(updateDataNew.platforms).forEach(([key, value]) => { if (value.url) { updateDataNew.platforms[key].url = - "https://mirror.ghproxy.com/" + value.url; + "https://download.clashverge.dev/" + value.url; } else { console.log(`[Error]: updateDataNew.platforms.${key} is null`); } diff --git a/clash-verge-rev/src-tauri/tauri.conf.json b/clash-verge-rev/src-tauri/tauri.conf.json index 7f6a2a336c..b1138b2a1f 100644 --- a/clash-verge-rev/src-tauri/tauri.conf.json +++ b/clash-verge-rev/src-tauri/tauri.conf.json @@ -32,7 +32,7 @@ "updater": { "active": true, "endpoints": [ - "https://mirror.ghproxy.com/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-proxy.json", + "https://download.clashverge.dev/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-proxy.json", "https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update.json" ], "dialog": false, diff --git a/clash-verge-rev/src-tauri/webview2.arm64.json b/clash-verge-rev/src-tauri/webview2.arm64.json index 8079b63ab3..64ce7c5e82 100644 --- a/clash-verge-rev/src-tauri/webview2.arm64.json +++ b/clash-verge-rev/src-tauri/webview2.arm64.json @@ -29,7 +29,7 @@ "active": true, "dialog": false, "endpoints": [ - "https://mirror.ghproxy.com/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2-proxy.json", + "https://download.clashverge.dev/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2-proxy.json", "https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2.json" ], "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEQyOEMyRjBCQkVGOUJEREYKUldUZnZmbStDeStNMHU5Mmo1N24xQXZwSVRYbXA2NUpzZE5oVzlqeS9Bc0t6RVV4MmtwVjBZaHgK" diff --git a/clash-verge-rev/src-tauri/webview2.x64.json b/clash-verge-rev/src-tauri/webview2.x64.json index 27f772d4d8..085d567285 100644 --- a/clash-verge-rev/src-tauri/webview2.x64.json +++ b/clash-verge-rev/src-tauri/webview2.x64.json @@ -29,7 +29,7 @@ "active": true, "dialog": false, "endpoints": [ - "https://mirror.ghproxy.com/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2-proxy.json", + "https://download.clashverge.dev/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2-proxy.json", "https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2.json" ], "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEQyOEMyRjBCQkVGOUJEREYKUldUZnZmbStDeStNMHU5Mmo1N24xQXZwSVRYbXA2NUpzZE5oVzlqeS9Bc0t6RVV4MmtwVjBZaHgK" diff --git a/clash-verge-rev/src-tauri/webview2.x86.json b/clash-verge-rev/src-tauri/webview2.x86.json index ea1eb337dc..726d16a17b 100644 --- a/clash-verge-rev/src-tauri/webview2.x86.json +++ b/clash-verge-rev/src-tauri/webview2.x86.json @@ -29,7 +29,7 @@ "active": true, "dialog": false, "endpoints": [ - "https://mirror.ghproxy.com/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2-proxy.json", + "https://download.clashverge.dev/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2-proxy.json", "https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-fixed-webview2.json" ], "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEQyOEMyRjBCQkVGOUJEREYKUldUZnZmbStDeStNMHU5Mmo1N24xQXZwSVRYbXA2NUpzZE5oVzlqeS9Bc0t6RVV4MmtwVjBZaHgK" diff --git a/mihomo/listener/shadowsocks/tcp.go b/mihomo/listener/shadowsocks/tcp.go index c08667de6b..c38438142d 100644 --- a/mihomo/listener/shadowsocks/tcp.go +++ b/mihomo/listener/shadowsocks/tcp.go @@ -22,7 +22,7 @@ type Listener struct { var _listener *Listener -func New(config LC.ShadowsocksServer, tunnel C.Tunnel) (*Listener, error) { +func New(config LC.ShadowsocksServer, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) { pickCipher, err := core.PickCipher(config.Cipher, nil, config.Password) if err != nil { return nil, err @@ -36,7 +36,7 @@ func New(config LC.ShadowsocksServer, tunnel C.Tunnel) (*Listener, error) { if config.Udp { //UDP - ul, err := NewUDP(addr, pickCipher, tunnel) + ul, err := NewUDP(addr, pickCipher, tunnel, additions...) if err != nil { return nil, err } @@ -60,7 +60,7 @@ func New(config LC.ShadowsocksServer, tunnel C.Tunnel) (*Listener, error) { continue } N.TCPKeepAlive(c) - go sl.HandleConn(c, tunnel) + go sl.HandleConn(c, tunnel, additions...) } }() } diff --git a/mihomo/listener/shadowsocks/udp.go b/mihomo/listener/shadowsocks/udp.go index 4336db2253..77932ed1b1 100644 --- a/mihomo/listener/shadowsocks/udp.go +++ b/mihomo/listener/shadowsocks/udp.go @@ -17,7 +17,7 @@ type UDPListener struct { closed bool } -func NewUDP(addr string, pickCipher core.Cipher, tunnel C.Tunnel) (*UDPListener, error) { +func NewUDP(addr string, pickCipher core.Cipher, tunnel C.Tunnel, additions ...inbound.Addition) (*UDPListener, error) { l, err := net.ListenPacket("udp", addr) if err != nil { return nil, err @@ -42,7 +42,7 @@ func NewUDP(addr string, pickCipher core.Cipher, tunnel C.Tunnel) (*UDPListener, } continue } - handleSocksUDP(conn, tunnel, data, put, remoteAddr) + handleSocksUDP(conn, tunnel, data, put, remoteAddr, additions...) } }() diff --git a/mihomo/listener/sing_shadowsocks/server.go b/mihomo/listener/sing_shadowsocks/server.go index bd5002a464..1cb798f7d0 100644 --- a/mihomo/listener/sing_shadowsocks/server.go +++ b/mihomo/listener/sing_shadowsocks/server.go @@ -72,7 +72,7 @@ func New(config LC.ShadowsocksServer, tunnel C.Tunnel, additions ...inbound.Addi sl.service, err = shadowaead_2022.NewServiceWithPassword(config.Cipher, config.Password, udpTimeout, h, ntp.Now) default: err = fmt.Errorf("shadowsocks: unsupported method: %s", config.Cipher) - return embedSS.New(config, tunnel) + return embedSS.New(config, tunnel, additions...) } if err != nil { return nil, err diff --git a/sing-box/docs/configuration/experimental/clash-api.md b/sing-box/docs/configuration/experimental/clash-api.md index e1ca981521..7425143eb3 100644 --- a/sing-box/docs/configuration/experimental/clash-api.md +++ b/sing-box/docs/configuration/experimental/clash-api.md @@ -1,3 +1,12 @@ +--- +icon: material/new-box +--- + +!!! quote "Changes in sing-box 1.10.0" + + :material-plus: [access_control_allow_origin](#access_control_allow_origin) + :material-plus: [access_control_allow_private_network](#access_control_allow_private_network) + !!! quote "Changes in sing-box 1.8.0" :material-delete-alert: [store_mode](#store_mode) @@ -8,24 +17,59 @@ ### Structure -```json -{ - "external_controller": "127.0.0.1:9090", - "external_ui": "", - "external_ui_download_url": "", - "external_ui_download_detour": "", - "secret": "", - "default_mode": "", - - // Deprecated - - "store_mode": false, - "store_selected": false, - "store_fakeip": false, - "cache_file": "", - "cache_id": "" -} -``` +=== "Structure" + + ```json + { + "external_controller": "127.0.0.1:9090", + "external_ui": "", + "external_ui_download_url": "", + "external_ui_download_detour": "", + "secret": "", + "default_mode": "", + "access_control_allow_origin": [], + "access_control_allow_private_network": false, + + // Deprecated + + "store_mode": false, + "store_selected": false, + "store_fakeip": false, + "cache_file": "", + "cache_id": "" + } + ``` + +=== "Example (online)" + + !!! question "Since sing-box 1.10.0" + + ```json + { + "external_controller": "127.0.0.1:9090", + "access_control_allow_origin": [ + "http://127.0.0.1", + "http://yacd.haishan.me" + ], + "access_control_allow_private_network": true + } + ``` + +=== "Example (download)" + + !!! question "Since sing-box 1.10.0" + + ```json + { + "external_controller": "0.0.0.0:9090", + "external_ui": "dashboard" + // external_ui_download_detour: "direct" + } + ``` + +!!! note "" + + You can ignore the JSON Array [] tag when the content is only one item ### Fields @@ -63,6 +107,22 @@ Default mode in clash, `Rule` will be used if empty. This setting has no direct effect, but can be used in routing and DNS rules via the `clash_mode` rule item. +#### access_control_allow_origin + +!!! question "Since sing-box 1.10.0" + +CORS allowed origins, `*` will be used if empty. + +To access the Clash API on a private network from a public website, you must explicitly specify it in `access_control_allow_origin` instead of using `*`. + +#### access_control_allow_private_network + +!!! question "Since sing-box 1.10.0" + +Allow access from private network. + +To access the Clash API on a private network from a public website, `access_control_allow_private_network` must be enabled. + #### store_mode !!! failure "Deprecated in sing-box 1.8.0" diff --git a/sing-box/docs/configuration/experimental/clash-api.zh.md b/sing-box/docs/configuration/experimental/clash-api.zh.md index 092769ac93..b3d8aeaf99 100644 --- a/sing-box/docs/configuration/experimental/clash-api.zh.md +++ b/sing-box/docs/configuration/experimental/clash-api.zh.md @@ -1,3 +1,12 @@ +--- +icon: material/new-box +--- + +!!! quote "sing-box 1.10.0 中的更改" + + :material-plus: [access_control_allow_origin](#access_control_allow_origin) + :material-plus: [access_control_allow_private_network](#access_control_allow_private_network) + !!! quote "sing-box 1.8.0 中的更改" :material-delete-alert: [store_mode](#store_mode) @@ -8,24 +17,59 @@ ### 结构 -```json -{ - "external_controller": "127.0.0.1:9090", - "external_ui": "", - "external_ui_download_url": "", - "external_ui_download_detour": "", - "secret": "", - "default_mode": "", - - // Deprecated - - "store_mode": false, - "store_selected": false, - "store_fakeip": false, - "cache_file": "", - "cache_id": "" -} -``` +=== "结构" + + ```json + { + "external_controller": "127.0.0.1:9090", + "external_ui": "", + "external_ui_download_url": "", + "external_ui_download_detour": "", + "secret": "", + "default_mode": "", + "access_control_allow_origin": [], + "access_control_allow_private_network": false, + + // Deprecated + + "store_mode": false, + "store_selected": false, + "store_fakeip": false, + "cache_file": "", + "cache_id": "" + } + ``` + +=== "示例 (在线)" + + !!! question "自 sing-box 1.10.0 起" + + ```json + { + "external_controller": "127.0.0.1:9090", + "access_control_allow_origin": [ + "http://127.0.0.1", + "http://yacd.haishan.me" + ], + "access_control_allow_private_network": true + } + ``` + +=== "示例 (下载)" + + !!! question "自 sing-box 1.10.0 起" + + ```json + { + "external_controller": "0.0.0.0:9090", + "external_ui": "dashboard" + // external_ui_download_detour: "direct" + } + ``` + +!!! note "" + + 当内容只有一项时,可以忽略 JSON 数组 [] 标签 ### Fields @@ -61,6 +105,22 @@ Clash 中的默认模式,默认使用 `Rule`。 此设置没有直接影响,但可以通过 `clash_mode` 规则项在路由和 DNS 规则中使用。 +#### access_control_allow_origin + +!!! question "自 sing-box 1.10.0 起" + +允许的 CORS 来源,默认使用 `*`。 + +要从公共网站访问私有网络上的 Clash API,必须在 `access_control_allow_origin` 中明确指定它而不是使用 `*`。 + +#### access_control_allow_private_network + +!!! question "自 sing-box 1.10.0 起" + +允许从私有网络访问。 + +要从公共网站访问私有网络上的 Clash API,必须启用 `access_control_allow_private_network`。 + #### store_mode !!! failure "已在 sing-box 1.8.0 废弃" diff --git a/sing-box/experimental/clashapi/server.go b/sing-box/experimental/clashapi/server.go index 1e7804ce44..889d191e0e 100644 --- a/sing-box/experimental/clashapi/server.go +++ b/sing-box/experimental/clashapi/server.go @@ -12,6 +12,7 @@ import ( "syscall" "time" + "github.com/sagernet/cors" "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/common/urltest" C "github.com/sagernet/sing-box/constant" @@ -29,7 +30,6 @@ import ( "github.com/sagernet/ws/wsutil" "github.com/go-chi/chi/v5" - "github.com/go-chi/cors" "github.com/go-chi/render" ) @@ -90,11 +90,16 @@ func NewServer(ctx context.Context, router adapter.Router, logFactory log.Observ if options.StoreMode || options.StoreSelected || options.StoreFakeIP || options.CacheFile != "" || options.CacheID != "" { return nil, E.New("cache_file and related fields in Clash API is deprecated in sing-box 1.8.0, use experimental.cache_file instead.") } + allowedOrigins := options.AccessControlAllowOrigin + if len(allowedOrigins) == 0 { + allowedOrigins = []string{"*"} + } cors := cors.New(cors.Options{ - AllowedOrigins: []string{"*"}, - AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE"}, - AllowedHeaders: []string{"Content-Type", "Authorization"}, - MaxAge: 300, + AllowedOrigins: allowedOrigins, + AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE"}, + AllowedHeaders: []string{"Content-Type", "Authorization"}, + AllowPrivateNetwork: options.AccessControlAllowPrivateNetwork, + MaxAge: 300, }) chiRouter.Use(cors.Handler) chiRouter.Group(func(r chi.Router) { @@ -277,10 +282,11 @@ func authentication(serverSecret string) func(next http.Handler) http.Handler { func hello(redirect bool) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { - if redirect { - http.Redirect(w, r, "/ui/", http.StatusTemporaryRedirect) - } else { + contentType := r.Header.Get("Content-Type") + if !redirect || contentType == "application/json" { render.JSON(w, r, render.M{"hello": "clash"}) + } else { + http.Redirect(w, r, "/ui/", http.StatusTemporaryRedirect) } } } diff --git a/sing-box/go.mod b/sing-box/go.mod index 8f9cf39a45..727d10f08a 100644 --- a/sing-box/go.mod +++ b/sing-box/go.mod @@ -8,7 +8,6 @@ require ( github.com/cloudflare/circl v1.3.7 github.com/cretz/bine v0.2.0 github.com/go-chi/chi/v5 v5.0.12 - github.com/go-chi/cors v1.2.1 github.com/go-chi/render v1.0.3 github.com/gofrs/uuid/v5 v5.2.0 github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2 @@ -21,6 +20,7 @@ require ( github.com/oschwald/maxminddb-golang v1.12.0 github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 + github.com/sagernet/cors v1.2.1 github.com/sagernet/fswatch v0.1.1 github.com/sagernet/gomobile v0.1.3 github.com/sagernet/gvisor v0.0.0-20240428053021-e691de28565f diff --git a/sing-box/go.sum b/sing-box/go.sum index be752e4dad..e30307962b 100644 --- a/sing-box/go.sum +++ b/sing-box/go.sum @@ -21,8 +21,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.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= github.com/go-chi/chi/v5 v5.0.12/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= @@ -100,6 +98,8 @@ github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a h1:+NkI2670SQpQWvkk github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a/go.mod h1:63s7jpZqcDAIpj8oI/1v4Izok+npJOHACFCU6+huCkM= github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 h1:YbmpqPQEMdlk9oFSKYWRqVuu9qzNiOayIonKmv1gCXY= github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1/go.mod h1:J2yAxTFPDjrDPhuAi9aWFz2L3ox9it4qAluBBbN0H5k= +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/gomobile v0.1.3 h1:ohjIb1Ou2+1558PnZour3od69suSuvkdSVOlO1tC4B8= diff --git a/sing-box/option/experimental.go b/sing-box/option/experimental.go index 9f6071baee..6ab6638550 100644 --- a/sing-box/option/experimental.go +++ b/sing-box/option/experimental.go @@ -17,13 +17,15 @@ type CacheFileOptions struct { } type ClashAPIOptions struct { - ExternalController string `json:"external_controller,omitempty"` - ExternalUI string `json:"external_ui,omitempty"` - ExternalUIDownloadURL string `json:"external_ui_download_url,omitempty"` - ExternalUIDownloadDetour string `json:"external_ui_download_detour,omitempty"` - Secret string `json:"secret,omitempty"` - DefaultMode string `json:"default_mode,omitempty"` - ModeList []string `json:"-"` + ExternalController string `json:"external_controller,omitempty"` + ExternalUI string `json:"external_ui,omitempty"` + ExternalUIDownloadURL string `json:"external_ui_download_url,omitempty"` + ExternalUIDownloadDetour string `json:"external_ui_download_detour,omitempty"` + Secret string `json:"secret,omitempty"` + DefaultMode string `json:"default_mode,omitempty"` + ModeList []string `json:"-"` + AccessControlAllowOrigin Listable[string] `json:"access_control_allow_origin,omitempty"` + AccessControlAllowPrivateNetwork bool `json:"access_control_allow_private_network,omitempty"` // Deprecated: migrated to global cache file CacheFile string `json:"cache_file,omitempty"` diff --git a/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua b/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua index 8450e30607..1b2ffbba36 100644 --- a/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua +++ b/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua @@ -334,7 +334,15 @@ if singbox_tags:find("with_quic") then o.default = "3" o:depends({ [option_name("protocol")] = "tuic" }) - o = s:option(Value, option_name("tuic_alpn"), translate("QUIC TLS ALPN")) + o = s:option(ListValue, option_name("tuic_alpn"), translate("QUIC TLS ALPN")) + o.default = "default" + o:value("default", translate("Default")) + o:value("h3") + o:value("h2") + o:value("h3,h2") + o:value("http/1.1") + o:value("h2,http/1.1") + o:value("h3,h2,http/1.1") o:depends({ [option_name("protocol")] = "tuic" }) end diff --git a/small/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm b/small/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm index b0c1796ce8..a3bbbfabf1 100644 --- a/small/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm +++ b/small/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm @@ -508,6 +508,27 @@ local api = require "luci.passwall.api" if (v_password) { url = encodeURIComponent(v_password.value) + "@" + url } + } else if (v_type === "sing-box" && opt.get(dom_prefix + "protocol").value === "tuic") { + protocol = "tuic"; + var v_username = opt.get(dom_prefix + "uuid"); + var v_password = opt.get(dom_prefix + "password"); + var v_port = opt.get(dom_prefix + "port"); + url = encodeURIComponent(v_username.value) + + ":" + encodeURIComponent(v_password.value) + + "@" + _address + + ":" + v_port.value + "?"; + + var params = ""; + params += opt.query("sni", dom_prefix + "tls_serverName"); + params += opt.query("alpn", dom_prefix + "tuic_alpn"); + params += opt.query("congestion_control", dom_prefix + "tuic_congestion_control"); + params += opt.query("allowinsecure", dom_prefix + "tls_allowInsecure"); + + params += "#" + encodeURI(v_alias.value); + if (params[0] == "&") { + params = params.substring(1); + } + url += params; } if (url) { url = protocol.toLowerCase() + "://" + url; @@ -1185,6 +1206,45 @@ local api = require "luci.passwall.api" opt.set('remarks', decodeURIComponent(m.hash.substr(1))); } } + if (ssu[0] === "tuic") { + if (has_singbox) { + dom_prefix = "singbox_" + opt.set('type', "sing-box"); + } + opt.set(dom_prefix + 'protocol', "tuic"); + var _parsedUrl = new URL("http://" + ssu[1]); + var username = _parsedUrl.username; + var password = _parsedUrl.password; + var hostname = _parsedUrl.hostname; + var port = _parsedUrl.port; + var search = _parsedUrl.search; + var hash = _parsedUrl.hash; + opt.set(dom_prefix + 'uuid', decodeURIComponent(username)); + opt.set(dom_prefix + 'password', decodeURIComponent(password)); + opt.set(dom_prefix + 'address', hostname); + opt.set(dom_prefix + 'port', port || "443"); + var queryParam = {}; + if (search.length > 1) { + var query = search.split('?') + var queryParams = query[1]; + var queryArray = queryParams.split('&'); + var params; + for (i = 0; i < queryArray.length; i++) { + params = queryArray[i].split('='); + queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || ''); + } + } + opt.set(dom_prefix + 'tuic_congestion_control', queryParam.congestion_control || 'cubic'); + opt.set(dom_prefix + 'tuic_alpn', queryParam.alpn || 'default'); + opt.set(dom_prefix + 'tls_serverName', queryParam.sni || ''); + opt.set(dom_prefix + 'tls_allowInsecure', true); + if (queryParam.allowinsecure === '0') { + opt.set(dom_prefix + 'tls_allowInsecure', false); + } + if (hash) { + opt.set('remarks', decodeURIComponent(hash.substr(1))); + } + } if (dom_prefix && dom_prefix != null) { if (opt.get(dom_prefix + 'port').value) { opt.get(dom_prefix + 'port').focus(); diff --git a/small/luci-app-passwall/root/usr/share/passwall/subscribe.lua b/small/luci-app-passwall/root/usr/share/passwall/subscribe.lua index 1d22a1ad5b..e423a67a13 100755 --- a/small/luci-app-passwall/root/usr/share/passwall/subscribe.lua +++ b/small/luci-app-passwall/root/usr/share/passwall/subscribe.lua @@ -1081,6 +1081,59 @@ local function processData(szType, content, add_mode, add_from) result.hysteria2_obfs_password = params["obfs-password"] end end + elseif szType == 'tuic' then + local alias = "" + if content:find("#") then + local idx_sp = content:find("#") + alias = content:sub(idx_sp + 1, -1) + content = content:sub(0, idx_sp - 1) + end + result.remarks = UrlDecode(alias) + local Info = content + if content:find("@") then + local contents = split(content, "@") + if contents[1]:find(":") then + local userinfo = split(contents[1], ":") + result.uuid = UrlDecode(userinfo[1]) + result.password = UrlDecode(userinfo[2]) + end + Info = (contents[2] or ""):gsub("/%?", "?") + end + local query = split(Info, "?") + local host_port = query[1] + local params = {} + for _, v in pairs(split(query[2], '&')) do + local t = split(v, '=') + if #t > 1 then + params[string.lower(t[1])] = UrlDecode(t[2]) + end + end + if host_port:find(":") then + local sp = split(host_port, ":") + result.port = sp[#sp] + if api.is_ipv6addrport(host_port) then + result.address = api.get_ipv6_only(host_port) + else + result.address = sp[1] + end + else + result.address = host_port + end + result.tls_serverName = params.sni + result.tuic_alpn = params.alpn or "default" + result.tuic_congestion_control = params.congestion_control or "cubic" + if params.allowinsecure then + if params.allowinsecure == "1" or params.allowinsecure == "0" then + result.tls_allowInsecure = params.allowinsecure + else + result.tls_allowInsecure = string.lower(params.allowinsecure) == "true" and "1" or "0" + end + --log(result.remarks .. ' 使用节点AllowInsecure设定: '.. result.tls_allowInsecure) + else + result.tls_allowInsecure = allowInsecure_default and "1" or "0" + end + result.type = 'sing-box' + result.protocol = "tuic" else log('暂时不支持' .. szType .. "类型的节点订阅,跳过此节点。") return nil diff --git a/small/v2ray-geodata/Makefile b/small/v2ray-geodata/Makefile index e7767abff8..9067aa194a 100644 --- a/small/v2ray-geodata/Makefile +++ b/small/v2ray-geodata/Makefile @@ -21,13 +21,13 @@ define Download/geoip HASH:=2c6b6ee15f4593a7b54853c8db5a2b881986ae405122d9fa1427f33c26316ff3 endef -GEOSITE_VER:=20240817092737 +GEOSITE_VER:=20240823035651 GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER) define Download/geosite URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/ URL_FILE:=dlc.dat FILE:=$(GEOSITE_FILE) - HASH:=4cfb044771759b19b26f36e7f697d9224a62226b2edea9d3e79c0ce1830fbf71 + HASH:=e9197238b1b4e6e6ae9f35dfc40484936093562bef354501981bf8d5e29950da endef GEOSITE_IRAN_VER:=202408190030 diff --git a/v2ray-core/go.mod b/v2ray-core/go.mod index dddabd6a53..5739511055 100644 --- a/v2ray-core/go.mod +++ b/v2ray-core/go.mod @@ -5,23 +5,23 @@ go 1.21 toolchain go1.21.4 require ( - github.com/adrg/xdg v0.4.0 - github.com/go-chi/chi/v5 v5.0.12 + github.com/adrg/xdg v0.5.0 + github.com/go-chi/chi/v5 v5.1.0 github.com/go-chi/render v1.0.3 - github.com/go-playground/validator/v10 v10.20.0 + github.com/go-playground/validator/v10 v10.22.0 github.com/golang-collections/go-datastructures v0.0.0-20150211160725-59788d5eb259 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 github.com/google/go-cmp v0.6.0 github.com/google/gopacket v1.1.19 - github.com/gorilla/websocket v1.5.1 + github.com/gorilla/websocket v1.5.3 github.com/jhump/protoreflect v1.16.0 github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 github.com/miekg/dns v1.1.62 github.com/mustafaturan/bus v1.0.2 github.com/pelletier/go-toml v1.9.5 - github.com/pion/dtls/v2 v2.2.7 - github.com/pion/transport/v2 v2.2.5 + github.com/pion/dtls/v2 v2.2.12 + github.com/pion/transport/v2 v2.2.10 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.46.0 github.com/refraction-networking/utls v1.6.7 @@ -72,6 +72,7 @@ require ( github.com/pion/logging v0.2.2 // indirect github.com/pion/randutil v0.1.0 // indirect github.com/pion/sctp v1.8.7 // indirect + github.com/pion/transport/v3 v3.0.7 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4 // indirect diff --git a/v2ray-core/go.sum b/v2ray-core/go.sum index ccb53c69d9..e559d9ac3e 100644 --- a/v2ray-core/go.sum +++ b/v2ray-core/go.sum @@ -15,8 +15,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/FlowerWrong/water v0.0.0-20180301012659-01a4eaa1f6f2/go.mod h1:xrG5L7lq7T2DLnPr2frMnL906CNEoKRwLB+VYFhPq2w= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= -github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= +github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY= +github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4= github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 h1:+JkXLHME8vLJafGhOH4aoV2Iu8bR55nU6iKMVfYVLjY= github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1/go.mod h1:nuudZmJhzWtx2212z+pkuy7B6nkBqa+xwNXZHL1j8cg= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= @@ -69,8 +69,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= -github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +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/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4= github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -85,8 +85,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao= +github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= @@ -140,8 +140,8 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR github.com/gopherjs/gopherjs v0.0.0-20210420193930-a4630ec28c79/go.mod h1:Opf9rtYVq0eTyX+aRVmRO9hE8ERAozcdrBxWG9Q6mkQ= github.com/gopherjs/websocket v0.0.0-20191103002815-9a42957e2b3a/go.mod h1:jd+zY81Fx2lC4bfw58+Rflg1srqmedQjbBUejKOjYNY= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -234,8 +234,8 @@ github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pion/dtls/v2 v2.0.0-rc.7/go.mod h1:U199DvHpRBN0muE9+tVN4TMy1jvEhZIZ63lk4xkvVSk= -github.com/pion/dtls/v2 v2.2.7 h1:cSUBsETxepsCSFSxC3mc/aDo14qQLMSL+O6IjG28yV8= -github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= +github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk= +github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= @@ -245,9 +245,11 @@ github.com/pion/sctp v1.8.7 h1:JnABvFakZueGAn4KU/4PSKg+GWbF6QWbKTWZOSGJjXw= github.com/pion/sctp v1.8.7/go.mod h1:g1Ul+ARqZq5JEmoFy87Q/4CePtKnTJ1QCL9dBBdN6AU= github.com/pion/transport v0.8.10/go.mod h1:tBmha/UCjpum5hqTWhfAEs3CO4/tHSg0MYRhSzR+CZ8= github.com/pion/transport/v2 v2.1.0/go.mod h1:AdSw4YBZVDkZm8fpoz+fclXyQwANWmZAlDuQdctTThQ= -github.com/pion/transport/v2 v2.2.1/go.mod h1:cXXWavvCnFF6McHTft3DWS9iic2Mftcz1Aq29pGcU5g= -github.com/pion/transport/v2 v2.2.5 h1:iyi25i/21gQck4hfRhomF6SktmUQjRsRW4WJdhfc3Kc= -github.com/pion/transport/v2 v2.2.5/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= +github.com/pion/transport/v2 v2.2.4/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= +github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQpw6Q= +github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E= +github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0= +github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo= github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwyq0Hs= github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -307,11 +309,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -328,6 +328,7 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI= github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= +github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xiaokangwang/VLite v0.0.0-20220418190619-cff95160a432 h1:I/ATawgO2RerCq9ACwL0wBB8xNXZdE3J+93MCEHReRs= github.com/xiaokangwang/VLite v0.0.0-20220418190619-cff95160a432/go.mod h1:QN7Go2ftTVfx0aCTh9RXHV8pkpi0FtmbwQw40dy61wQ= @@ -363,8 +364,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= 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-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -416,9 +417,9 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= 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/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -459,7 +460,6 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -468,6 +468,7 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.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.16.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.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -475,9 +476,9 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -487,6 +488,7 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 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/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/v2rayn/v2rayN/ServiceLib/Base/MyReactiveObject.cs b/v2rayn/v2rayN/ServiceLib/Base/MyReactiveObject.cs index 8d7c35218a..7a0a304f5d 100644 --- a/v2rayn/v2rayN/ServiceLib/Base/MyReactiveObject.cs +++ b/v2rayn/v2rayN/ServiceLib/Base/MyReactiveObject.cs @@ -5,7 +5,7 @@ namespace ServiceLib.Base public class MyReactiveObject : ReactiveObject { protected static Config? _config; - protected Func? _updateView; + protected Func>? _updateView; protected NoticeHandler? _noticeHandler; } } \ No newline at end of file diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs index 9f11cebbee..f313e79c92 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs @@ -15,7 +15,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand SaveServerCmd { get; } public bool IsModified { get; set; } - public AddServer2ViewModel(ProfileItem profileItem, Func? updateView) + public AddServer2ViewModel(ProfileItem profileItem, Func>? updateView) { _noticeHandler = Locator.Current.GetService(); _config = LazyConfig.Instance.Config; @@ -30,9 +30,9 @@ namespace ServiceLib.ViewModels SelectedSource = JsonUtils.DeepCopy(profileItem); } - BrowseServerCmd = ReactiveCommand.Create(() => + BrowseServerCmd = ReactiveCommand.CreateFromTask(async () => { - _updateView?.Invoke(EViewAction.BrowseServer, null); + await _updateView?.Invoke(EViewAction.BrowseServer, null); }); EditServerCmd = ReactiveCommand.Create(() => @@ -42,11 +42,11 @@ namespace ServiceLib.ViewModels SaveServerCmd = ReactiveCommand.Create(() => { - SaveServer(); + SaveServerAsync(); }); } - private void SaveServer() + private async Task SaveServerAsync() { string remarks = SelectedSource.remarks; if (Utils.IsNullOrEmpty(remarks)) @@ -64,7 +64,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.EditCustomServer(_config, SelectedSource) == 0) { _noticeHandler?.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index 889de9b2d9..f1dcee79d3 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -12,7 +12,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand SaveCmd { get; } - public AddServerViewModel(ProfileItem profileItem, Func? updateView) + public AddServerViewModel(ProfileItem profileItem, Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -33,11 +33,11 @@ namespace ServiceLib.ViewModels SaveCmd = ReactiveCommand.Create(() => { - SaveServer(); + SaveServerAsync(); }); } - private void SaveServer() + private async Task SaveServerAsync() { if (Utils.IsNullOrEmpty(SelectedSource.remarks)) { @@ -83,7 +83,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.AddServer(_config, SelectedSource) == 0) { _noticeHandler?.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index e733ce6a4e..5adf7fc939 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -25,7 +25,7 @@ namespace ServiceLib.ViewModels [Reactive] public bool AutoRefresh { get; set; } - public ClashConnectionsViewModel(Func? updateView) + public ClashConnectionsViewModel(Func>? updateView) { _config = LazyConfig.Instance.Config; _updateView = updateView; @@ -99,14 +99,14 @@ namespace ServiceLib.ViewModels private void GetClashConnections() { - ClashApiHandler.Instance.GetClashConnections(_config, (it) => + ClashApiHandler.Instance.GetClashConnections(_config, async (it) => { if (it == null) { return; } - _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections); + await _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections); }); } diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index ffdd8562b7..5fb095c198 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -42,7 +42,7 @@ namespace ServiceLib.ViewModels [Reactive] public bool AutoRefresh { get; set; } - public ClashProxiesViewModel(Func? updateView) + public ClashProxiesViewModel(Func>? updateView) { _noticeHandler = Locator.Current.GetService(); _config = LazyConfig.Instance.Config; @@ -167,7 +167,7 @@ namespace ServiceLib.ViewModels private void GetClashProxies(bool refreshUI) { - ClashApiHandler.Instance.GetClashProxies(_config, (it, it2) => + ClashApiHandler.Instance.GetClashProxies(_config, async (it, it2) => { //UpdateHandler(false, "Refresh Clash Proxies"); _proxies = it?.proxies; @@ -179,7 +179,7 @@ namespace ServiceLib.ViewModels } if (refreshUI) { - _updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null); + await _updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null); } }); } @@ -386,7 +386,7 @@ namespace ServiceLib.ViewModels { //UpdateHandler(false, "Clash Proxies Latency Test"); - ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) => + ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), async (item, result) => { if (item == null) { @@ -398,7 +398,7 @@ namespace ServiceLib.ViewModels return; } - _updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result }); + await _updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result }); }); } diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index 42a4f5a406..b5bbb399d3 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -21,7 +21,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand ImportDefConfig4V2rayCmd { get; } public ReactiveCommand ImportDefConfig4SingboxCmd { get; } - public DNSSettingViewModel(Func? updateView) + public DNSSettingViewModel(Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -41,7 +41,7 @@ namespace ServiceLib.ViewModels SaveCmd = ReactiveCommand.Create(() => { - SaveSetting(); + SaveSettingAsync(); }); ImportDefConfig4V2rayCmd = ReactiveCommand.Create(() => @@ -56,7 +56,7 @@ namespace ServiceLib.ViewModels }); } - private void SaveSetting() + private async Task SaveSettingAsync() { if (!Utils.IsNullOrEmpty(normalDNS)) { @@ -107,7 +107,7 @@ namespace ServiceLib.ViewModels ConfigHandler.SaveDNSItems(_config, item2); _noticeHandler?.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } } } \ No newline at end of file diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 6073e9b285..b80db10308 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -152,13 +152,13 @@ namespace ServiceLib.ViewModels #region Init - public MainWindowViewModel(Func? updateView) + public MainWindowViewModel(Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); _updateView = updateView; - MessageBus.Current.Listen(Global.CommandRefreshProfiles).Subscribe(x => _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null)); + MessageBus.Current.Listen(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null)); SelectedRouting = new(); SelectedServer = new(); @@ -170,7 +170,7 @@ namespace ServiceLib.ViewModels this.WhenAnyValue( x => x.SelectedRouting, y => y != null && !y.remarks.IsNullOrEmpty()) - .Subscribe(c => RoutingSelectedChanged(c)); + .Subscribe(c => RoutingSelectedChangedAsync(c)); this.WhenAnyValue( x => x.SelectedServer, @@ -191,57 +191,57 @@ namespace ServiceLib.ViewModels //servers AddVmessServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.VMess); + AddServerAsync(true, EConfigType.VMess); }); AddVlessServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.VLESS); + AddServerAsync(true, EConfigType.VLESS); }); AddShadowsocksServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Shadowsocks); + AddServerAsync(true, EConfigType.Shadowsocks); }); AddSocksServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Socks); + AddServerAsync(true, EConfigType.Socks); }); AddHttpServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Http); + AddServerAsync(true, EConfigType.Http); }); AddTrojanServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Trojan); + AddServerAsync(true, EConfigType.Trojan); }); AddHysteria2ServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Hysteria2); + AddServerAsync(true, EConfigType.Hysteria2); }); AddTuicServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Tuic); + AddServerAsync(true, EConfigType.Tuic); }); AddWireguardServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Wireguard); + AddServerAsync(true, EConfigType.Wireguard); }); AddCustomServerCmd = ReactiveCommand.Create(() => { - AddServer(true, EConfigType.Custom); + AddServerAsync(true, EConfigType.Custom); }); AddServerViaClipboardCmd = ReactiveCommand.Create(() => { - AddServerViaClipboard(null); + AddServerViaClipboardAsync(null); }); - AddServerViaScanCmd = ReactiveCommand.Create(() => + AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () => { - _updateView?.Invoke(EViewAction.ScanScreenTask, null); + await _updateView?.Invoke(EViewAction.ScanScreenTask, null); }); //Subscription SubSettingCmd = ReactiveCommand.Create(() => { - SubSetting(); + SubSettingAsync(); }); SubUpdateCmd = ReactiveCommand.Create(() => @@ -264,19 +264,19 @@ namespace ServiceLib.ViewModels //Setting OptionSettingCmd = ReactiveCommand.Create(() => { - OptionSetting(); + OptionSettingAsync(); }); RoutingSettingCmd = ReactiveCommand.Create(() => { - RoutingSetting(); + RoutingSettingAsync(); }); DNSSettingCmd = ReactiveCommand.Create(() => { - DNSSetting(); + DNSSettingAsync(); }); - GlobalHotkeySettingCmd = ReactiveCommand.Create(() => + GlobalHotkeySettingCmd = ReactiveCommand.CreateFromTask(async () => { - if (_updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true) + if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true) { _noticeHandler?.Enqueue(ResUI.OperationSuccess); } @@ -322,9 +322,9 @@ namespace ServiceLib.ViewModels Reload(); }); - NotifyLeftClickCmd = ReactiveCommand.Create(() => + NotifyLeftClickCmd = ReactiveCommand.CreateFromTask(async () => { - _updateView?.Invoke(EViewAction.ShowHideWindow, null); + await _updateView?.Invoke(EViewAction.ShowHideWindow, null); }); //System proxy @@ -369,7 +369,7 @@ namespace ServiceLib.ViewModels //RefreshServers(); Reload(); - ChangeSystemProxyStatus(_config.systemProxyItem.sysProxyType, true); + ChangeSystemProxyStatusAsync(_config.systemProxyItem.sysProxyType, true); } #endregion Init @@ -402,7 +402,7 @@ namespace ServiceLib.ViewModels } if (_config.uiItem.enableAutoAdjustMainLvColWidth) { - Locator.Current.GetService()?.AutofitColumnWidth(); + Locator.Current.GetService()?.AutofitColumnWidthAsync(); } } } @@ -434,13 +434,13 @@ namespace ServiceLib.ViewModels } } - public void MyAppExit(bool blWindowsShutDown) + public async Task MyAppExitAsync(bool blWindowsShutDown) { try { Logging.SaveLog("MyAppExit Begin"); //if (blWindowsShutDown) - _updateView?.Invoke(EViewAction.UpdateSysProxy, true); + await _updateView?.Invoke(EViewAction.UpdateSysProxy, true); ConfigHandler.SaveConfig(_config); ProfileExHandler.Instance.SaveTo(); @@ -453,7 +453,7 @@ namespace ServiceLib.ViewModels catch { } finally { - _updateView?.Invoke(EViewAction.Shutdown, null); + await _updateView?.Invoke(EViewAction.Shutdown, null); } } @@ -519,7 +519,7 @@ namespace ServiceLib.ViewModels #region Add Servers - public void AddServer(bool blNew, EConfigType eConfigType) + public async Task AddServerAsync(bool blNew, EConfigType eConfigType) { ProfileItem item = new() { @@ -531,11 +531,11 @@ namespace ServiceLib.ViewModels bool? ret = false; if (eConfigType == EConfigType.Custom) { - ret = _updateView?.Invoke(EViewAction.AddServer2Window, item); + ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item); } else { - ret = _updateView?.Invoke(EViewAction.AddServerWindow, item); + ret = await _updateView?.Invoke(EViewAction.AddServerWindow, item); } if (ret == true) { @@ -547,11 +547,11 @@ namespace ServiceLib.ViewModels } } - public void AddServerViaClipboard(string? clipboardData) + public async Task AddServerViaClipboardAsync(string? clipboardData) { if (clipboardData == null) { - _updateView?.Invoke(EViewAction.AddServerViaClipboard, null); + await _updateView?.Invoke(EViewAction.AddServerViaClipboard, null); return; } int ret = ConfigHandler.AddBatchServers(_config, clipboardData, _config.subIndexId, false); @@ -629,7 +629,7 @@ namespace ServiceLib.ViewModels { return; } - (new UpdateHandler()).RunAvailabilityCheck((bool success, string msg) => + (new UpdateHandler()).RunAvailabilityCheck(async (bool success, string msg) => { _noticeHandler?.SendMessage(msg, true); @@ -637,7 +637,7 @@ namespace ServiceLib.ViewModels { return; } - _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg); + await _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg); }); } @@ -650,9 +650,9 @@ namespace ServiceLib.ViewModels #region Subscription - private void SubSetting() + private async Task SubSettingAsync() { - if (_updateView?.Invoke(EViewAction.SubSettingWindow, null) == true) + if (await _updateView?.Invoke(EViewAction.SubSettingWindow, null) == true) { RefreshSubscriptions(); } @@ -667,9 +667,9 @@ namespace ServiceLib.ViewModels #region Setting - private void OptionSetting() + private async Task OptionSettingAsync() { - var ret = _updateView?.Invoke(EViewAction.OptionSettingWindow, null); + var ret = await _updateView?.Invoke(EViewAction.OptionSettingWindow, null); if (ret == true) { //RefreshServers(); @@ -677,9 +677,9 @@ namespace ServiceLib.ViewModels } } - private void RoutingSetting() + private async Task RoutingSettingAsync() { - var ret = _updateView?.Invoke(EViewAction.RoutingSettingWindow, null); + var ret = await _updateView?.Invoke(EViewAction.RoutingSettingWindow, null); if (ret == true) { ConfigHandler.InitBuiltinRouting(_config); @@ -689,9 +689,9 @@ namespace ServiceLib.ViewModels } } - private void DNSSetting() + private async Task DNSSettingAsync() { - var ret = _updateView?.Invoke(EViewAction.DNSSettingWindow, null); + var ret = await _updateView?.Invoke(EViewAction.DNSSettingWindow, null); if (ret == true) { Reload(); @@ -711,7 +711,7 @@ namespace ServiceLib.ViewModels try { Process.Start(startInfo); - MyAppExit(false); + MyAppExitAsync(false); } catch { } } @@ -742,7 +742,7 @@ namespace ServiceLib.ViewModels process.Start(); if (process.Id > 0) { - MyAppExit(false); + MyAppExitAsync(false); } } catch (Exception ex) @@ -796,17 +796,17 @@ namespace ServiceLib.ViewModels { BlReloadEnabled = false; - LoadCore().ContinueWith(task => + LoadCore().ContinueWith(async task => { TestServerAvailability(); - _updateView?.Invoke(EViewAction.DispatcherReload, null); + await _updateView?.Invoke(EViewAction.DispatcherReload, null); }); } public void ReloadResult() { - ChangeSystemProxyStatus(_config.systemProxyItem.sysProxyType, false); + ChangeSystemProxyStatusAsync(_config.systemProxyItem.sysProxyType, false); BlReloadEnabled = true; ShowClashUI = _config.IsRunningCore(ECoreType.clash); if (ShowClashUI) @@ -835,7 +835,7 @@ namespace ServiceLib.ViewModels { ConfigHandler.SaveConfig(_config, false); - ChangeSystemProxyStatus(ESysProxyType.ForcedClear, false); + ChangeSystemProxyStatusAsync(ESysProxyType.ForcedClear, false); _coreHandler.CoreStop(); } @@ -851,15 +851,15 @@ namespace ServiceLib.ViewModels return; } _config.systemProxyItem.sysProxyType = type; - ChangeSystemProxyStatus(type, true); + ChangeSystemProxyStatusAsync(type, true); SystemProxySelected = (int)_config.systemProxyItem.sysProxyType; ConfigHandler.SaveConfig(_config, false); } - private void ChangeSystemProxyStatus(ESysProxyType type, bool blChange) + private async Task ChangeSystemProxyStatusAsync(ESysProxyType type, bool blChange) { - _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false); + await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false); _noticeHandler?.SendMessage($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}", true); BlSystemProxyClear = (type == ESysProxyType.ForcedClear); @@ -871,7 +871,7 @@ namespace ServiceLib.ViewModels if (blChange) { - _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); + await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); } } @@ -896,7 +896,7 @@ namespace ServiceLib.ViewModels } } - private void RoutingSelectedChanged(bool c) + private async Task RoutingSelectedChangedAsync(bool c) { if (!c) { @@ -922,7 +922,7 @@ namespace ServiceLib.ViewModels { _noticeHandler?.SendMessage(ResUI.TipChangeRouting, true); Reload(); - _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); + await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); } } @@ -1001,9 +1001,9 @@ namespace ServiceLib.ViewModels { Observable.Range(1, 1) .Delay(TimeSpan.FromSeconds(1)) - .Subscribe(x => + .Subscribe(async x => { - _updateView?.Invoke(EViewAction.ShowHideWindow, false); + await _updateView?.Invoke(EViewAction.ShowHideWindow, false); }); } } diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index 8dc332f3b6..a2221486a1 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -100,7 +100,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand SaveCmd { get; } - public OptionSettingViewModel(Func? updateView) + public OptionSettingViewModel(Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -190,7 +190,7 @@ namespace ServiceLib.ViewModels SaveCmd = ReactiveCommand.Create(() => { - SaveSetting(); + SaveSettingAsync(); }); } @@ -246,7 +246,7 @@ namespace ServiceLib.ViewModels }); } - private void SaveSetting() + private async Task SaveSettingAsync() { if (Utils.IsNullOrEmpty(localPort.ToString()) || !Utils.IsNumeric(localPort.ToString()) || localPort <= 0 || localPort >= Global.MaxPort) @@ -343,7 +343,7 @@ namespace ServiceLib.ViewModels { _noticeHandler?.Enqueue(ResUI.OperationSuccess); } - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 4611747716..88abe2d784 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -95,13 +95,13 @@ namespace ServiceLib.ViewModels #region Init - public ProfilesViewModel(Func? updateView) + public ProfilesViewModel(Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); _updateView = updateView; - MessageBus.Current.Listen(Global.CommandRefreshProfiles).Subscribe(x => _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null)); + MessageBus.Current.Listen(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null)); SelectedProfile = new(); SelectedSub = new(); @@ -120,7 +120,7 @@ namespace ServiceLib.ViewModels this.WhenAnyValue( x => x.SelectedSub, y => y != null && !y.remarks.IsNullOrEmpty() && _config.subIndexId != y.id) - .Subscribe(c => SubSelectedChanged(c)); + .Subscribe(c => SubSelectedChangedAsync(c)); this.WhenAnyValue( x => x.SelectedMoveToGroup, y => y != null && !y.remarks.IsNullOrEmpty()) @@ -139,11 +139,11 @@ namespace ServiceLib.ViewModels //servers delete EditServerCmd = ReactiveCommand.Create(() => { - EditServer(EConfigType.Custom); + EditServerAsync(EConfigType.Custom); }, canEditRemove); RemoveServerCmd = ReactiveCommand.Create(() => { - RemoveServer(); + RemoveServerAsync(); }, canEditRemove); RemoveDuplicateServerCmd = ReactiveCommand.Create(() => { @@ -159,7 +159,7 @@ namespace ServiceLib.ViewModels }, canEditRemove); ShareServerCmd = ReactiveCommand.Create(() => { - ShareServer(); + ShareServerAsync(); }, canEditRemove); SetDefaultMultipleServerCmd = ReactiveCommand.Create(() => { @@ -212,29 +212,29 @@ namespace ServiceLib.ViewModels //servers export Export2ClientConfigCmd = ReactiveCommand.Create(() => { - Export2ClientConfig(false); + Export2ClientConfigAsync(false); }, canEditRemove); Export2ClientConfigClipboardCmd = ReactiveCommand.Create(() => { - Export2ClientConfig(true); + Export2ClientConfigAsync(true); }, canEditRemove); Export2ShareUrlCmd = ReactiveCommand.Create(() => { - Export2ShareUrl(false); + Export2ShareUrlAsync(false); }, canEditRemove); Export2ShareUrlBase64Cmd = ReactiveCommand.Create(() => { - Export2ShareUrl(true); + Export2ShareUrlAsync(true); }, canEditRemove); //Subscription AddSubCmd = ReactiveCommand.Create(() => { - EditSub(true); + EditSubAsync(true); }); EditSubCmd = ReactiveCommand.Create(() => { - EditSub(false); + EditSubAsync(false); }); #endregion WhenAnyValue && ReactiveCommand @@ -308,16 +308,16 @@ namespace ServiceLib.ViewModels } } - public void AutofitColumnWidth() + public async Task AutofitColumnWidthAsync() { - _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null); + await _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null); } #endregion Actions #region Servers && Groups - private void SubSelectedChanged(bool c) + private async Task SubSelectedChangedAsync(bool c) { if (!c) { @@ -327,7 +327,7 @@ namespace ServiceLib.ViewModels RefreshServers(); - _updateView?.Invoke(EViewAction.ProfilesFocus, null); + await _updateView?.Invoke(EViewAction.ProfilesFocus, null); } private void ServerFilterChanged(bool c) @@ -420,7 +420,7 @@ namespace ServiceLib.ViewModels return 0; } - public void EditServer(EConfigType eConfigType) + public async Task EditServerAsync(EConfigType eConfigType) { if (Utils.IsNullOrEmpty(SelectedProfile?.indexId)) { @@ -437,11 +437,11 @@ namespace ServiceLib.ViewModels bool? ret = false; if (eConfigType == EConfigType.Custom) { - ret = _updateView?.Invoke(EViewAction.AddServer2Window, item); + ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item); } else { - ret = _updateView?.Invoke(EViewAction.AddServerWindow, item); + ret = await _updateView?.Invoke(EViewAction.AddServerWindow, item); } if (ret == true) { @@ -453,13 +453,13 @@ namespace ServiceLib.ViewModels } } - public void RemoveServer() + public async Task RemoveServerAsync() { if (GetProfileItems(out List lstSelecteds, true) < 0) { return; } - if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false) + if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) { return; } @@ -546,7 +546,7 @@ namespace ServiceLib.ViewModels SetDefaultServer(SelectedServer.ID); } - public void ShareServer() + public async Task ShareServerAsync() { var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId); if (item is null) @@ -560,7 +560,7 @@ namespace ServiceLib.ViewModels return; } - _updateView?.Invoke(EViewAction.ShareServer, url); + await _updateView?.Invoke(EViewAction.ShareServer, url); } private void SetDefaultMultipleServer(ECoreType coreType) @@ -679,7 +679,7 @@ namespace ServiceLib.ViewModels _speedtestHandler?.ExitLoop(); } - private void Export2ClientConfig(bool blClipboard) + private async Task Export2ClientConfigAsync(bool blClipboard) { var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId); if (item is null) @@ -695,13 +695,13 @@ namespace ServiceLib.ViewModels } else { - _updateView?.Invoke(EViewAction.SetClipboardData, content); + await _updateView?.Invoke(EViewAction.SetClipboardData, content); _noticeHandler?.SendMessage(ResUI.OperationSuccess); } } else { - _updateView?.Invoke(EViewAction.SaveFileDialog, item); + await _updateView?.Invoke(EViewAction.SaveFileDialog, item); } } @@ -722,7 +722,7 @@ namespace ServiceLib.ViewModels } } - public void Export2ShareUrl(bool blEncode) + public async Task Export2ShareUrlAsync(bool blEncode) { if (GetProfileItems(out List lstSelecteds, true) < 0) { @@ -744,11 +744,11 @@ namespace ServiceLib.ViewModels { if (blEncode) { - _updateView?.Invoke(EViewAction.SetClipboardData, Utils.Base64Encode(sb.ToString())); + await _updateView?.Invoke(EViewAction.SetClipboardData, Utils.Base64Encode(sb.ToString())); } else { - _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString()); + await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString()); } _noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully); } @@ -758,7 +758,7 @@ namespace ServiceLib.ViewModels #region Subscription - private void EditSub(bool blNew) + private async Task EditSubAsync(bool blNew) { SubItem item; if (blNew) @@ -773,10 +773,10 @@ namespace ServiceLib.ViewModels return; } } - if (_updateView?.Invoke(EViewAction.SubEditWindow, item) == true) + if (await _updateView?.Invoke(EViewAction.SubEditWindow, item) == true) { RefreshSubscriptions(); - SubSelectedChanged(true); + SubSelectedChangedAsync(true); } } diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs index 60294a4202..8acfc234dc 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs @@ -27,7 +27,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand SaveCmd { get; } - public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func? updateView) + public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -51,11 +51,11 @@ namespace ServiceLib.ViewModels SaveCmd = ReactiveCommand.Create(() => { - SaveRules(); + SaveRulesAsync(); }); } - private void SaveRules() + private async Task SaveRulesAsync() { Domain = Utils.Convert2Comma(Domain); IP = Utils.Convert2Comma(IP); @@ -88,7 +88,7 @@ namespace ServiceLib.ViewModels return; } //_noticeHandler?.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } } } \ No newline at end of file diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index d76e26e056..fa0a57ef0f 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -34,7 +34,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand SaveCmd { get; } - public RoutingRuleSettingViewModel(RoutingItem routingItem, Func? updateView) + public RoutingRuleSettingViewModel(RoutingItem routingItem, Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -60,15 +60,15 @@ namespace ServiceLib.ViewModels RuleAddCmd = ReactiveCommand.Create(() => { - RuleEdit(true); + RuleEditAsync(true); }); - ImportRulesFromFileCmd = ReactiveCommand.Create(() => + ImportRulesFromFileCmd = ReactiveCommand.CreateFromTask(async () => { - _updateView?.Invoke(EViewAction.ImportRulesFromFile, null); + await _updateView?.Invoke(EViewAction.ImportRulesFromFile, null); }); ImportRulesFromClipboardCmd = ReactiveCommand.Create(() => { - ImportRulesFromClipboard(null); + ImportRulesFromClipboardAsync(null); }); ImportRulesFromUrlCmd = ReactiveCommand.Create(() => { @@ -77,11 +77,11 @@ namespace ServiceLib.ViewModels RuleRemoveCmd = ReactiveCommand.Create(() => { - RuleRemove(); + RuleRemoveAsync(); }, canEditRemove); RuleExportSelectedCmd = ReactiveCommand.Create(() => { - RuleExportSelected(); + RuleExportSelectedAsync(); }, canEditRemove); MoveTopCmd = ReactiveCommand.Create(() => @@ -103,7 +103,7 @@ namespace ServiceLib.ViewModels SaveCmd = ReactiveCommand.Create(() => { - SaveRouting(); + SaveRoutingAsync(); }); } @@ -129,7 +129,7 @@ namespace ServiceLib.ViewModels } } - public void RuleEdit(bool blNew) + public async Task RuleEditAsync(bool blNew) { RulesItem? item; if (blNew) @@ -144,7 +144,7 @@ namespace ServiceLib.ViewModels return; } } - if (_updateView?.Invoke(EViewAction.RoutingRuleDetailsWindow, item) == true) + if (await _updateView?.Invoke(EViewAction.RoutingRuleDetailsWindow, item) == true) { if (blNew) { @@ -154,14 +154,14 @@ namespace ServiceLib.ViewModels } } - public void RuleRemove() + public async Task RuleRemoveAsync() { if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty()) { _noticeHandler?.Enqueue(ResUI.PleaseSelectRules); return; } - if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false) + if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) { return; } @@ -177,7 +177,7 @@ namespace ServiceLib.ViewModels RefreshRulesItems(); } - public void RuleExportSelected() + public async Task RuleExportSelectedAsync() { if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty()) { @@ -197,7 +197,7 @@ namespace ServiceLib.ViewModels } if (lst.Count > 0) { - _updateView?.Invoke(EViewAction.SetClipboardData, JsonUtils.Serialize(lst)); + await _updateView?.Invoke(EViewAction.SetClipboardData, JsonUtils.Serialize(lst)); } } @@ -221,7 +221,7 @@ namespace ServiceLib.ViewModels } } - private void SaveRouting() + private async Task SaveRoutingAsync() { string remarks = SelectedRouting.remarks; if (Utils.IsNullOrEmpty(remarks)) @@ -240,7 +240,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.SaveRoutingItem(_config, item) == 0) { _noticeHandler?.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { @@ -250,7 +250,7 @@ namespace ServiceLib.ViewModels #region Import rules - public void ImportRulesFromFile(string fileName) + public async Task ImportRulesFromFileAsync(string fileName) { if (Utils.IsNullOrEmpty(fileName)) { @@ -262,29 +262,30 @@ namespace ServiceLib.ViewModels { return; } - - if (AddBatchRoutingRules(SelectedRouting, result) == 0) + var ret = await AddBatchRoutingRulesAsync(SelectedRouting, result); + if (ret == 0) { RefreshRulesItems(); _noticeHandler?.Enqueue(ResUI.OperationSuccess); } } - public void ImportRulesFromClipboard(string? clipboardData) + public async Task ImportRulesFromClipboardAsync(string? clipboardData) { if (clipboardData == null) { - _updateView?.Invoke(EViewAction.ImportRulesFromClipboard, null); + await _updateView?.Invoke(EViewAction.ImportRulesFromClipboard, null); return; } - if (AddBatchRoutingRules(SelectedRouting, clipboardData) == 0) + var ret = await AddBatchRoutingRulesAsync(SelectedRouting, clipboardData); + if (ret == 0) { RefreshRulesItems(); _noticeHandler?.Enqueue(ResUI.OperationSuccess); } } - private void ImportRulesFromUrl() + private async void ImportRulesFromUrl() { var url = SelectedRouting.url; if (Utils.IsNullOrEmpty(url)) @@ -294,18 +295,19 @@ namespace ServiceLib.ViewModels } DownloadHandler downloadHandle = new DownloadHandler(); - var result = downloadHandle.TryDownloadString(url, true, "").Result; - if (AddBatchRoutingRules(SelectedRouting, result) == 0) + var result = await downloadHandle.TryDownloadString(url, true, ""); + var ret = await AddBatchRoutingRulesAsync(SelectedRouting, result); + if (ret == 0) { RefreshRulesItems(); _noticeHandler?.Enqueue(ResUI.OperationSuccess); } } - private int AddBatchRoutingRules(RoutingItem routingItem, string? clipboardData) + private async Task AddBatchRoutingRulesAsync(RoutingItem routingItem, string? clipboardData) { bool blReplace = false; - if (_updateView?.Invoke(EViewAction.AddBatchRoutingRulesYesNo, null) == false) + if (await _updateView?.Invoke(EViewAction.AddBatchRoutingRulesYesNo, null) == false) { blReplace = true; } diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index bf059948c3..ce0ba95355 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -65,7 +65,7 @@ namespace ServiceLib.ViewModels #endregion Reactive - public RoutingSettingViewModel(Func? updateView) + public RoutingSettingViewModel(Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -98,11 +98,11 @@ namespace ServiceLib.ViewModels RoutingAdvancedAddCmd = ReactiveCommand.Create(() => { - RoutingAdvancedEdit(true); + RoutingAdvancedEditAsync(true); }); RoutingAdvancedRemoveCmd = ReactiveCommand.Create(() => { - RoutingAdvancedRemove(); + RoutingAdvancedRemoveAsync(); }, canEditRemove); RoutingAdvancedSetDefaultCmd = ReactiveCommand.Create(() => { @@ -115,7 +115,7 @@ namespace ServiceLib.ViewModels SaveCmd = ReactiveCommand.Create(() => { - SaveRouting(); + SaveRoutingAsync(); }); } @@ -189,7 +189,7 @@ namespace ServiceLib.ViewModels } } - private void SaveRouting() + private async Task SaveRoutingAsync() { _config.routingBasicItem.domainStrategy = domainStrategy; _config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced; @@ -201,7 +201,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.SaveConfig(_config) == 0) { _noticeHandler?.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { @@ -223,7 +223,7 @@ namespace ServiceLib.ViewModels _noticeHandler?.Enqueue(ResUI.OperationSuccess); } - public void RoutingAdvancedEdit(bool blNew) + public async Task RoutingAdvancedEditAsync(bool blNew) { RoutingItem item; if (blNew) @@ -238,21 +238,21 @@ namespace ServiceLib.ViewModels return; } } - if (_updateView?.Invoke(EViewAction.RoutingRuleSettingWindow, item) == true) + if (await _updateView?.Invoke(EViewAction.RoutingRuleSettingWindow, item) == true) { RefreshRoutingItems(); IsModified = true; } } - public void RoutingAdvancedRemove() + public async Task RoutingAdvancedRemoveAsync() { if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty()) { _noticeHandler?.Enqueue(ResUI.PleaseSelectRules); return; } - if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false) + if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) { return; } diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs index 6c10ed5117..487f34cea7 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs @@ -12,7 +12,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand SaveCmd { get; } - public SubEditViewModel(SubItem subItem, Func? updateView) + public SubEditViewModel(SubItem subItem, Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -29,11 +29,11 @@ namespace ServiceLib.ViewModels SaveCmd = ReactiveCommand.Create(() => { - SaveSub(); + SaveSubAsync(); }); } - private void SaveSub() + private async Task SaveSubAsync() { string remarks = SelectedSource.remarks; if (Utils.IsNullOrEmpty(remarks)) @@ -45,7 +45,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.AddSubItem(_config, SelectedSource) == 0) { _noticeHandler?.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + await _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs index 36f6387428..632cddf4f2 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs @@ -23,7 +23,7 @@ namespace ServiceLib.ViewModels public ReactiveCommand SubShareCmd { get; } public bool IsModified { get; set; } - public SubSettingViewModel(Func? updateView) + public SubSettingViewModel(Func>? updateView) { _config = LazyConfig.Instance.Config; _noticeHandler = Locator.Current.GetService(); @@ -39,19 +39,19 @@ namespace ServiceLib.ViewModels SubAddCmd = ReactiveCommand.Create(() => { - EditSub(true); + EditSubAsync(true); }); SubDeleteCmd = ReactiveCommand.Create(() => { - DeleteSub(); + DeleteSubAsync(); }, canEditRemove); - SubEditCmd = ReactiveCommand.Create(() => + SubEditCmd = ReactiveCommand.CreateFromTask(async () => { - EditSub(false); + await EditSubAsync(false); }, canEditRemove); - SubShareCmd = ReactiveCommand.Create(() => + SubShareCmd = ReactiveCommand.CreateFromTask(async () => { - _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url); + await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url); }, canEditRemove); } @@ -61,7 +61,7 @@ namespace ServiceLib.ViewModels _subItems.AddRange(LazyConfig.Instance.SubItems().OrderBy(t => t.sort)); } - public void EditSub(bool blNew) + public async Task EditSubAsync(bool blNew) { SubItem item; if (blNew) @@ -76,16 +76,16 @@ namespace ServiceLib.ViewModels return; } } - if (_updateView?.Invoke(EViewAction.SubEditWindow, item) == true) + if (await _updateView?.Invoke(EViewAction.SubEditWindow, item) == true) { RefreshSubItems(); IsModified = true; } } - private void DeleteSub() + private async Task DeleteSubAsync() { - if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false) + if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) { return; } diff --git a/v2rayn/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index b30384189d..b9bdf56aad 100644 --- a/v2rayn/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -37,7 +37,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -54,7 +54,7 @@ namespace v2rayN.Views break; } - return true; + return await Task.FromResult(true); } private void Window_Loaded(object sender, RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index e2da0157da..f9607334a0 100644 --- a/v2rayn/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -220,7 +220,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -228,7 +228,7 @@ namespace v2rayN.Views this.DialogResult = true; break; } - return true; + return await Task.FromResult(true); } private void Window_Loaded(object sender, RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs index d3c61617ee..c90fcfad0b 100644 --- a/v2rayn/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs @@ -29,7 +29,7 @@ namespace v2rayN.Views }); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -42,7 +42,7 @@ namespace v2rayN.Views break; } - return true; + return await Task.FromResult(true); } private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs index 0715a30c73..5142f72bfc 100644 --- a/v2rayn/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs @@ -39,7 +39,7 @@ namespace v2rayN.Views }); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -60,7 +60,7 @@ namespace v2rayN.Views break; } - return true; + return await Task.FromResult(true); } private void ProxiesView_KeyDown(object sender, KeyEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs index 08c555135a..0b029e3562 100644 --- a/v2rayn/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs @@ -53,7 +53,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -61,7 +61,7 @@ namespace v2rayN.Views this.DialogResult = true; break; } - return true; + return await Task.FromResult(true); } private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 82e60c5197..baecf5065e 100644 --- a/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -204,7 +204,7 @@ namespace v2rayN.Views }), DispatcherPriority.Normal); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -291,11 +291,11 @@ namespace v2rayN.Views case EViewAction.AddServerViaClipboard: var clipboardData = WindowsUtils.GetClipboardData(); - ViewModel?.AddServerViaClipboard(clipboardData); + ViewModel?.AddServerViaClipboardAsync(clipboardData); break; } - return true; + return await Task.FromResult(true); } private void OnHotkeyHandler(EGlobalHotkey e) @@ -336,14 +336,14 @@ namespace v2rayN.Views tbNotify.Dispose(); StorageUI(); - ViewModel?.MyAppExit(false); + ViewModel?.MyAppExitAsync(false); } private void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e) { Logging.SaveLog("Current_SessionEnding"); StorageUI(); - ViewModel?.MyAppExit(true); + ViewModel?.MyAppExitAsync(true); } private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e) @@ -354,7 +354,7 @@ namespace v2rayN.Views { case Key.V: var clipboardData = WindowsUtils.GetClipboardData(); - ViewModel?.AddServerViaClipboard(clipboardData); + ViewModel?.AddServerViaClipboardAsync(clipboardData); break; case Key.S: diff --git a/v2rayn/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs index c5549a30b0..0bdd2d353e 100644 --- a/v2rayn/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs @@ -168,7 +168,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -177,7 +177,7 @@ namespace v2rayN.Views this.DialogResult = true; break; } - return true; + return await Task.FromResult(true); } private List GetFonts(string path) diff --git a/v2rayn/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index 3f2530ebad..f2fad81db3 100644 --- a/v2rayn/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -98,7 +98,7 @@ namespace v2rayN.Views StorageUI(); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -173,7 +173,7 @@ namespace v2rayN.Views break; } - return true; + return await Task.FromResult(true); } public async void ShareServer(string url) @@ -206,7 +206,7 @@ namespace v2rayN.Views } else { - ViewModel?.EditServer(EConfigType.Custom); + ViewModel?.EditServerAsync(EConfigType.Custom); } } @@ -238,15 +238,15 @@ namespace v2rayN.Views break; case Key.C: - ViewModel?.Export2ShareUrl(false); + ViewModel?.Export2ShareUrlAsync(false); break; case Key.D: - ViewModel?.EditServer(EConfigType.Custom); + ViewModel?.EditServerAsync(EConfigType.Custom); break; case Key.F: - ViewModel?.ShareServer(); + ViewModel?.ShareServerAsync(); break; case Key.O: @@ -274,7 +274,7 @@ namespace v2rayN.Views } else if (e.Key == Key.Delete) { - ViewModel?.RemoveServer(); + ViewModel?.RemoveServerAsync(); } else if (e.Key == Key.T) { diff --git a/v2rayn/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs index 8235ccaaae..fe3fef5d60 100644 --- a/v2rayn/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -60,7 +60,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -68,7 +68,7 @@ namespace v2rayN.Views this.DialogResult = true; break; } - return true; + return await Task.FromResult(true); } private void Window_Loaded(object sender, RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs index 62845cc5d5..4e9992b1f9 100644 --- a/v2rayn/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml.cs @@ -60,7 +60,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -95,7 +95,7 @@ namespace v2rayN.Views { return false; } - ViewModel?.ImportRulesFromFile(fileName); + ViewModel?.ImportRulesFromFileAsync(fileName); break; case EViewAction.SetClipboardData: @@ -105,11 +105,11 @@ namespace v2rayN.Views case EViewAction.ImportRulesFromClipboard: var clipboardData = WindowsUtils.GetClipboardData(); - ViewModel?.ImportRulesFromClipboard(clipboardData); + ViewModel?.ImportRulesFromClipboardAsync(clipboardData); break; } - return true; + return await Task.FromResult(true); } private void Window_Loaded(object sender, RoutedEventArgs e) @@ -127,7 +127,7 @@ namespace v2rayN.Views } else if (e.Key == Key.C) { - ViewModel?.RuleExportSelected(); + ViewModel?.RuleExportSelectedAsync(); } } else @@ -150,7 +150,7 @@ namespace v2rayN.Views } else if (e.Key == Key.Delete) { - ViewModel?.RuleRemove(); + ViewModel?.RuleRemoveAsync(); } } } @@ -162,7 +162,7 @@ namespace v2rayN.Views private void LstRules_MouseDoubleClick(object sender, MouseButtonEventArgs e) { - ViewModel?.RuleEdit(false); + ViewModel?.RuleEditAsync(false); } private void menuRuleSelectAll_Click(object sender, System.Windows.RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs index 2696b93091..90f2101f80 100644 --- a/v2rayn/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs @@ -67,7 +67,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -87,7 +87,7 @@ namespace v2rayN.Views if (obj is null) return false; return (new RoutingRuleSettingWindow((RoutingItem)obj)).ShowDialog() ?? false; } - return true; + return await Task.FromResult(true); } private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e) @@ -118,7 +118,7 @@ namespace v2rayN.Views } else if (e.Key == Key.Delete) { - ViewModel?.RoutingAdvancedRemove(); + ViewModel?.RoutingAdvancedRemoveAsync(); } } @@ -134,7 +134,7 @@ namespace v2rayN.Views private void LstRoutings_MouseDoubleClick(object sender, MouseButtonEventArgs e) { - ViewModel?.RoutingAdvancedEdit(false); + ViewModel?.RoutingAdvancedEditAsync(false); } private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs index dff22a38ce..ae27980bd9 100644 --- a/v2rayn/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/SubEditWindow.xaml.cs @@ -39,7 +39,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -47,7 +47,7 @@ namespace v2rayN.Views this.DialogResult = true; break; } - return true; + return await Task.FromResult(true); } private void Window_Loaded(object sender, RoutedEventArgs e) diff --git a/v2rayn/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs index 278b56fb50..f0c385b5ae 100644 --- a/v2rayn/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs @@ -33,7 +33,7 @@ namespace v2rayN.Views WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark); } - private bool UpdateViewHandler(EViewAction action, object? obj) + private async Task UpdateViewHandler(EViewAction action, object? obj) { switch (action) { @@ -57,7 +57,7 @@ namespace v2rayN.Views ShareSub((string)obj); break; } - return true; + return await Task.FromResult(true); } private async void ShareSub(string url) @@ -86,7 +86,7 @@ namespace v2rayN.Views private void LstSubscription_MouseDoubleClick(object sender, MouseButtonEventArgs e) { - ViewModel?.EditSub(false); + ViewModel?.EditSubAsync(false); } private void LstSubscription_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) diff --git a/xray-core/.github/ISSUE_TEMPLATE/bug_report.yml b/xray-core/.github/ISSUE_TEMPLATE/bug_report.yml index 9efeede77f..32f58b1905 100644 --- a/xray-core/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/xray-core/.github/ISSUE_TEMPLATE/bug_report.yml @@ -13,16 +13,14 @@ body: required: true - label: I searched issues and did not find any similar issues. required: true - - type: input - attributes: - label: Version - description: Version of Xray-core - validations: - required: true + - label: The problem can be successfully reproduced in the latest Release + required: true - type: textarea attributes: label: Description - description: Please provide a detailed description of the error. And the information you think valuable. + description: |- + Please provide a detailed description of the error. And the information you think valuable. + If the problem occurs after the update, please provide the **specific** version validations: required: true - type: textarea diff --git a/xray-core/.github/ISSUE_TEMPLATE/bug_report_zh.yml b/xray-core/.github/ISSUE_TEMPLATE/bug_report_zh.yml index 2fd33c566b..201f847e22 100644 --- a/xray-core/.github/ISSUE_TEMPLATE/bug_report_zh.yml +++ b/xray-core/.github/ISSUE_TEMPLATE/bug_report_zh.yml @@ -11,18 +11,16 @@ body: required: true - label: 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。 required: true - - label: 我搜索了issues,没有发现已提出的类似问题。 + - label: 我搜索了 issues, 没有发现已提出的类似问题。 + required: true + - label: 问题在 Release 最新的版本上可以成功复现 required: true - - type: input - attributes: - label: 版本 - description: 使用的Xray-core版本 - validations: - required: true - type: textarea attributes: label: 描述 - description: 请提供错误的详细描述。以及你认为有价值的信息。 + description: |- + 请提供错误的详细描述。以及你认为有价值的信息。 + 如果问题在更新后出现,请提供**具体**出现问题的版本号。 validations: required: true - type: textarea diff --git a/xray-core/go.mod b/xray-core/go.mod index 208763877a..874d26d358 100644 --- a/xray-core/go.mod +++ b/xray-core/go.mod @@ -19,7 +19,7 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.9.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 + github.com/vishvananda/netlink v1.2.1 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.26.0 diff --git a/xray-core/go.sum b/xray-core/go.sum index 2960e875d8..2942ecb8c6 100644 --- a/xray-core/go.sum +++ b/xray-core/go.sum @@ -160,9 +160,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 h1:tkMT5pTye+1NlKIXETU78NXw0fyjnaNHmJyyLyzw8+U= -github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mod h1:cAAsePK2e15YDAMJNyOpGYEWNe4sIghTY7gpz4cX/Ik= -github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/vishvananda/netlink v1.2.1 h1:pfLv/qlJUwOTPvtWREA7c3PI4u81YkqZw1DYhI2HmLA= +github.com/vishvananda/netlink v1.2.1/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= @@ -222,12 +221,12 @@ golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=