Compare commits

..

194 Commits
6.23 ... 6.32

Author SHA1 Message Date
2dust
f5f944aa50 up 6.32 2023-12-29 10:02:24 +08:00
2dust
83b4ab83d1 Improve speed test,add Hy2 and Tuic test 2023-12-29 09:39:55 +08:00
2dust
34f63f9006 Add ipv6 option for Tun mode 2023-12-26 18:13:12 +08:00
2dust
b74188d904 Previous and next proxy 4 sing-box 2023-12-25 16:42:23 +08:00
2dust
51576b54c3 Previous and next proxy setting 2023-12-24 10:34:55 +08:00
2dust
0d5a9fcf4a Previous and next proxy 2023-12-23 20:57:31 +08:00
2dust
b0c5f74edb Refactor 2023-12-23 17:49:39 +08:00
2dust
1ac7661593 Refactor 2023-12-23 10:19:41 +08:00
2dust
caa2c523f4 Remove singbox update geo file 2023-12-22 16:56:09 +08:00
2dust
7b9f1e6788 Refactor 2023-12-22 16:03:25 +08:00
2dust
86f3ed29f9 Adjust cores 2023-12-22 12:13:36 +08:00
2dust
655d411afe Fix something 2023-12-22 09:46:55 +08:00
2dust
f5deb8e168 Code clean 2023-12-19 18:09:11 +08:00
2dust
fcdb61bfbf Code clean 2023-12-19 16:49:45 +08:00
2dust
bd9a4ca094 Added Tuic v5 support (using sing-box) 2023-12-19 16:03:30 +08:00
2dust
e2657e746d UI adjust 2023-12-16 17:45:52 +08:00
2dust
6f5a174231 Update Package Reference 2023-12-16 17:45:29 +08:00
2dust
91e9c0b02b up 6.31 2023-12-03 17:03:33 +08:00
2dust
658ea26ab7 Bug fix 2023-12-03 17:02:34 +08:00
2dust
77b736541e Bug fix 2023-12-01 17:03:49 +08:00
2dust
843b881da6 Merge pull request #4464 from ShiinaRinne/host
feat: 支持导入系统hosts追加至dns设置
2023-12-01 16:21:37 +08:00
2dust
3ca8acc805 Merge pull request #4457 from canmengxian/patch-1
优化自动化编译
2023-12-01 16:02:48 +08:00
ShiinaRinne
63809d4f16 Added: 支持导入系统hosts添加至dns设置中 2023-12-01 12:37:49 +08:00
残梦
557660b16b 优化自动化编译 2023-11-28 23:56:44 +08:00
2dust
12be8bda52 Code clean 2023-11-28 16:07:53 +08:00
2dust
81efd25e0a Added Hysteria2 support (using sing-box) 2023-11-28 15:45:53 +08:00
2dust
7037009ce4 Added Hysteria2 support (using sing-box) 2023-11-27 17:58:34 +08:00
2dust
4a0902d4c8 Bug fix 2023-11-26 10:39:03 +08:00
2dust
ed25ac1748 Merge pull request #4444 from flyoutsea/master
Fixed Issue #3875 that ProxySetting doesn't support PPPoE connection. Remove unnecessary sysproxy.exe.
2023-11-26 10:03:27 +08:00
flyoutsea
55e09ed062 Fix build warnings: unused variable and obsolete dpiAware settings. 2023-11-25 21:48:33 +08:00
flyoutsea
babb548c22 Fixed Issue #3875 that ProxySetting doesn't support PPPoE connection. Remove sysproxy.exe, which is the unnecessary workaround. 2023-11-25 21:29:59 +08:00
2dust
1d0e8434ad up 6.30 2023-11-22 16:47:57 +08:00
2dust
e7b2deb941 In tun mode, do a delay check and restart the core 2023-11-22 16:37:46 +08:00
2dust
2a37a6a28e Merge pull request #4432 from The-Mojoo/master
Add Update CoreTypeName
2023-11-22 16:31:56 +08:00
Jimmy Mo
735ebbe92a Add Update CoreTypeName 2023-11-22 11:48:49 +08:00
2dust
2031729656 Merge pull request #4409 from Dts0/master
Fix the issue of readonly custom config  and add github workflow
2023-11-18 18:06:57 +08:00
zhaojingshi
f39fdc38cb add github workflow
The output can be found in actions->workflow->Artifacts
2023-11-18 10:22:47 +08:00
zhaojingshi
6b62623615 Fixed the issue of readonly custom config
Fixed the issue where importing read-only custom files would cause the service to fail to start
2023-11-18 10:22:37 +08:00
2dust
f3f3dc1951 Adjust some core 2023-11-17 13:38:50 +08:00
2dust
f4dd970f5e Add core hysteria2 2023-11-16 20:08:17 +08:00
2dust
74332c58c5 Adjust some core 2023-11-16 19:56:14 +08:00
2dust
f7ce49020f Update Package Reference 2023-11-16 17:47:32 +08:00
2dust
aaba1f7209 Merge pull request #4405 from ShiinaRinne/patch-1
fix https://github.com/2dust/v2rayN/pull/4287#discussion_r1394166976
2023-11-16 17:37:46 +08:00
ShiinaRinne
a9c7916b3d fix https://github.com/2dust/v2rayN/pull/4287#discussion_r1394166976 2023-11-15 21:01:38 +08:00
2dust
e3c8ccfafe Merge pull request #4385 from ShiinaRinne/font-ttc
Add: 添加TTC格式字体支持
2023-11-10 15:09:34 +08:00
2dust
2a22b65b2d Merge pull request #4321 from hxdhttk/hxdhttk/keyDown
Fix that editing the basic routing settings will trigger unexpected error messages.
2023-11-10 15:06:18 +08:00
2dust
ce5728e2df Merge pull request #4287 from MichaelHinrichs/Switch
Use a switch
2023-11-10 15:03:03 +08:00
2dust
cba82e0e8e Adjust speedtest addr 2023-11-10 15:00:48 +08:00
ShiinaRinne
be30064f9a Merge branch 'master' into font-ttc 2023-11-09 14:07:16 +08:00
ShiinaRinne
1798981380 Update ResUI.zh-Hant.resx 2023-11-09 13:56:27 +08:00
ShiinaRinne
06586d3405 Add: 添加TTC格式字体支持
https://github.com/2dust/v2rayN/issues/4089
2023-11-09 13:03:45 +08:00
Minghao Hu
31bcbd0e13 Do not execute keyboard shorcut on basic routing setting window. 2023-10-12 05:05:30 +08:00
2dust
2652beed88 Merge pull request #4299 from hxdhttk/hxdhttk/notifyUpd
Update the H.NotifyIcon to show default system tooltip for sys tray icon.
2023-09-30 14:25:03 +08:00
Minghao Hu
a2b87b862f Merge branch '2dust:master' into hxdhttk/notifyUpd 2023-09-29 14:38:06 +08:00
NintenHero
85e8d9479e Fix switch 2023-09-25 10:05:56 -05:00
NintenHero
119508a4e3 Use a switch 2023-09-25 04:45:50 -04:00
2dust
3c2da0a225 up 6.29 2023-09-24 16:17:54 +08:00
Minghao Hu
ef79e6adf9 Use latest update. 2023-09-24 02:05:04 +08:00
2dust
528400579a Merge pull request #4255 from crazypeace/master
解决当订阅数量较多时,占用窗口空间太大的问题
2023-09-22 14:57:07 +08:00
2dust
521ce1a487 Merge pull request #4235 from YheonYeung/patch-1
修正繁中用詞
2023-09-22 14:56:17 +08:00
Minghao Hu
014cc9bc16 Update H.NotifyIcon. 2023-09-17 16:10:05 +08:00
crazypeace
34c6c953ac 考虑在更大的屏幕上可以接受更高尺寸的占用
https://zelikk.blogspot.com/2023/09/v2rayn-lstgroup-maxheight.html
2023-09-09 15:59:08 +08:00
crazypeace
40fbbc7c58 设置 订阅/分组 显示空间的最大高度
避免占用过大的窗口面积
https://github.com/2dust/v2rayN/issues/4224
2023-09-09 15:00:59 +08:00
YheonYeung
534c329970 Update ResUI.zh-Hant.resx 2023-09-01 23:42:07 +08:00
YheonYeung
328d728257 Update ResUI.zh-Hant.resx 2023-09-01 23:39:16 +08:00
YheonYeung
fae6d42758 Update ResUI.zh-Hant.resx 2023-09-01 23:33:39 +08:00
YheonYeung
27693f6d23 Update ResUI.zh-Hant.resx 2023-09-01 23:31:24 +08:00
YheonYeung
89c4bab5b9 Update ResUI.zh-Hant.resx 2023-09-01 23:29:19 +08:00
YheonYeung
9d2ff04838 Update ResUI.zh-Hant.resx 2023-09-01 23:27:15 +08:00
YheonYeung
cf00243107 Update ResUI.zh-Hant.resx 2023-09-01 23:25:12 +08:00
YheonYeung
e8019ba7a5 修正繁中用詞 2023-09-01 23:21:10 +08:00
2dust
4f30e3f0e3 Merge pull request #4149 from eltociear/patch-1
fix typo in MainForm.cs
2023-08-02 10:15:55 +08:00
Ikko Eltociear Ashimine
047d08470f fix typo in MainForm.cs
entryOuputPath -> entryOutputPath
2023-08-02 00:33:10 +09:00
2dust
9643695389 Merge pull request #4144 from chika0801/master
修正 juicity 启动参数少了 run
2023-07-31 09:21:33 +08:00
chika0801
5cabec86e7 修正 juicity 启动参数少了 run
它的客户端启动参数是 ./juicity-client run -c config.json

https://github.com/juicity/juicity/blob/main/cmd/client/README.md#run
2023-07-30 21:33:12 +08:00
2dust
f2d0e37255 Merge pull request #4141 from chika0801/master
添加 juicity 作为自定义 core
2023-07-30 18:26:36 +08:00
chika0801
9560851a3f add juicity 2023-07-30 16:37:44 +08:00
chika0801
4aeec1caa1 add juicity 2023-07-30 16:36:48 +08:00
chika0801
ae45b1ef44 Update Global.cs 2023-07-30 16:33:11 +08:00
2dust
aad1b087c9 Up 6.28 2023-07-30 14:30:20 +08:00
2dust
b69c581fa1 Merge pull request #4123 from openGiraffes/master
繁体字典添加
2023-07-30 11:08:24 +08:00
2dust
9eb4d90cd6 Merge pull request #4122 from yu0A/master
Fix timestamps in log TextBox
2023-07-30 11:08:14 +08:00
Ding
958567c2c5 繁體支持 2023-07-24 10:55:45 +08:00
yu0A
f1fc4583ed fix #4121 2023-07-23 21:20:36 +08:00
Ding
f7bfd5f766 upload part1 2023-07-21 17:57:16 +08:00
2dust
aadc3c216a Merge pull request #4055 from meaqese/meaqese-patch-1
Russian lang improvements
2023-07-10 15:27:43 +08:00
2dust
6fd2499daf Merge pull request #4048 from crazypeace/master
解决窗口尺寸大于屏幕尺寸的问题 #
2023-07-10 15:26:20 +08:00
meaqese
f0405f1c5d imporvements 2 2023-07-04 21:16:01 +03:00
crazypeace
1914cb3994 Delete dotnet-desktop.yml 2023-07-03 01:50:27 +08:00
crazypeace
ab38fb572d Update dotnet-desktop.yml 2023-07-02 19:52:42 +08:00
crazypeace
46d7128a6e Update dotnet-desktop.yml 2023-07-02 19:49:09 +08:00
crazypeace
0821884ff3 Create dotnet-desktop.yml 2023-07-02 19:45:15 +08:00
crazypeace
62233281ef 与上游一致 2023-07-02 12:40:01 +08:00
crazypeace
39504502af Update AddServerWindow.xaml.cs 2023-07-02 12:22:17 +08:00
crazypeace
f97530a671 设置窗口的尺寸不大于屏幕的尺寸 2023-07-02 12:15:51 +08:00
crazypeace
0fe7d5e598 Update AddServerWindow.xaml.cs 2023-07-01 04:53:42 +08:00
crazypeace
527362dc9f 初始化窗口宽和高的最大值, 依据工作区的宽和高.
解决在笔记本屏幕上因为DPI较高导致窗口显示不全的问题.
2023-06-30 13:29:43 +08:00
meaqese
1023426c8d Russian imporvements 2023-06-18 12:34:53 +03:00
2dust
4458fd7541 Up 6.27 2023-06-18 16:44:03 +08:00
2dust
f0b03f59ff Up PackageReference 2023-06-18 16:33:18 +08:00
2dust
d5b17b3cfb Update MainWindowViewModel.cs 2023-06-18 16:23:03 +08:00
2dust
9664d1d77f Fix update the pre version 2023-06-18 16:18:50 +08:00
2dust
d329646a52 Merge pull request #3989 from hvvvvvvv/v2rayN_2
Update HotkeyHandler.cs
2023-06-18 09:43:50 +08:00
2dust
8eafe72bb0 Merge pull request #3943 from hsbtr/master
feat: pac rule add chat.openai.com
2023-06-18 09:43:31 +08:00
2dust
c38a0bde65 Optimize interface 2023-06-18 09:42:45 +08:00
2dust
eef5d3cc16 Update DNSSettingWindow.xaml.cs
https://github.com/2dust/v2rayN/issues/3992
2023-06-18 08:49:04 +08:00
咸鱼而已
59ada594a5 Merge pull request #1 from hvvvvvvv/hvvvvvvv-patch-1
Update HotkeyHandler.cs
2023-06-15 17:12:03 +08:00
咸鱼而已
5ec1d18143 Update HotkeyHandler.cs
fix bug
2023-06-15 16:58:04 +08:00
2dust
fd1e1bb6bf AddServerView CanResize 2023-06-11 19:57:00 +08:00
2dust
5d545d8a85 bug fixes 2023-06-08 20:36:13 +08:00
liuyan
e38bc45527 feat: pac rule add chat.openai.com 2023-06-05 17:42:06 +08:00
2dust
1b11425acd up 6.26 2023-06-04 20:31:05 +08:00
2dust
1e67850a80 Add inet6_address for sing-box 2023-06-04 20:30:00 +08:00
2dust
975f89456f Update ProtosLib.csproj 2023-06-04 17:13:37 +08:00
2dust
e267b4b379 Update v2rayN.csproj 2023-06-04 17:13:34 +08:00
2dust
2fd21690a5 Enable extra inbound for tun mode 2023-06-04 17:11:37 +08:00
2dust
b176ad03aa Remove ToolTipText 2023-06-04 16:30:42 +08:00
2dust
152c4802d0 Fix the bug for flow is empty 2023-06-04 16:24:48 +08:00
2dust
8adbc57f23 remove statisticsFreshRate 2023-06-04 16:14:17 +08:00
2dust
d263a78db8 bug fixes 2023-06-04 15:50:38 +08:00
2dust
b94a065c06 Optimize Subscription 2023-06-04 15:50:25 +08:00
2dust
bc957fea71 up 6.25 2023-05-21 16:31:48 +08:00
2dust
566f056149 use Task.Delay instead of Thread.Sleep 2023-05-21 16:30:05 +08:00
2dust
abe484b0df use Task.Delay instead of Thread.Sleep 2023-05-21 16:29:57 +08:00
2dust
982c865245 Fix subscription ordering 2023-05-21 16:03:29 +08:00
2dust
07d2a27b5f optimize sing-box DNS 2023-05-21 15:22:30 +08:00
2dust
e4c65deda8 Add fakeip for sing-box 2023-05-21 15:05:15 +08:00
2dust
4930646e05 Tum mode forcibly closes the system proxy 2023-05-21 14:55:48 +08:00
2dust
01dd1ff56f Fix cannot insert routing rule with only process name 2023-05-21 14:43:07 +08:00
2dust
9433213fe5 Fill sing-box server_name 2023-05-21 14:35:18 +08:00
2dust
82dea829f1 Temporarily disable sing-box multiplex 2023-05-21 14:30:48 +08:00
2dust
dafc83aa53 Code clean 2023-05-14 17:25:05 +08:00
2dust
7ab1cd6612 Merge pull request #3852 from qhy040404/master
Fix download url
2023-05-14 17:21:33 +08:00
qhy040404
d0e3b3ffbd Fix download url 2023-05-14 17:16:55 +08:00
2dust
50bcc88700 up 6.24 2023-05-14 16:01:57 +08:00
2dust
8fb8575f4b Update v2rayN.csproj 2023-05-13 20:45:02 +08:00
2dust
e63c113b8a Update ProtosLib.csproj 2023-05-13 20:39:24 +08:00
2dust
43d892dbf7 Fix follow system theme 2023-05-13 20:39:16 +08:00
2dust
d9bf31d4f0 Merge pull request #3844 from JasonWues/master
add follow system theme func
2023-05-13 20:04:41 +08:00
2dust
0bde282448 Merge pull request #3842 from ShiinaRinne/hotkey
修复部分键位无法录入热键
2023-05-13 19:33:07 +08:00
2dust
6098132fdf Merge pull request #3834 from qhy040404/master
Avoid to update core if current version is newer than remote version
2023-05-13 19:32:55 +08:00
Metatron
a6bb8947f3 add follow system theme func 2023-05-12 16:19:09 +08:00
ShiinaRinne
48880328b0 Merge branch '2dust:master' into hotkey 2023-05-11 23:32:20 +08:00
ShiinaRinne
25776a788e https://github.com/2dust/v2rayN/issues/3678 2023-05-11 23:31:47 +08:00
qhy040404
f5e8f2831e Cleanup 2023-05-09 23:08:14 +08:00
qhy040404
b3fe13c97a Avoid to update core if current version is newer than remote version 2023-05-09 21:54:56 +08:00
2dust
7845569319 Add ws headers for sing-box 2023-05-09 18:44:04 +08:00
2dust
69b3178c13 remove tun template 2023-05-09 16:14:07 +08:00
2dust
1dce0f0366 Add speed display for sing-box , using clash api 2023-05-09 15:51:32 +08:00
2dust
db1b3fdaad Remove TunHandler 2023-05-07 19:09:51 +08:00
2dust
032d12a592 Add process name (Tun mode) to the rule
Add Tun DNS in the DNS settings of sing-box
Remove Tun mode settings process name and dns
2023-05-07 19:09:13 +08:00
2dust
94cc36a08f Rename the v2ray configuration class 2023-05-07 16:35:46 +08:00
2dust
4fcae44fb7 The default color is Blue 2023-05-07 15:54:40 +08:00
2dust
83719dfe17 vless reality mux can be used when the flow is empty 2023-05-07 09:01:50 +08:00
2dust
c8b01a5530 bug fixes 2023-05-04 20:28:38 +08:00
2dust
b469d73385 add mux for sing-box vless 2023-05-04 20:23:54 +08:00
2dust
69468b1770 Sing2sing 2023-05-04 20:18:21 +08:00
2dust
7e4f66d533 Add Multiplex protocol settings for sing-box 2023-05-04 16:30:35 +08:00
2dust
758d0d82d4 Tun mode force start sing-box core 2023-05-04 11:44:51 +08:00
2dust
a01b934fdb Fix update geoip 2023-04-30 16:46:49 +08:00
2dust
e9b0372174 Enable pre tun mode for other cores 2023-04-29 19:38:00 +08:00
2dust
288c02e092 Adjust some settings 2023-04-29 16:41:31 +08:00
2dust
33322e8795 Improved true connection test 2023-04-28 21:10:13 +08:00
2dust
ec8f6478df update geo files for sing-box 2023-04-28 15:54:51 +08:00
2dust
59d397a3a0 fix some text 2023-04-28 14:15:03 +08:00
2dust
b06540f2ec Custom config pre-service uses sing-box instead of v2ray 2023-04-28 12:09:02 +08:00
2dust
419f5458b4 Add domainStrategy4Singbox in rule set settings 2023-04-28 10:41:50 +08:00
2dust
ca4e8960d2 Delete shortcut keys for routing rules 2023-04-28 10:23:48 +08:00
2dust
7b3bed015a Add the ip and domain separator convert it to a comma 2023-04-28 10:22:55 +08:00
2dust
c97fa3a767 format dns config 2023-04-28 10:02:42 +08:00
2dust
42f7c7cb43 Adjust some config for sing-box 2023-04-27 16:20:13 +08:00
2dust
c8ae834f50 bug fixes 2023-04-27 14:17:27 +08:00
2dust
b8644268b3 Enter to set active routing rules 2023-04-27 10:28:20 +08:00
2dust
75742d8a9e Convert rule domain newLine to comma 2023-04-27 10:21:06 +08:00
2dust
6b6169e248 Adjust some config 2023-04-27 10:15:22 +08:00
2dust
3c4ae902fd Add dns for tun mode 2023-04-26 20:53:43 +08:00
2dust
bfc8bf91ee Add def dns for normal 2023-04-26 20:32:01 +08:00
2dust
768d5cce27 Add Sing-box domain strategy 2023-04-26 15:11:57 +08:00
2dust
d54a1c2754 Adjust some def configs 2023-04-26 14:39:04 +08:00
2dust
282ad3ab2d Add import default DNS config 2023-04-26 10:43:05 +08:00
2dust
c692dd3a66 add sing-box new LAN port 2023-04-26 10:00:51 +08:00
2dust
e461fce2cb add sing-box tun bypassMode 2023-04-26 09:36:30 +08:00
2dust
4d92caabf8 Trojan add reality 2023-04-25 20:34:37 +08:00
2dust
07c07ec60a sniff_override_destination = RouteOnly ? false 2023-04-25 20:34:18 +08:00
2dust
4020213729 generate a single file for sing-box tun mode 2023-04-25 20:27:21 +08:00
2dust
b9beb4be9d Add registry settings system proxy 2023-04-25 10:56:07 +08:00
2dust
f747416d3b Merge pull request #3756 from MohammadHadi2031/dev/ma/perf
use WaitAsync for Timeout
2023-04-25 10:03:40 +08:00
MohammadHadi Attarieh
41241b694f use WaitAsync instead of CTS 2023-04-24 18:34:30 +03:30
2dust
26c5c1ac01 bug fixes 2023-04-24 14:27:17 +08:00
2dust
dedd5b197c DNS independent setting, V2ray and Sing-box 2023-04-24 11:55:26 +08:00
2dust
6340764a6c Add basic rules for sing-box 2023-04-24 09:40:38 +08:00
2dust
a262c1e98d Add sing-box core config file support 2023-04-23 20:21:52 +08:00
2dust
7b9c64c5a5 remove export to server config 2023-04-23 15:06:51 +08:00
2dust
4283404f35 bug fixes 2023-04-22 20:29:06 +08:00
101 changed files with 8096 additions and 4710 deletions

61
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,61 @@
name: release
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
strategy:
matrix:
configuration: [Release]
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 删除工作流运行
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 1
- name: Build
run: cd v2rayN &&
.\build.ps1
# - name: Package
# shell: pwsh
# run: |
# 7z a -mx9 ..\v2rayN.7z $env:Wap_Project_Directory
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: v2rayN
path:
.\v2rayN\v2rayN.zip
# - name: Release
# uses: softprops/action-gh-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# with:
# prerelease: ${{ contains(github.ref, '-') }}
# draft: false
# files: |
# .\v2rayN\v2rayN.zip
# body: |
# [![](https://img.shields.io/badge/Telegram-Channel-blue)](https://t.me/netch_channel) [![](https://img.shields.io/badge/Telegram-Group-green)](https://t.me/netch_group)
# ## Changelogs
# * This is an automated deployment of GitHub Actions, the change log should be updated manually soon
# ## 更新日志
# * 这是 GitHub Actions 自动化部署,更新日志应该很快会手动更新

View File

@@ -2,7 +2,6 @@
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace PacLib;
@@ -50,7 +49,7 @@ public class PacHandler
_tcpListener = TcpListener.Create(_pacPort);
_isRunning = true;
_tcpListener.Start();
Task.Factory.StartNew(() =>
Task.Factory.StartNew(async () =>
{
while (_isRunning)
{
@@ -58,25 +57,25 @@ public class PacHandler
{
if (!_tcpListener.Pending())
{
Thread.Sleep(10);
await Task.Delay(10);
continue;
}
var client = _tcpListener.AcceptTcpClient();
Task.Run(() =>
{
var stream = client.GetStream();
var sb = new StringBuilder();
sb.AppendLine("HTTP/1.0 200 OK");
sb.AppendLine("Content-type:application/x-ns-proxy-autoconfig");
sb.AppendLine("Connection:close");
sb.AppendLine("Content-Length:" + Encoding.UTF8.GetByteCount(_pacText));
sb.AppendLine();
sb.Append(_pacText);
var content = Encoding.UTF8.GetBytes(sb.ToString());
stream.Write(content, 0, content.Length);
stream.Flush();
});
await Task.Run(() =>
{
var stream = client.GetStream();
var sb = new StringBuilder();
sb.AppendLine("HTTP/1.0 200 OK");
sb.AppendLine("Content-type:application/x-ns-proxy-autoconfig");
sb.AppendLine("Connection:close");
sb.AppendLine("Content-Length:" + Encoding.UTF8.GetByteCount(_pacText));
sb.AppendLine();
sb.Append(_pacText);
var content = Encoding.UTF8.GetBytes(sb.ToString());
stream.Write(content, 0, content.Length);
stream.Flush();
});
}
catch (Exception e)
{

View File

@@ -5982,7 +5982,8 @@ var rules = [
"zyzc9.com",
"zzcartoon.com",
"zzcloud.me",
"zzux.com"
"zzux.com",
"chat.openai.com"
]
]
];

View File

@@ -9,9 +9,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.22.3" />
<PackageReference Include="Grpc.Net.Client" Version="2.52.0" />
<PackageReference Include="Grpc.Tools" Version="2.53.0">
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.59.0" />
<PackageReference Include="Grpc.Tools" Version="2.59.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

39
v2rayN/build.ps1 Normal file
View File

@@ -0,0 +1,39 @@
param (
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$OutputPath = '.\bin\v2rayN'
)
Write-Host 'Building'
dotnet publish `
.\v2rayN\v2rayN.csproj `
-c Release `
--self-contained false `
-p:PublishReadyToRun=true `
-p:PublishSingleFile=true `
-o $OutputPath
dotnet publish `
.\v2rayUpgrade\v2rayUpgrade.csproj `
-c Release `
--self-contained false `
-p:PublishReadyToRun=true `
-p:PublishSingleFile=true `
-o $OutputPath
if ( -Not $? ) {
exit $lastExitCode
}
if ( Test-Path -Path .\bin\v2rayN ) {
rm -Force "$OutputPath\*.pdb"
rm -Force "$OutputPath\*.xml"
}
Write-Host 'Build done'
ls $OutputPath
7z a v2rayN.zip $OutputPath
exit 0

View File

@@ -1,9 +1,9 @@
<Application
x:Class="v2rayN.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
ShutdownMode="OnExplicitShutdown"
StartupUri="Views/MainWindow.xaml">
<Application.Resources>
@@ -11,7 +11,7 @@
<ResourceDictionary.MergedDictionaries>
<materialDesign:BundledTheme
BaseTheme="Light"
PrimaryColor="DeepPurple"
PrimaryColor="Blue"
SecondaryColor="Lime" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
</ResourceDictionary.MergedDictionaries>
@@ -20,6 +20,8 @@
<system:Double x:Key="StdFontSize1">13</system:Double>
<system:Double x:Key="StdFontSize2">14</system:Double>
<system:Double x:Key="StdFontSizeMsg">11</system:Double>
<conv:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<Thickness
x:Key="ServerItemMargin"
Bottom="4"
@@ -32,6 +34,12 @@
Left="8"
Right="8"
Top="8" />
<Thickness
x:Key="OutlinedTextBoxDefaultPadding"
Bottom="12"
Left="16"
Right="12"
Top="12" />
<Style
x:Key="ModuleTitle"
BasedOn="{StaticResource MaterialDesignTextBlock}"
@@ -127,6 +135,7 @@
BasedOn="{StaticResource MaterialDesignOutlinedTextBox}"
TargetType="{x:Type TextBox}">
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" />
<Setter Property="Padding" Value="{StaticResource OutlinedTextBoxDefaultPadding}" />
</Style>
<Style
x:Key="MyGroupBox"
@@ -140,6 +149,13 @@
TargetType="{x:Type ListBoxItem}">
<Setter Property="Margin" Value="-2,0" />
</Style>
<Style
x:Key="MyOutlinedTextComboBox"
BasedOn="{StaticResource MaterialDesignOutlinedComboBox}"
TargetType="{x:Type ComboBox}">
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" />
<Setter Property="Padding" Value="{StaticResource OutlinedTextBoxDefaultPadding}" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -40,7 +40,7 @@ namespace v2rayN
return;
}
Global.processJob = new Job();
Global.ProcessJob = new Job();
Logging.Setup();
Init();

View File

@@ -16,9 +16,6 @@ namespace v2rayN.Base
return null;
}
var cancellationToken = new CancellationTokenSource();
cancellationToken.CancelAfter(timeout * 1000);
Uri uri = new(url);
//Authorization Header
var headers = new WebHeaderCollection();
@@ -48,7 +45,9 @@ namespace v2rayN.Base
throw value.Error;
}
};
using var stream = await downloader.DownloadFileTaskAsync(address: url, cancellationToken: cancellationToken.Token);
using var cts = new CancellationTokenSource();
using var stream = await downloader.DownloadFileTaskAsync(address: url, cts.Token).WaitAsync(TimeSpan.FromSeconds(timeout), cts.Token);
using StreamReader reader = new(stream);
downloadOpt = null;
@@ -63,9 +62,6 @@ namespace v2rayN.Base
throw new ArgumentNullException(nameof(url));
}
var cancellationToken = new CancellationTokenSource();
cancellationToken.CancelAfter(timeout * 1000);
var downloadOpt = new DownloadConfiguration()
{
Timeout = timeout * 1000,
@@ -115,8 +111,9 @@ namespace v2rayN.Base
}
};
//progress.Report("......");
using var stream = await downloader.DownloadFileTaskAsync(address: url, cancellationToken: cancellationToken.Token);
using var cts = new CancellationTokenSource();
cts.CancelAfter(timeout * 1000);
using var stream = await downloader.DownloadFileTaskAsync(address: url, cts.Token);
downloadOpt = null;
}
@@ -136,9 +133,6 @@ namespace v2rayN.Base
File.Delete(fileName);
}
var cancellationToken = new CancellationTokenSource();
cancellationToken.CancelAfter(timeout * 1000);
var downloadOpt = new DownloadConfiguration()
{
Timeout = timeout * 1000,
@@ -178,7 +172,8 @@ namespace v2rayN.Base
}
};
await downloader.DownloadFileTaskAsync(url, fileName, cancellationToken: cancellationToken.Token);
using var cts = new CancellationTokenSource();
await downloader.DownloadFileTaskAsync(url, fileName, cts.Token).WaitAsync(TimeSpan.FromSeconds(timeout), cts.Token);
downloadOpt = null;
}

View File

@@ -136,7 +136,6 @@ namespace v2rayN.Base
var data = new byte[read];
buffer.ToList().CopyTo(0, data, 0, read);
// TODO:
totalRead += read;
TimeSpan ts = (DateTime.Now - totalDatetime);

View File

@@ -46,5 +46,39 @@ namespace v2rayN.Base
{
return value == null ? string.Empty : value.Trim();
}
public static string RemovePrefix(this string value, char prefix)
{
if (value.StartsWith(prefix))
{
return value.Substring(1);
}
else
{
return value;
}
}
public static string RemovePrefix(this string value, string prefix)
{
if (value.StartsWith(prefix))
{
return value.Substring(prefix.Length);
}
else
{
return value;
}
}
public static string UpperFirstChar(this string value)
{
if (string.IsNullOrEmpty(value))
{
return string.Empty;
}
return char.ToUpper(value[0]) + value.Substring(1);
}
}
}

View File

@@ -0,0 +1,24 @@
using System.Globalization;
using System.Windows.Data;
namespace v2rayN.Converters
{
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof(bool))
{
throw new InvalidOperationException("The target must be a boolean");
}
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,48 +1,60 @@
namespace v2rayN
using v2rayN.Mode;
namespace v2rayN
{
internal class Global
{
#region const
public const string githubUrl = "https://github.com";
public const string githubApiUrl = "https://api.github.com/repos";
public const string v2rayWebsiteUrl = @"https://www.v2fly.org/";
public const string GithubUrl = "https://github.com";
public const string GithubApiUrl = "https://api.github.com/repos";
public const string V2rayWebsiteUrl = @"https://www.v2fly.org/";
public const string AboutUrl = @"https://github.com/2dust/v2rayN";
public const string UpdateUrl = AboutUrl + @"/releases";
public const string v2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases";
public const string xrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
public const string V2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases";
public const string XrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
public const string SagerNetCoreUrl = "https://github.com/SagerNet/v2ray-core/releases";
public const string NUrl = @"https://github.com/2dust/v2rayN/releases";
public const string clashCoreUrl = "https://github.com/Dreamacro/clash/releases";
public const string clashMetaCoreUrl = "https://github.com/MetaCubeX/Clash.Meta/releases";
public const string hysteriaCoreUrl = "https://github.com/apernet/hysteria/releases";
public const string naiveproxyCoreUrl = "https://github.com/klzgrad/naiveproxy/releases";
public const string tuicCoreUrl = "https://github.com/EAimTY/tuic/releases";
public const string singboxCoreUrl = "https://github.com/SagerNet/sing-box/releases";
public const string geoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
public const string ClashCoreUrl = "https://github.com/Dreamacro/clash/releases";
public const string ClashMetaCoreUrl = "https://github.com/MetaCubeX/Clash.Meta/releases";
public const string MihomoCoreUrl = "https://github.com/MetaCubeX/mihomo/releases";
public const string HysteriaCoreUrl = "https://github.com/apernet/hysteria/releases";
public const string NaiveproxyCoreUrl = "https://github.com/klzgrad/naiveproxy/releases";
public const string TuicCoreUrl = "https://github.com/EAimTY/tuic/releases";
public const string SingboxCoreUrl = "https://github.com/SagerNet/sing-box/releases";
public const string GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
public const string SingboxGeoUrl = "https://github.com/soffchen/sing-{0}/releases/latest/download/{0}.db";
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/";
public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw=";
public const string ConfigFileName = "guiNConfig.json";
public const string ConfigDB = "guiNDB.db";
public const string coreConfigFileName = "config.json";
public const string v2raySampleClient = "v2rayN.Sample.SampleClientConfig";
public const string v2raySampleServer = "v2rayN.Sample.SampleServerConfig";
public const string v2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest";
public const string v2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
public const string CoreConfigFileName = "config.json";
public const string CorePreConfigFileName = "configPre.json";
public const string CoreSpeedtestConfigFileName = "configSpeedtest.json";
public const string V2raySampleClient = "v2rayN.Sample.SampleClientConfig";
public const string SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig";
public const string V2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest";
public const string V2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
public const string V2raySampleInbound = "v2rayN.Sample.SampleInbound";
public const string V2raySampleOutbound = "v2rayN.Sample.SampleOutbound";
public const string SingboxSampleOutbound = "v2rayN.Sample.SingboxSampleOutbound";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
public const string v2raySampleInbound = "v2rayN.Sample.SampleInbound";
public const string TunSingboxFileName = "v2rayN.Sample.tun_singbox";
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound";
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules";
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal";
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal";
public const string DefaultSecurity = "auto";
public const string DefaultNetwork = "tcp";
public const string TcpHeaderHttp = "http";
public const string None = "none";
public const string agentTag = "proxy";
public const string directTag = "direct";
public const string blockTag = "block";
public const string ProxyTag = "proxy";
public const string DirectTag = "direct";
public const string BlockTag = "block";
public const string StreamSecurity = "tls";
public const string StreamSecurityReality = "reality";
public const string InboundSocks = "socks";
@@ -52,21 +64,10 @@
public const string Loopback = "127.0.0.1";
public const string InboundAPITagName = "api";
public const string InboundAPIProtocal = "dokodemo-door";
public const string HttpProtocol = "http://";
public const string HttpsProtocol = "https://";
public const string vmessProtocol = "vmess://";
public const string vmessProtocolLite = "vmess";
public const string ssProtocol = "ss://";
public const string ssProtocolLite = "shadowsocks";
public const string socksProtocol = "socks://";
public const string socksProtocolLite = "socks";
public const string httpProtocol = "http://";
public const string httpsProtocol = "https://";
public const string vlessProtocol = "vless://";
public const string vlessProtocolLite = "vless";
public const string trojanProtocol = "trojan://";
public const string trojanProtocolLite = "trojan";
public const string userEMail = "t@t.tt";
public const string UserEMail = "t@t.tt";
public const string MyRegPath = "Software\\v2rayNGUI";
public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
public const string AutoRunName = "v2rayNAutoRun";
@@ -111,11 +112,14 @@
};
public static readonly List<string> SpeedTestUrls = new() {
@"https://speed.cloudflare.com/__down?bytes=100000000",
@"https://speed.cloudflare.com/__down?bytes=10000000",
@"http://cachefly.cachefly.net/50mb.test",
@"http://cachefly.cachefly.net/100mb.test",
@"http://cachefly.cachefly.net/10mb.test"
};
public static readonly Dictionary<string, string> userAgentTxt = new()
public static readonly Dictionary<string, string> UserAgentTxts = new()
{
{"chrome","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" },
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
@@ -124,37 +128,64 @@
{"none",""}
};
public static readonly List<string> vmessSecuritys = new() { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" };
public static readonly List<string> ssSecuritys = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
public static readonly List<string> ssSecuritysInSagerNet = new() { "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-gcm", "aes-192-gcm", "aes-256-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "rc4", "rc4-md5", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-cfb8", "aes-192-cfb8", "aes-256-cfb8", "aes-128-ofb", "aes-192-ofb", "aes-256-ofb", "bf-cfb", "cast5-cfb", "des-cfb", "idea-cfb", "rc2-cfb", "seed-cfb", "camellia-128-cfb", "camellia-192-cfb", "camellia-256-cfb", "camellia-128-cfb8", "camellia-192-cfb8", "camellia-256-cfb8", "salsa20", "chacha20", "chacha20-ietf", "xchacha20" };
public static readonly List<string> ssSecuritysInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" };
public static readonly List<string> flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> networks = new() { "tcp", "kcp", "ws", "h2", "quic", "grpc" };
public static readonly List<string> kcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> coreTypes = new() { "v2fly", "SagerNet", "Xray", "v2fly_v5" };
public static readonly List<string> coreTypes4VLESS = new() { "Xray" };
public static readonly List<string> domainStrategys = new() { "AsIs", "IPIfNonMatch", "IPOnDemand" };
public static readonly List<string> domainMatchers = new() { "linear", "mph", "" };
public static readonly List<string> fingerprints = new() { "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random", "randomized", "" };
public static readonly List<string> userAgent = new() { "chrome", "firefox", "safari", "edge", "none" };
public const string Hysteria2ProtocolShare = "hy2://";
public static readonly List<string> allowInsecures = new() { "true", "false", "" };
public static readonly List<string> domainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
public static readonly List<string> Languages = new() { "zh-Hans", "en", "fa-Ir", "ru" };
public static readonly List<string> alpns = new() { "h2", "http/1.1", "h2,http/1.1", "" };
public static readonly List<string> LogLevel = new() { "debug", "info", "warning", "error", "none" };
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
{
{EConfigType.VMess,"vmess://"},
{EConfigType.Shadowsocks,"ss://"},
{EConfigType.Socks,"socks://"},
{EConfigType.VLESS,"vless://"},
{EConfigType.Trojan,"trojan://"},
{EConfigType.Hysteria2,"hysteria2://"},
{EConfigType.Tuic,"tuic://"}
};
public static readonly Dictionary<EConfigType, string> ProtocolTypes = new()
{
{EConfigType.VMess,"vmess"},
{EConfigType.Shadowsocks,"shadowsocks"},
{EConfigType.Socks,"socks"},
{EConfigType.VLESS,"vless"},
{EConfigType.Trojan,"trojan"},
{EConfigType.Hysteria2,"hysteria2"},
{EConfigType.Tuic,"tuic"}
};
public static readonly List<string> VmessSecuritys = new() { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" };
public static readonly List<string> SsSecuritys = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
public static readonly List<string> SsSecuritysInSagerNet = new() { "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-gcm", "aes-192-gcm", "aes-256-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "rc4", "rc4-md5", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-cfb8", "aes-192-cfb8", "aes-256-cfb8", "aes-128-ofb", "aes-192-ofb", "aes-256-ofb", "bf-cfb", "cast5-cfb", "des-cfb", "idea-cfb", "rc2-cfb", "seed-cfb", "camellia-128-cfb", "camellia-192-cfb", "camellia-256-cfb", "camellia-128-cfb8", "camellia-192-cfb8", "camellia-256-cfb8", "salsa20", "chacha20", "chacha20-ietf", "xchacha20" };
public static readonly List<string> SsSecuritysInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" };
public static readonly List<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "h2", "quic", "grpc" };
public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" };
public static readonly List<string> DomainStrategys = new() { "AsIs", "IPIfNonMatch", "IPOnDemand" };
public static readonly List<string> DomainStrategys4Singbox = new() { "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6", "" };
public static readonly List<string> DomainMatchers = new() { "linear", "mph", "" };
public static readonly List<string> Fingerprints = new() { "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random", "randomized", "" };
public static readonly List<string> UserAgent = new() { "chrome", "firefox", "safari", "edge", "none" };
public static readonly List<string> AllowInsecures = new() { "true", "false", "" };
public static readonly List<string> DomainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
public static readonly List<string> Languages = new() { "zh-Hans", "zh-Hant", "en", "fa-Ir", "ru" };
public static readonly List<string> Alpns = new() { "h2", "http/1.1", "h2,http/1.1", "h3", "" };
public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" };
public static readonly List<string> InboundTags = new() { "socks", "http", "socks2", "http2" };
public static readonly List<string> Protocols = new() { "http", "tls", "bittorrent" };
public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" };
public static readonly List<string> TunMtus = new() { "9000", "1500" };
public static readonly List<string> TunStacks = new() { "gvisor", "system" };
public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" };
public static readonly List<string> SingboxMuxs = new() { "h2mux", "smux", "yamux", "" };
public static readonly List<string> TuicCongestionControls = new() { "cubic", "new_reno", "bbr" };
#endregion const
#region global variable
public static int statePort { get; set; }
public static Job processJob { get; set; }
public static int StatePort { get; set; }
public static Job ProcessJob { get; set; }
public static bool ShowInTaskbar { get; set; }
public static string ExePathKey { get; set; }

View File

@@ -22,10 +22,10 @@ namespace v2rayN.Handler
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
public static int LoadConfig(ref Config config)
public static int LoadConfig(ref Config? config)
{
//载入配置文件
string result = Utils.LoadResource(Utils.GetConfigPath(configRes));
var result = Utils.LoadResource(Utils.GetConfigPath(configRes));
if (!Utils.IsNullOrEmpty(result))
{
//转成Json
@@ -96,7 +96,7 @@ namespace v2rayN.Handler
//路由规则
if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy))
{
config.routingBasicItem.domainStrategy = Global.domainStrategys[0];//"IPIfNonMatch";
config.routingBasicItem.domainStrategy = Global.DomainStrategys[0];//"IPIfNonMatch";
}
//if (Utils.IsNullOrEmpty(config.domainMatcher))
//{
@@ -132,7 +132,6 @@ namespace v2rayN.Handler
config.tunModeItem = new TunModeItem
{
enableTun = false,
showWindow = true,
mtu = 9000,
};
}
@@ -141,7 +140,6 @@ namespace v2rayN.Handler
config.guiItem = new()
{
enableStatistics = false,
statisticsFreshRate = 1,
};
}
if (config.uiItem == null)
@@ -168,10 +166,6 @@ namespace v2rayN.Handler
{
config.constItem.defIEProxyExceptions = Global.IEProxyExceptions;
}
//if (Utils.IsNullOrEmpty(config.remoteDNS))
//{
// config.remoteDNS = "1.1.1.1";
//}
if (config.speedTestItem == null)
{
@@ -190,9 +184,25 @@ namespace v2rayN.Handler
config.speedTestItem.speedPingTestUrl = Global.SpeedPingTestUrl;
}
if (config.guiItem.statisticsFreshRate is > 100 or < 1)
if (config.mux4SboxItem == null)
{
config.guiItem.statisticsFreshRate = 1;
config.mux4SboxItem = new()
{
protocol = Global.SingboxMuxs[0],
max_connections = 4,
min_streams = 4,
max_streams = 0,
padding = true
};
}
if (config.hysteriaItem == null)
{
config.hysteriaItem = new()
{
up_mbps = 100,
down_mbps = 100
};
}
LazyConfig.Instance.SetConfig(config);
@@ -204,7 +214,7 @@ namespace v2rayN.Handler
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
public static int SaveConfig(ref Config config, bool reload = true)
public static int SaveConfig(Config config, bool reload = true)
{
ToJsonFile(config);
@@ -243,7 +253,7 @@ namespace v2rayN.Handler
}
}
public static int ImportOldGuiConfig(ref Config config, string fileName)
public static int ImportOldGuiConfig(Config config, string fileName)
{
string result = Utils.LoadResource(fileName);
if (Utils.IsNullOrEmpty(result))
@@ -324,7 +334,6 @@ namespace v2rayN.Handler
config.guiItem = new()
{
enableStatistics = configOld.enableStatistics,
statisticsFreshRate = configOld.statisticsFreshRate,
keepOlderDedupl = configOld.keepOlderDedupl,
ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
autoUpdateInterval = configOld.autoUpdateInterval,
@@ -334,9 +343,9 @@ namespace v2rayN.Handler
};
}
GetDefaultServer(ref config);
GetDefaultRouting(ref config);
SaveConfig(ref config);
GetDefaultServer(config);
GetDefaultRouting(config);
SaveConfig(config);
LoadConfig(ref config);
return 0;
@@ -347,12 +356,12 @@ namespace v2rayN.Handler
#region Server
/// <summary>
/// 添加服务器或编辑
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddServer(ref Config config, ProfileItem profileItem, bool toFile = true)
public static int AddServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.VMess;
@@ -365,12 +374,16 @@ namespace v2rayN.Handler
profileItem.path = profileItem.path.TrimEx();
profileItem.streamSecurity = profileItem.streamSecurity.TrimEx();
if (!Global.vmessSecuritys.Contains(profileItem.security))
if (!Global.VmessSecuritys.Contains(profileItem.security))
{
return -1;
}
if (profileItem.id.IsNullOrEmpty())
{
return -1;
}
AddServerCommon(ref config, profileItem, toFile);
AddServerCommon(config, profileItem, toFile);
return 0;
}
@@ -390,7 +403,7 @@ namespace v2rayN.Handler
}
SqliteHelper.Instance.UpdateAll(indexs);
RemoveServerViaSubid(ref config, subid, false);
RemoveServerViaSubid(config, subid, false);
return 0;
}
@@ -401,7 +414,7 @@ namespace v2rayN.Handler
/// <param name="config"></param>
/// <param name="index"></param>
/// <returns></returns>
public static int CopyServer(ref Config config, List<ProfileItem> indexs)
public static int CopyServer(Config config, List<ProfileItem> indexs)
{
foreach (var it in indexs)
{
@@ -418,13 +431,13 @@ namespace v2rayN.Handler
if (profileItem.configType == EConfigType.Custom)
{
profileItem.address = Utils.GetConfigPath(profileItem.address);
if (AddCustomServer(ref config, profileItem, false) == 0)
if (AddCustomServer(config, profileItem, false) == 0)
{
}
}
else
{
AddServerCommon(ref config, profileItem, true);
AddServerCommon(config, profileItem, true);
}
}
@@ -437,7 +450,7 @@ namespace v2rayN.Handler
/// <param name="config"></param>
/// <param name="item"></param>
/// <returns></returns>
public static int SetDefaultServerIndex(ref Config config, string? indexId)
public static int SetDefaultServerIndex(Config config, string? indexId)
{
if (Utils.IsNullOrEmpty(indexId))
{
@@ -463,18 +476,18 @@ namespace v2rayN.Handler
}
if (lstProfile.Count > 0)
{
return SetDefaultServerIndex(ref config, lstProfile.Where(t => t.port > 0).FirstOrDefault()?.indexId);
return SetDefaultServerIndex(config, lstProfile.Where(t => t.port > 0).FirstOrDefault()?.indexId);
}
return SetDefaultServerIndex(ref config, SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.port > 0).Select(t => t.indexId).FirstOrDefault());
return SetDefaultServerIndex(config, SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.port > 0).Select(t => t.indexId).FirstOrDefault());
}
public static ProfileItem? GetDefaultServer(ref Config config)
public static ProfileItem? GetDefaultServer(Config config)
{
var item = LazyConfig.Instance.GetProfileItem(config.indexId);
if (item is null)
{
var item2 = SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault();
SetDefaultServerIndex(ref config, item2?.indexId);
SetDefaultServerIndex(config, item2?.indexId);
return item2;
}
@@ -489,7 +502,7 @@ namespace v2rayN.Handler
/// <param name="index"></param>
/// <param name="eMove"></param>
/// <returns></returns>
public static int MoveServer(ref Config config, ref List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
public static int MoveServer(Config config, ref List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
{
int count = lstProfile.Count;
if (index < 0 || index > lstProfile.Count - 1)
@@ -561,7 +574,7 @@ namespace v2rayN.Handler
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddCustomServer(ref Config config, ProfileItem profileItem, bool blDelete)
public static int AddCustomServer(Config config, ProfileItem profileItem, bool blDelete)
{
var fileName = profileItem.address;
if (!File.Exists(fileName))
@@ -590,21 +603,21 @@ namespace v2rayN.Handler
profileItem.configType = EConfigType.Custom;
if (Utils.IsNullOrEmpty(profileItem.remarks))
{
profileItem.remarks = $"import custom@{DateTime.Now.ToShortDateString()}";
profileItem.remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
}
AddServerCommon(ref config, profileItem, true);
AddServerCommon(config, profileItem, true);
return 0;
}
/// <summary>
/// 添加服务器或编辑
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int EditCustomServer(ref Config config, ProfileItem profileItem)
public static int EditCustomServer(Config config, ProfileItem profileItem)
{
if (SqliteHelper.Instance.Update(profileItem) > 0)
{
@@ -619,12 +632,12 @@ namespace v2rayN.Handler
}
/// <summary>
/// 添加服务器或编辑
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddShadowsocksServer(ref Config config, ProfileItem profileItem, bool toFile = true)
public static int AddShadowsocksServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Shadowsocks;
@@ -636,36 +649,40 @@ namespace v2rayN.Handler
{
return -1;
}
if (profileItem.id.IsNullOrEmpty())
{
return -1;
}
AddServerCommon(ref config, profileItem, toFile);
AddServerCommon(config, profileItem, toFile);
return 0;
}
/// <summary>
/// 添加服务器或编辑
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddSocksServer(ref Config config, ProfileItem profileItem, bool toFile = true)
public static int AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Socks;
profileItem.address = profileItem.address.TrimEx();
AddServerCommon(ref config, profileItem, toFile);
AddServerCommon(config, profileItem, toFile);
return 0;
}
/// <summary>
/// 添加服务器或编辑
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddTrojanServer(ref Config config, ProfileItem profileItem, bool toFile = true)
public static int AddTrojanServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Trojan;
@@ -675,13 +692,85 @@ namespace v2rayN.Handler
{
profileItem.streamSecurity = Global.StreamSecurity;
}
if (profileItem.id.IsNullOrEmpty())
{
return -1;
}
AddServerCommon(ref config, profileItem, toFile);
AddServerCommon(config, profileItem, toFile);
return 0;
}
public static int SortServers(ref Config config, string subId, string colName, bool asc)
/// <summary>
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Hysteria2;
profileItem.coreType = ECoreType.sing_box;
profileItem.address = profileItem.address.TrimEx();
profileItem.id = profileItem.id.TrimEx();
profileItem.network = string.Empty;
if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
{
profileItem.streamSecurity = Global.StreamSecurity;
}
if (profileItem.id.IsNullOrEmpty())
{
return -1;
}
AddServerCommon(config, profileItem, toFile);
return 0;
}
/// <summary>
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Tuic;
profileItem.coreType = ECoreType.sing_box;
profileItem.address = profileItem.address.TrimEx();
profileItem.id = profileItem.id.TrimEx();
profileItem.security = profileItem.security.TrimEx();
profileItem.network = string.Empty;
if (!Global.TuicCongestionControls.Contains(profileItem.headerType))
{
profileItem.headerType = Global.TuicCongestionControls.FirstOrDefault()!;
}
if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
{
profileItem.streamSecurity = Global.StreamSecurity;
}
if (Utils.IsNullOrEmpty(profileItem.alpn))
{
profileItem.alpn = "h3";
}
if (profileItem.id.IsNullOrEmpty())
{
return -1;
}
AddServerCommon(config, profileItem, toFile);
return 0;
}
public static int SortServers(Config config, string subId, string colName, bool asc)
{
var lstModel = LazyConfig.Instance.ProfileItems(subId, "");
if (lstModel.Count <= 0)
@@ -778,12 +867,12 @@ namespace v2rayN.Handler
}
/// <summary>
/// 添加服务器或编辑
/// Add or edit server
/// </summary>
/// <param name="config"></param>
/// <param name="profileItem"></param>
/// <returns></returns>
public static int AddVlessServer(ref Config config, ProfileItem profileItem, bool toFile = true)
public static int AddVlessServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.VLESS;
@@ -796,12 +885,16 @@ namespace v2rayN.Handler
profileItem.path = profileItem.path.TrimEx();
profileItem.streamSecurity = profileItem.streamSecurity.TrimEx();
if (!Global.flows.Contains(profileItem.flow))
if (!Global.Flows.Contains(profileItem.flow))
{
profileItem.flow = Global.flows.First();
profileItem.flow = Global.Flows.First();
}
if (profileItem.id.IsNullOrEmpty())
{
return -1;
}
AddServerCommon(ref config, profileItem, toFile);
AddServerCommon(config, profileItem, toFile);
return 0;
}
@@ -830,7 +923,7 @@ namespace v2rayN.Handler
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
}
public static int AddServerCommon(ref Config config, ProfileItem profileItem, bool toFile = true)
public static int AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configVersion = 2;
@@ -840,21 +933,29 @@ namespace v2rayN.Handler
{
profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower();
}
if (Utils.IsNullOrEmpty(profileItem.fingerprint))
if (Utils.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality)
{
profileItem.fingerprint = config.coreBasicItem.defFingerprint;
}
}
if (!Utils.IsNullOrEmpty(profileItem.network) && !Global.networks.Contains(profileItem.network))
if (!Utils.IsNullOrEmpty(profileItem.network) && !Global.Networks.Contains(profileItem.network))
{
profileItem.network = Global.DefaultNetwork;
}
var maxSort = -1;
if (Utils.IsNullOrEmpty(profileItem.indexId))
{
profileItem.indexId = Utils.GetGUID(false);
var maxSort = ProfileExHandler.Instance.GetMaxSort();
maxSort = ProfileExHandler.Instance.GetMaxSort();
}
if (!toFile && maxSort < 0)
{
maxSort = ProfileExHandler.Instance.GetMaxSort();
}
if (maxSort > 0)
{
ProfileExHandler.Instance.SetSort(profileItem.indexId, maxSort + 1);
}
@@ -923,7 +1024,7 @@ namespace v2rayN.Handler
/// <param name="clipboardData"></param>
/// <param name="subid"></param>
/// <returns>成功导入的数量</returns>
private static int AddBatchServers(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
private static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
{
if (Utils.IsNullOrEmpty(clipboardData))
{
@@ -934,7 +1035,7 @@ namespace v2rayN.Handler
//remove sub items
if (isSub && !Utils.IsNullOrEmpty(subid))
{
RemoveServerViaSubid(ref config, subid, isSub);
RemoveServerViaSubid(config, subid, isSub);
subFilter = LazyConfig.Instance.GetSubItem(subid)?.filter ?? "";
}
@@ -950,9 +1051,9 @@ namespace v2rayN.Handler
foreach (string str in arrData)
{
//maybe sub
if (!isSub && (str.StartsWith(Global.httpsProtocol) || str.StartsWith(Global.httpProtocol)))
if (!isSub && (str.StartsWith(Global.HttpsProtocol) || str.StartsWith(Global.HttpProtocol)))
{
if (AddSubItem(ref config, str) == 0)
if (AddSubItem(config, str) == 0)
{
countServers++;
}
@@ -1000,26 +1101,34 @@ namespace v2rayN.Handler
if (profileItem.configType == EConfigType.VMess)
{
addStatus = AddServer(ref config, profileItem, false);
addStatus = AddServer(config, profileItem, false);
}
else if (profileItem.configType == EConfigType.Shadowsocks)
{
addStatus = AddShadowsocksServer(ref config, profileItem, false);
addStatus = AddShadowsocksServer(config, profileItem, false);
}
else if (profileItem.configType == EConfigType.Socks)
{
addStatus = AddSocksServer(ref config, profileItem, false);
addStatus = AddSocksServer(config, profileItem, false);
}
else if (profileItem.configType == EConfigType.Trojan)
{
addStatus = AddTrojanServer(ref config, profileItem, false);
addStatus = AddTrojanServer(config, profileItem, false);
}
else if (profileItem.configType == EConfigType.VLESS)
{
addStatus = AddVlessServer(ref config, profileItem, false);
addStatus = AddVlessServer(config, profileItem, false);
}
else if (profileItem.configType == EConfigType.Hysteria2)
{
addStatus = AddHysteria2Server(config, profileItem, false);
}
else if (profileItem.configType == EConfigType.Tuic)
{
addStatus = AddTuicServer(config, profileItem, false);
}
if (addStatus == 0 && profileItem.port > 0)
if (addStatus == 0)
{
countServers++;
lstAdd.Add(profileItem);
@@ -1035,7 +1144,7 @@ namespace v2rayN.Handler
return countServers;
}
private static int AddBatchServers4Custom(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
private static int AddBatchServers4Custom(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
{
if (Utils.IsNullOrEmpty(clipboardData))
{
@@ -1071,7 +1180,7 @@ namespace v2rayN.Handler
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.yaml");
File.WriteAllText(fileName, clipboardData);
profileItem.coreType = ECoreType.clash;
profileItem.coreType = ECoreType.mihomo;
profileItem.address = fileName;
profileItem.remarks = "clash_custom";
}
@@ -1108,7 +1217,7 @@ namespace v2rayN.Handler
if (isSub && !Utils.IsNullOrEmpty(subid))
{
RemoveServerViaSubid(ref config, subid, isSub);
RemoveServerViaSubid(config, subid, isSub);
}
if (isSub && lstOriSub?.Count == 1)
{
@@ -1122,7 +1231,7 @@ namespace v2rayN.Handler
return -1;
}
if (AddCustomServer(ref config, profileItem, true) == 0)
if (AddCustomServer(config, profileItem, true) == 0)
{
return 1;
}
@@ -1132,7 +1241,7 @@ namespace v2rayN.Handler
}
}
private static int AddBatchServers4SsSIP008(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
private static int AddBatchServers4SsSIP008(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
{
if (Utils.IsNullOrEmpty(clipboardData))
{
@@ -1141,7 +1250,7 @@ namespace v2rayN.Handler
if (isSub && !Utils.IsNullOrEmpty(subid))
{
RemoveServerViaSubid(ref config, subid, isSub);
RemoveServerViaSubid(config, subid, isSub);
}
//SsSIP008
@@ -1171,7 +1280,7 @@ namespace v2rayN.Handler
};
ssItem.subid = subid;
ssItem.isSub = isSub;
if (AddShadowsocksServer(ref config, ssItem) == 0)
if (AddShadowsocksServer(config, ssItem) == 0)
{
counter++;
}
@@ -1183,7 +1292,7 @@ namespace v2rayN.Handler
return -1;
}
public static int AddBatchServers(ref Config config, string clipboardData, string subid, bool isSub)
public static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub)
{
List<ProfileItem>? lstOriSub = null;
if (isSub && !Utils.IsNullOrEmpty(subid))
@@ -1194,26 +1303,26 @@ namespace v2rayN.Handler
var counter = 0;
if (Utils.IsBase64String(clipboardData))
{
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
counter = AddBatchServers(config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
}
if (counter < 1)
{
counter = AddBatchServers(ref config, clipboardData, subid, isSub, lstOriSub);
counter = AddBatchServers(config, clipboardData, subid, isSub, lstOriSub);
}
if (counter < 1)
{
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
counter = AddBatchServers(config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
}
if (counter < 1)
{
counter = AddBatchServers4SsSIP008(ref config, clipboardData, subid, isSub, lstOriSub);
counter = AddBatchServers4SsSIP008(config, clipboardData, subid, isSub, lstOriSub);
}
//maybe other sub
if (counter < 1)
{
counter = AddBatchServers4Custom(ref config, clipboardData, subid, isSub, lstOriSub);
counter = AddBatchServers4Custom(config, clipboardData, subid, isSub, lstOriSub);
}
return counter;
@@ -1229,7 +1338,7 @@ namespace v2rayN.Handler
/// <param name="config"></param>
/// <param name="url"></param>
/// <returns></returns>
public static int AddSubItem(ref Config config, string url)
public static int AddSubItem(Config config, string url)
{
//already exists
if (SqliteHelper.Instance.Table<SubItem>().Where(e => e.url == url).Count() > 0)
@@ -1244,10 +1353,10 @@ namespace v2rayN.Handler
url = url
};
return AddSubItem(ref config, subItem);
return AddSubItem(config, subItem);
}
public static int AddSubItem(ref Config config, SubItem subItem)
public static int AddSubItem(Config config, SubItem subItem)
{
if (Utils.IsNullOrEmpty(subItem.id))
{
@@ -1279,13 +1388,13 @@ namespace v2rayN.Handler
/// <param name="config"></param>
/// <param name="subid"></param>
/// <returns></returns>
public static int RemoveServerViaSubid(ref Config config, string subid, bool isSub)
public static int RemoveServerViaSubid(Config config, string subid, bool isSub)
{
if (Utils.IsNullOrEmpty(subid))
{
return -1;
}
var customProfile = SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.subid == subid && t.isSub == isSub && t.configType == EConfigType.Custom).ToList();
var customProfile = SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.subid == subid && t.configType == EConfigType.Custom).ToList();
if (isSub)
{
SqliteHelper.Instance.Execute($"delete from ProfileItem where isSub = 1 and subid = '{subid}'");
@@ -1302,7 +1411,7 @@ namespace v2rayN.Handler
return 0;
}
public static int DeleteSubItem(ref Config config, string id)
public static int DeleteSubItem(Config config, string id)
{
var item = LazyConfig.Instance.GetSubItem(id);
if (item is null)
@@ -1310,7 +1419,7 @@ namespace v2rayN.Handler
return 0;
}
SqliteHelper.Instance.Delete(item);
RemoveServerViaSubid(ref config, id, false);
RemoveServerViaSubid(config, id, false);
return 0;
}
@@ -1330,7 +1439,7 @@ namespace v2rayN.Handler
#region Routing
public static int SaveRoutingItem(ref Config config, RoutingItem item)
public static int SaveRoutingItem(Config config, RoutingItem item)
{
if (Utils.IsNullOrEmpty(item.id))
{
@@ -1465,7 +1574,7 @@ namespace v2rayN.Handler
return 0;
}
public static int SetDefaultRouting(ref Config config, RoutingItem routingItem)
public static int SetDefaultRouting(Config config, RoutingItem routingItem)
{
if (SqliteHelper.Instance.Table<RoutingItem>().Where(t => t.id == routingItem.id).Count() > 0)
{
@@ -1477,20 +1586,20 @@ namespace v2rayN.Handler
return 0;
}
public static RoutingItem GetDefaultRouting(ref Config config)
public static RoutingItem GetDefaultRouting(Config config)
{
var item = LazyConfig.Instance.GetRoutingItem(config.routingBasicItem.routingIndexId);
if (item is null)
{
var item2 = SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(t => t.locked == false);
SetDefaultRouting(ref config, item2);
SetDefaultRouting(config, item2);
return item2;
}
return item;
}
public static int InitBuiltinRouting(ref Config config, bool blImportAdvancedRules = false)
public static int InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
{
var items = LazyConfig.Instance.RoutingItems();
if (blImportAdvancedRules || items.Count <= 0)
@@ -1525,11 +1634,11 @@ namespace v2rayN.Handler
if (!blImportAdvancedRules)
{
SetDefaultRouting(ref config, item2);
SetDefaultRouting(config, item2);
}
}
if (GetLockedRoutingItem(ref config) == null)
if (GetLockedRoutingItem(config) == null)
{
var item1 = new RoutingItem()
{
@@ -1542,7 +1651,7 @@ namespace v2rayN.Handler
return 0;
}
public static RoutingItem GetLockedRoutingItem(ref Config config)
public static RoutingItem GetLockedRoutingItem(Config config)
{
return SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(it => it.locked == true);
}
@@ -1553,5 +1662,49 @@ namespace v2rayN.Handler
}
#endregion Routing
#region DNS
public static int InitBuiltinDNS(Config config)
{
var items = LazyConfig.Instance.DNSItems();
if (items.Count <= 0)
{
var item = new DNSItem()
{
remarks = "V2ray",
coreType = ECoreType.Xray,
};
SaveDNSItems(config, item);
var item2 = new DNSItem()
{
remarks = "sing-box",
coreType = ECoreType.sing_box,
};
SaveDNSItems(config, item2);
}
return 0;
}
public static int SaveDNSItems(Config config, DNSItem item)
{
if (Utils.IsNullOrEmpty(item.id))
{
item.id = Utils.GetGUID(false);
}
if (SqliteHelper.Instance.Replace(item) > 0)
{
return 0;
}
else
{
return -1;
}
}
#endregion DNS
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,947 @@
using System.Net;
using System.Net.NetworkInformation;
using v2rayN.Base;
using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Handler
{
internal class CoreConfigSingbox
{
private Config _config;
public CoreConfigSingbox(Config config)
{
_config = config;
}
public int GenerateClientConfigContent(ProfileItem node, out SingboxConfig? singboxConfig, out string msg)
{
singboxConfig = null;
try
{
if (node == null
|| node.port <= 0)
{
msg = ResUI.CheckServerSettings;
return -1;
}
msg = ResUI.InitialConfiguration;
string result = Utils.GetEmbedText(Global.SingboxSampleClient);
if (Utils.IsNullOrEmpty(result))
{
msg = ResUI.FailedGetDefaultConfiguration;
return -1;
}
singboxConfig = Utils.FromJson<SingboxConfig>(result);
if (singboxConfig == null)
{
msg = ResUI.FailedGenDefaultConfiguration;
return -1;
}
GenLog(singboxConfig);
GenInbounds(singboxConfig);
GenOutbound(node, singboxConfig.outbounds[0]);
GenMoreOutbounds(node, singboxConfig);
GenRouting(singboxConfig);
GenDns(node, singboxConfig);
GenStatistic(singboxConfig);
msg = string.Format(ResUI.SuccessfulConfiguration, "");
}
catch (Exception ex)
{
Utils.SaveLog("GenerateClientConfig4Singbox", ex);
msg = ResUI.FailedGenDefaultConfiguration;
return -1;
}
return 0;
}
#region private gen function
private int GenLog(SingboxConfig singboxConfig)
{
try
{
switch (_config.coreBasicItem.loglevel)
{
case "debug":
case "info":
case "error":
singboxConfig.log.level = _config.coreBasicItem.loglevel;
break;
case "warning":
singboxConfig.log.level = "warn";
break;
default:
break;
}
if (_config.coreBasicItem.loglevel == "none")
{
singboxConfig.log.disabled = true;
}
if (_config.coreBasicItem.logEnabled)
{
var dtNow = DateTime.Now;
singboxConfig.log.output = Utils.GetLogPath($"sbox_{dtNow:yyyy-MM-dd}.txt");
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private int GenInbounds(SingboxConfig singboxConfig)
{
try
{
singboxConfig.inbounds.Clear();
if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound))
{
var inbound = new Inbound4Sbox()
{
type = Global.InboundSocks,
tag = Global.InboundSocks,
listen = Global.Loopback,
};
singboxConfig.inbounds.Add(inbound);
inbound.listen_port = LazyConfig.Instance.GetLocalPort(Global.InboundSocks);
inbound.sniff = _config.inbound[0].sniffingEnabled;
inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled;
inbound.domain_strategy = Utils.IsNullOrEmpty(_config.routingBasicItem.domainStrategy4Singbox) ? null : _config.routingBasicItem.domainStrategy4Singbox;
if (_config.routingBasicItem.enableRoutingAdvanced)
{
var routing = ConfigHandler.GetDefaultRouting(_config);
if (!Utils.IsNullOrEmpty(routing.domainStrategy4Singbox))
{
inbound.domain_strategy = routing.domainStrategy4Singbox;
}
}
//http
var inbound2 = GetInbound(inbound, Global.InboundHttp, 1, false);
singboxConfig.inbounds.Add(inbound2);
if (_config.inbound[0].allowLANConn)
{
if (_config.inbound[0].newPort4LAN)
{
var inbound3 = GetInbound(inbound, Global.InboundSocks2, 2, true);
inbound3.listen = "::";
singboxConfig.inbounds.Add(inbound3);
var inbound4 = GetInbound(inbound, Global.InboundHttp2, 3, false);
inbound4.listen = "::";
singboxConfig.inbounds.Add(inbound4);
//auth
if (!Utils.IsNullOrEmpty(_config.inbound[0].user) && !Utils.IsNullOrEmpty(_config.inbound[0].pass))
{
inbound3.users = new() { new() { username = _config.inbound[0].user, password = _config.inbound[0].pass } };
inbound4.users = new() { new() { username = _config.inbound[0].user, password = _config.inbound[0].pass } };
}
}
else
{
inbound.listen = "::";
inbound2.listen = "::";
}
}
}
if (_config.tunModeItem.enableTun)
{
if (_config.tunModeItem.mtu <= 0)
{
_config.tunModeItem.mtu = Convert.ToInt32(Global.TunMtus[0]);
}
if (Utils.IsNullOrEmpty(_config.tunModeItem.stack))
{
_config.tunModeItem.stack = Global.TunStacks[0];
}
var tunInbound = Utils.FromJson<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName));
tunInbound.mtu = _config.tunModeItem.mtu;
tunInbound.strict_route = _config.tunModeItem.strictRoute;
tunInbound.stack = _config.tunModeItem.stack;
if (_config.tunModeItem.enableIPv6Address == false)
{
tunInbound.inet6_address = null;
}
singboxConfig.inbounds.Add(tunInbound);
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private Inbound4Sbox? GetInbound(Inbound4Sbox inItem, string tag, int offset, bool bSocks)
{
var inbound = Utils.DeepCopy(inItem);
inbound.tag = tag;
inbound.listen_port = inItem.listen_port + offset;
inbound.type = bSocks ? Global.InboundSocks : Global.InboundHttp;
return inbound;
}
private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
{
try
{
outbound.server = node.address;
outbound.server_port = node.port;
if (node.configType == EConfigType.VMess)
{
outbound.type = Global.ProtocolTypes[EConfigType.VMess];
outbound.uuid = node.id;
outbound.alter_id = node.alterId;
if (Global.VmessSecuritys.Contains(node.security))
{
outbound.security = node.security;
}
else
{
outbound.security = Global.DefaultSecurity;
}
GenOutboundMux(node, outbound);
}
else if (node.configType == EConfigType.Shadowsocks)
{
outbound.type = Global.ProtocolTypes[EConfigType.Shadowsocks];
outbound.method = LazyConfig.Instance.GetShadowsocksSecuritys(node).Contains(node.security) ? node.security : "none";
outbound.password = node.id;
GenOutboundMux(node, outbound);
}
else if (node.configType == EConfigType.Socks)
{
outbound.type = Global.ProtocolTypes[EConfigType.Socks];
outbound.version = "5";
if (!Utils.IsNullOrEmpty(node.security)
&& !Utils.IsNullOrEmpty(node.id))
{
outbound.username = node.security;
outbound.password = node.id;
}
}
else if (node.configType == EConfigType.VLESS)
{
outbound.type = Global.ProtocolTypes[EConfigType.VLESS];
outbound.uuid = node.id;
outbound.packet_encoding = "xudp";
if (Utils.IsNullOrEmpty(node.flow))
{
GenOutboundMux(node, outbound);
}
else
{
outbound.flow = node.flow;
}
}
else if (node.configType == EConfigType.Trojan)
{
outbound.type = Global.ProtocolTypes[EConfigType.Trojan];
outbound.password = node.id;
GenOutboundMux(node, outbound);
}
else if (node.configType == EConfigType.Hysteria2)
{
outbound.type = Global.ProtocolTypes[EConfigType.Hysteria2];
outbound.password = node.id;
outbound.up_mbps = _config.hysteriaItem.up_mbps > 0 ? _config.hysteriaItem.up_mbps : null;
outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null;
GenOutboundMux(node, outbound);
}
else if (node.configType == EConfigType.Tuic)
{
outbound.type = Global.ProtocolTypes[EConfigType.Tuic];
outbound.uuid = node.id;
outbound.password = node.security;
outbound.congestion_control = node.headerType;
GenOutboundMux(node, outbound);
}
GenOutboundTls(node, outbound);
GenOutboundTransport(node, outbound);
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private int GenOutboundMux(ProfileItem node, Outbound4Sbox outbound)
{
try
{
//if (_config.coreBasicItem.muxEnabled)
//{
// var mux = new Multiplex4Sbox()
// {
// enabled = true,
// protocol = _config.mux4Sbox.protocol,
// max_connections = _config.mux4Sbox.max_connections,
// min_streams = _config.mux4Sbox.min_streams,
// max_streams = _config.mux4Sbox.max_streams,
// padding = _config.mux4Sbox.padding
// };
// outbound.multiplex = mux;
//}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private int GenOutboundTls(ProfileItem node, Outbound4Sbox outbound)
{
try
{
if (node.streamSecurity == Global.StreamSecurityReality || node.streamSecurity == Global.StreamSecurity)
{
var server_name = string.Empty;
if (!string.IsNullOrWhiteSpace(node.sni))
{
server_name = node.sni;
}
else if (!string.IsNullOrWhiteSpace(node.requestHost))
{
server_name = Utils.String2List(node.requestHost)[0];
}
var tls = new Tls4Sbox()
{
enabled = true,
server_name = server_name,
insecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.coreBasicItem.defAllowInsecure.ToString().ToLower() : node.allowInsecure),
alpn = node.GetAlpn(),
};
if (!Utils.IsNullOrEmpty(node.fingerprint))
{
tls.utls = new Utls4Sbox()
{
enabled = true,
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint
};
}
if (node.streamSecurity == Global.StreamSecurityReality)
{
tls.reality = new Reality4Sbox()
{
enabled = true,
public_key = node.publicKey,
short_id = node.shortId
};
tls.insecure = false;
}
outbound.tls = tls;
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private int GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound)
{
try
{
var transport = new Transport4Sbox();
switch (node.GetNetwork())
{
case "h2":
transport.type = "http";
transport.host = Utils.IsNullOrEmpty(node.requestHost) ? null : Utils.String2List(node.requestHost);
transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path;
break;
case "ws":
transport.type = "ws";
transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path;
if (!Utils.IsNullOrEmpty(node.requestHost))
{
transport.headers = new()
{
Host = node.requestHost
};
}
break;
case "quic":
transport.type = "quic";
break;
case "grpc":
transport.type = "grpc";
transport.service_name = node.path;
transport.idle_timeout = _config.grpcItem.idle_timeout.ToString("##s");
transport.ping_timeout = _config.grpcItem.health_check_timeout.ToString("##s");
transport.permit_without_stream = _config.grpcItem.permit_without_stream;
break;
default:
transport = null;
break;
}
outbound.transport = transport;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private int GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig)
{
if (node.subid.IsNullOrEmpty())
{
return 0;
}
try
{
var subItem = LazyConfig.Instance.GetSubItem(node.subid);
if (subItem is null)
{
return 0;
}
//current proxy
var outbound = singboxConfig.outbounds[0];
var txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
//Previous proxy
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
if (prevNode is not null
&& prevNode.configType != EConfigType.Custom)
{
var prevOutbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
GenOutbound(prevNode, prevOutbound);
prevOutbound.tag = $"{Global.ProxyTag}2";
singboxConfig.outbounds.Add(prevOutbound);
outbound.detour = prevOutbound.tag;
}
//Next proxy
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
if (nextNode is not null
&& nextNode.configType != EConfigType.Custom)
{
var nextOutbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
GenOutbound(nextNode, nextOutbound);
nextOutbound.tag = Global.ProxyTag;
singboxConfig.outbounds.Insert(0, nextOutbound);
outbound.tag = $"{Global.ProxyTag}1";
nextOutbound.detour = outbound.tag;
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private int GenRouting(SingboxConfig singboxConfig)
{
try
{
if (_config.tunModeItem.enableTun)
{
singboxConfig.route.auto_detect_interface = true;
var tunRules = Utils.FromJson<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName));
singboxConfig.route.rules.AddRange(tunRules);
GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
singboxConfig.route.rules.Add(new()
{
port = new() { 53 },
outbound = "dns_out",
process_name = lstDnsExe
});
singboxConfig.route.rules.Add(new()
{
outbound = "direct",
process_name = lstDirectExe
});
}
if (_config.routingBasicItem.enableRoutingAdvanced)
{
var routing = ConfigHandler.GetDefaultRouting(_config);
if (routing != null)
{
var rules = Utils.FromJson<List<RulesItem>>(routing.ruleSet);
foreach (var item in rules!)
{
if (item.enabled)
{
GenRoutingUserRule(item, singboxConfig.route.rules);
}
}
}
}
else
{
var lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
if (lockedItem != null)
{
var rules = Utils.FromJson<List<RulesItem>>(lockedItem.ruleSet);
foreach (var item in rules!)
{
GenRoutingUserRule(item, singboxConfig.route.rules);
}
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private void GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe)
{
lstDnsExe = new();
lstDirectExe = new();
var coreInfos = LazyConfig.Instance.GetCoreInfos();
foreach (var it in coreInfos)
{
if (it.coreType == ECoreType.v2rayN)
{
continue;
}
foreach (var it2 in it.coreExes)
{
if (!lstDnsExe.Contains(it2) && it.coreType != ECoreType.sing_box)
{
lstDnsExe.Add($"{it2}.exe");
}
if (!lstDirectExe.Contains(it2))
{
lstDirectExe.Add($"{it2}.exe");
}
}
}
}
private int GenRoutingUserRule(RulesItem item, List<Rule4Sbox> rules)
{
try
{
if (item == null)
{
return 0;
}
var rule = new Rule4Sbox()
{
outbound = item.outboundTag,
};
if (!Utils.IsNullOrEmpty(item.port))
{
if (item.port.Contains("-"))
{
rule.port_range = new List<string> { item.port.Replace("-", ":") };
}
else
{
rule.port = new List<int> { Utils.ToInt(item.port) };
}
}
if (item.protocol?.Count > 0)
{
rule.protocol = item.protocol;
}
if (item.inboundTag?.Count >= 0)
{
rule.inbound = item.inboundTag;
}
var rule2 = Utils.DeepCopy(rule);
var rule3 = Utils.DeepCopy(rule);
var hasDomainIp = false;
if (item.domain?.Count > 0)
{
foreach (var it in item.domain)
{
ParseV2Domain(it, rule);
}
rules.Add(rule);
hasDomainIp = true;
}
if (item.ip?.Count > 0)
{
foreach (var it in item.ip)
{
ParseV2Address(it, rule2);
}
rules.Add(rule2);
hasDomainIp = true;
}
if (_config.tunModeItem.enableTun && item.process?.Count > 0)
{
rule3.process_name = item.process;
rules.Add(rule3);
hasDomainIp = true;
}
if (!hasDomainIp)
{
rules.Add(rule);
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private void ParseV2Domain(string domain, Rule4Sbox rule)
{
if (domain.StartsWith("ext:") || domain.StartsWith("ext-domain:"))
{
return;
}
else if (domain.StartsWith("geosite:"))
{
if (rule.geosite is null) { rule.geosite = new(); }
rule.geosite?.Add(domain.Substring(8));
}
else if (domain.StartsWith("regexp:"))
{
if (rule.domain_regex is null) { rule.domain_regex = new(); }
rule.domain_regex?.Add(domain.Replace(Global.RoutingRuleComma, ",").Substring(7));
}
else if (domain.StartsWith("domain:"))
{
if (rule.domain is null) { rule.domain = new(); }
if (rule.domain_suffix is null) { rule.domain_suffix = new(); }
rule.domain?.Add(domain.Substring(7));
rule.domain_suffix?.Add("." + domain.Substring(7));
}
else if (domain.StartsWith("full:"))
{
if (rule.domain is null) { rule.domain = new(); }
rule.domain?.Add(domain.Substring(5));
}
else if (domain.StartsWith("keyword:"))
{
if (rule.domain_keyword is null) { rule.domain_keyword = new(); }
rule.domain_keyword?.Add(domain.Substring(8));
}
else
{
if (rule.domain_keyword is null) { rule.domain_keyword = new(); }
rule.domain_keyword?.Add(domain);
}
}
private void ParseV2Address(string address, Rule4Sbox rule)
{
if (address.StartsWith("ext:") || address.StartsWith("ext-ip:"))
{
return;
}
else if (address.StartsWith("geoip:!"))
{
return;
}
else if (address.StartsWith("geoip:"))
{
if (rule.geoip is null) { rule.geoip = new(); }
rule.geoip?.Add(address.Substring(6));
}
else
{
if (rule.ip_cidr is null) { rule.ip_cidr = new(); }
rule.ip_cidr?.Add(address);
}
}
private int GenDns(ProfileItem node, SingboxConfig singboxConfig)
{
try
{
Dns4Sbox? dns4Sbox;
if (_config.tunModeItem.enableTun)
{
var item = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
var tunDNS = item?.tunDNS;
if (string.IsNullOrWhiteSpace(tunDNS))
{
tunDNS = Utils.GetEmbedText(Global.TunSingboxDNSFileName);
}
dns4Sbox = Utils.FromJson<Dns4Sbox>(tunDNS);
}
else
{
var item = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
var normalDNS = item?.normalDNS;
if (string.IsNullOrWhiteSpace(normalDNS))
{
normalDNS = "{\"servers\":[{\"address\":\"tcp://8.8.8.8\"}]}";
}
dns4Sbox = Utils.FromJson<Dns4Sbox>(normalDNS);
}
if (dns4Sbox is null)
{
return 0;
}
//Add the dns of the remote server domain
if (dns4Sbox.rules is null)
{
dns4Sbox.rules = new();
}
dns4Sbox.servers.Add(new()
{
tag = "local_local",
address = "223.5.5.5",
detour = "direct"
});
dns4Sbox.rules.Add(new()
{
server = "local_local",
outbound = "any"
});
singboxConfig.dns = dns4Sbox;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
return 0;
}
private int GenStatistic(SingboxConfig singboxConfig)
{
if (_config.guiItem.enableStatistics)
{
singboxConfig.experimental = new Experimental4Sbox()
{
//v2ray_api = new V2ray_Api4Sbox()
//{
// listen = $"{Global.Loopback}:{Global.statePort}",
// stats = new Stats4Sbox()
// {
// enabled = true,
// }
//}
clash_api = new Clash_Api4Sbox()
{
external_controller = $"{Global.Loopback}:{Global.StatePort}",
store_selected = true
}
};
}
return 0;
}
#endregion private gen function
#region Gen speedtest config
public int GenerateClientSpeedtestConfig(List<ServerTestItem> selecteds, out SingboxConfig? singboxConfig, out string msg)
{
singboxConfig = null;
try
{
if (_config == null)
{
msg = ResUI.CheckServerSettings;
return -1;
}
msg = ResUI.InitialConfiguration;
string result = Utils.GetEmbedText(Global.SingboxSampleClient);
string txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
{
msg = ResUI.FailedGetDefaultConfiguration;
return -1;
}
singboxConfig = Utils.FromJson<SingboxConfig>(result);
if (singboxConfig == null)
{
msg = ResUI.FailedGenDefaultConfiguration;
return -1;
}
List<IPEndPoint> lstIpEndPoints = new();
List<TcpConnectionInformation> lstTcpConns = new();
try
{
lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners());
lstTcpConns.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections());
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
GenLog(singboxConfig);
GenDns(new(), singboxConfig);
singboxConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
singboxConfig.outbounds.RemoveAt(0);
int httpPort = LazyConfig.Instance.GetLocalPort("speedtest");
foreach (var it in selecteds)
{
if (it.configType == EConfigType.Custom)
{
continue;
}
if (it.port <= 0)
{
continue;
}
if (it.configType is EConfigType.VMess or EConfigType.VLESS)
{
var item2 = LazyConfig.Instance.GetProfileItem(it.indexId);
if (item2 is null || Utils.IsNullOrEmpty(item2.id) || !Utils.IsGuidByParse(item2.id))
{
continue;
}
}
//find unuse port
var port = httpPort;
for (int k = httpPort; k < Global.MaxPort; k++)
{
if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0)
{
continue;
}
if (lstTcpConns?.FindIndex(_it => _it.LocalEndPoint.Port == k) >= 0)
{
continue;
}
//found
port = k;
httpPort = port + 1;
break;
}
//Port In Used
if (lstIpEndPoints?.FindIndex(_it => _it.Port == port) >= 0)
{
continue;
}
it.port = port;
it.allowTest = true;
//inbound
Inbound4Sbox inbound = new()
{
listen = Global.Loopback,
listen_port = port,
type = Global.InboundHttp
};
inbound.tag = Global.InboundHttp + inbound.listen_port.ToString();
singboxConfig.inbounds.Add(inbound);
//outbound
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
if (item is null)
{
continue;
}
if (item.configType == EConfigType.Shadowsocks
&& !Global.SsSecuritysInXray.Contains(item.security))
{
continue;
}
if (item.configType == EConfigType.VLESS
&& !Global.Flows.Contains(item.flow))
{
continue;
}
var outbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
GenOutbound(item, outbound);
outbound.tag = Global.ProxyTag + inbound.listen_port.ToString();
singboxConfig.outbounds.Add(outbound);
//rule
Rule4Sbox rule = new()
{
inbound = new List<string> { inbound.tag },
outbound = outbound.tag
};
singboxConfig.route.rules.Add(rule);
}
//msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
return 0;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
msg = ResUI.FailedGenDefaultConfiguration;
return -1;
}
}
#endregion Gen speedtest config
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.IO;
using System.Reactive.Linq;
using System.Text;
using v2rayN.Mode;
using v2rayN.Resx;
@@ -11,35 +12,30 @@ namespace v2rayN.Handler
/// </summary>
internal class CoreHandler
{
private static string _coreCConfigRes = Global.coreConfigFileName;
private CoreInfo? _coreInfo;
private int _processId = 0;
private Config _config;
private Process? _process;
private Process? _processPre;
private Action<bool, string> _updateFunc;
public CoreHandler(Action<bool, string> update)
public CoreHandler(Config config, Action<bool, string> update)
{
_config = config;
_updateFunc = update;
Environment.SetEnvironmentVariable("v2ray.location.asset", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("xray.location.asset", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
}
public void LoadCore(Config config)
public void LoadCore()
{
var node = ConfigHandler.GetDefaultServer(ref config);
var node = ConfigHandler.GetDefaultServer(_config);
if (node == null)
{
ShowMsg(false, ResUI.CheckServerSettings);
return;
}
if (SetCore(config, node) != 0)
{
ShowMsg(false, ResUI.CheckServerSettings);
return;
}
string fileName = Utils.GetConfigPath(_coreCConfigRes);
string fileName = Utils.GetConfigPath(Global.CoreConfigFileName);
if (CoreConfigHandler.GenerateClientConfig(node, fileName, out string msg, out string content) != 0)
{
ShowMsg(false, msg);
@@ -50,36 +46,40 @@ namespace v2rayN.Handler
ShowMsg(true, $"{node.GetSummary()}");
CoreStop();
CoreStart(node);
}
//start a socks service
if (_process != null && !_process.HasExited && node.configType == EConfigType.Custom && node.preSocksPort > 0)
{
var itemSocks = new ProfileItem()
//In tun mode, do a delay check and restart the core
if (_config.tunModeItem.enableTun)
{
configType = EConfigType.Socks,
address = Global.Loopback,
port = node.preSocksPort
};
if (CoreConfigHandler.GenerateClientConfig(itemSocks, null, out string msg2, out string configStr) == 0)
{
_processId = CoreStartViaString(configStr);
Observable.Range(1, 1)
.Delay(TimeSpan.FromSeconds(15))
.Subscribe(x =>
{
{
if (_process == null || _process.HasExited)
{
CoreStart(node);
ShowMsg(false, "Tun mode restart the core once");
Utils.SaveLog("Tun mode restart the core once");
}
}
});
}
}
}
public int LoadCoreConfigString(Config config, List<ServerTestItem> _selecteds)
public int LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
{
int pid = -1;
string configStr = CoreConfigHandler.GenerateClientSpeedtestConfigString(config, _selecteds, out string msg);
if (configStr == "")
var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.Tuic) ? ECoreType.sing_box : ECoreType.Xray;
string configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
if (CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType, out string msg) != 0)
{
ShowMsg(false, msg);
}
else
{
ShowMsg(false, msg);
pid = CoreStartViaString(configStr);
pid = CoreStartSpeedtest(configPath, coreType);
}
return pid;
}
@@ -88,37 +88,46 @@ namespace v2rayN.Handler
{
try
{
bool hasProc = false;
if (_process != null)
{
KillProcess(_process);
_process.Dispose();
_process = null;
hasProc = true;
}
else
if (_processPre != null)
{
if (_coreInfo == null || _coreInfo.coreExes == null)
KillProcess(_processPre);
_processPre.Dispose();
_processPre = null;
hasProc = true;
}
if (!hasProc)
{
var coreInfos = LazyConfig.Instance.GetCoreInfos();
foreach (var it in coreInfos)
{
return;
}
foreach (string vName in _coreInfo.coreExes)
{
Process[] existing = Process.GetProcessesByName(vName);
foreach (Process p in existing)
if (it.coreType == ECoreType.v2rayN)
{
string? path = p.MainModule?.FileName;
if (path == $"{Utils.GetBinPath(vName, _coreInfo.coreType)}.exe")
continue;
}
foreach (string vName in it.coreExes)
{
var existing = Process.GetProcessesByName(vName);
foreach (Process p in existing)
{
KillProcess(p);
string? path = p.MainModule?.FileName;
if (path == $"{Utils.GetBinPath(vName, it.coreType)}.exe")
{
KillProcess(p);
}
}
}
}
}
if (_processId > 0)
{
CoreStopPid(_processId);
_processId = 0;
}
}
catch (Exception ex)
{
@@ -130,7 +139,7 @@ namespace v2rayN.Handler
{
try
{
Process _p = Process.GetProcessById(pid);
var _p = Process.GetProcessById(pid);
KillProcess(_p);
}
catch (Exception ex)
@@ -163,128 +172,67 @@ namespace v2rayN.Handler
private void CoreStart(ProfileItem node)
{
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString()));
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
try
ECoreType coreType;
if (node.configType != EConfigType.Custom && _config.tunModeItem.enableTun)
{
string fileName = CoreFindexe(_coreInfo);
if (fileName == "") return;
var displayLog = node.configType != EConfigType.Custom || node.displayLog;
Process p = new()
{
StartInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = _coreInfo.arguments,
WorkingDirectory = Utils.GetConfigPath(),
UseShellExecute = false,
RedirectStandardOutput = displayLog,
RedirectStandardError = displayLog,
CreateNoWindow = true,
StandardOutputEncoding = displayLog ? Encoding.UTF8 : null,
StandardErrorEncoding = displayLog ? Encoding.UTF8 : null,
}
};
if (displayLog)
{
p.OutputDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
string msg = e.Data + Environment.NewLine;
ShowMsg(false, msg);
}
};
p.ErrorDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
string msg = e.Data + Environment.NewLine;
ShowMsg(false, msg);
}
};
}
p.Start();
if (displayLog)
{
p.BeginOutputReadLine();
p.BeginErrorReadLine();
}
_process = p;
if (p.WaitForExit(1000))
{
throw new Exception(displayLog ? p.StandardError.ReadToEnd() : "启动进程失败并退出 (Failed to start the process and exited)");
}
Global.processJob.AddProcess(p.Handle);
coreType = ECoreType.sing_box;
}
catch (Exception ex)
else
{
//Utils.SaveLog(Utils.ToJson(node));
Utils.SaveLog(ex.Message, ex);
string msg = ex.Message;
ShowMsg(true, msg);
coreType = LazyConfig.Instance.GetCoreType(node, node.configType);
}
var coreInfo = LazyConfig.Instance.GetCoreInfo(coreType);
var displayLog = node.configType != EConfigType.Custom || node.displayLog;
var proc = RunProcess(node, coreInfo, "", displayLog, ShowMsg);
if (proc is null)
{
return;
}
_process = proc;
//start a socks service
if (_process != null && !_process.HasExited)
{
if ((node.configType == EConfigType.Custom && node.preSocksPort > 0))
{
var itemSocks = new ProfileItem()
{
coreType = ECoreType.sing_box,
configType = EConfigType.Socks,
address = Global.Loopback,
port = node.preSocksPort
};
string fileName2 = Utils.GetConfigPath(Global.CorePreConfigFileName);
if (CoreConfigHandler.GenerateClientConfig(itemSocks, fileName2, out string msg2, out string configStr) == 0)
{
var coreInfo2 = LazyConfig.Instance.GetCoreInfo(ECoreType.sing_box);
var proc2 = RunProcess(node, coreInfo2, $" -c {Global.CorePreConfigFileName}", true, ShowMsg);
if (proc2 is not null)
{
_processPre = proc2;
}
}
}
}
}
private int CoreStartViaString(string configStr)
private int CoreStartSpeedtest(string configPath, ECoreType coreType)
{
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString()));
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
try
{
var coreInfo = LazyConfig.Instance.GetCoreInfo(ECoreType.Xray);
string fileName = CoreFindexe(coreInfo);
if (fileName == "") return -1;
Process p = new()
var coreInfo = LazyConfig.Instance.GetCoreInfo(coreType);
var proc = RunProcess(new(), coreInfo, $" -c {configPath}", true, ShowMsg);
if (proc is null)
{
StartInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = "-config stdin:",
WorkingDirectory = Utils.GetConfigPath(),
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8,
StandardErrorEncoding = Encoding.UTF8
}
};
p.OutputDataReceived += (sender, e) =>
{
if (!String.IsNullOrEmpty(e.Data))
{
string msg = e.Data + Environment.NewLine;
ShowMsg(false, msg);
}
};
p.ErrorDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
string msg = e.Data + Environment.NewLine;
ShowMsg(false, msg);
}
};
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.StandardInput.Write(configStr);
p.StandardInput.Close();
if (p.WaitForExit(1000))
{
throw new Exception(p.StandardError.ReadToEnd());
return -1;
}
Global.processJob.AddProcess(p.Handle);
return p.Id;
return proc.Id;
}
catch (Exception ex)
{
@@ -300,16 +248,89 @@ namespace v2rayN.Handler
_updateFunc(updateToTrayTooltip, msg);
}
private void KillProcess(Process p)
#region Process
private Process? RunProcess(ProfileItem node, CoreInfo coreInfo, string configPath, bool displayLog, Action<bool, string> update)
{
try
{
p.CloseMainWindow();
p.WaitForExit(100);
if (!p.HasExited)
string fileName = CoreFindexe(coreInfo);
if (Utils.IsNullOrEmpty(fileName))
{
p.Kill();
p.WaitForExit(100);
return null;
}
Process proc = new()
{
StartInfo = new()
{
FileName = fileName,
Arguments = string.Format(coreInfo.arguments, configPath),
WorkingDirectory = Utils.GetConfigPath(),
UseShellExecute = false,
RedirectStandardOutput = displayLog,
RedirectStandardError = displayLog,
CreateNoWindow = true,
StandardOutputEncoding = displayLog ? Encoding.UTF8 : null,
StandardErrorEncoding = displayLog ? Encoding.UTF8 : null,
}
};
if (displayLog)
{
proc.OutputDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
string msg = e.Data + Environment.NewLine;
update(false, msg);
}
};
proc.ErrorDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
string msg = e.Data + Environment.NewLine;
update(false, msg);
}
};
}
proc.Start();
if (displayLog)
{
proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
}
if (proc.WaitForExit(1000))
{
throw new Exception(displayLog ? proc.StandardError.ReadToEnd() : "启动进程失败并退出 (Failed to start the process and exited)");
}
Global.ProcessJob.AddProcess(proc.Handle);
return proc;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
string msg = ex.Message;
update(true, msg);
return null;
}
}
private void KillProcess(Process? proc)
{
if (proc is null)
{
return;
}
try
{
proc.CloseMainWindow();
proc.WaitForExit(100);
if (!proc.HasExited)
{
proc.Kill();
proc.WaitForExit(100);
}
}
catch (Exception ex)
@@ -318,21 +339,6 @@ namespace v2rayN.Handler
}
}
private int SetCore(Config config, ProfileItem node)
{
if (node == null)
{
return -1;
}
var coreType = LazyConfig.Instance.GetCoreType(node, node.configType);
_coreInfo = LazyConfig.Instance.GetCoreInfo(coreType);
if (_coreInfo == null)
{
return -1;
}
return 0;
}
#endregion Process
}
}

View File

@@ -62,12 +62,12 @@ namespace v2rayN.Handler
return 0;
}
public void DownloadFileAsync(string url, bool blProxy, int downloadTimeout)
public async Task DownloadFileAsync(string url, bool blProxy, int downloadTimeout)
{
try
{
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, ResUI.Downloading));
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, $"{ResUI.Downloading} {url}"));
var progress = new Progress<double>();
progress.ProgressChanged += (sender, value) =>
@@ -76,7 +76,7 @@ namespace v2rayN.Handler
};
var webProxy = GetWebProxy(blProxy);
_ = DownloaderHelper.Instance.DownloadFileAsync(webProxy,
await DownloaderHelper.Instance.DownloadFileAsync(webProxy,
url,
Utils.GetTempPath(Utils.GetDownloadFileName(url)),
progress,
@@ -206,10 +206,8 @@ namespace v2rayN.Handler
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utils.Base64Encode(uri.UserInfo));
}
var cts = new CancellationTokenSource();
cts.CancelAfter(1000 * 30);
var result = await HttpClientHelper.Instance.GetAsync(client, url, cts.Token);
using var cts = new CancellationTokenSource();
var result = await HttpClientHelper.Instance.GetAsync(client, url, cts.Token).WaitAsync(TimeSpan.FromSeconds(30), cts.Token);
return result;
}
catch (Exception ex)
@@ -255,22 +253,20 @@ namespace v2rayN.Handler
return null;
}
public int RunAvailabilityCheck(IWebProxy? webProxy)
public async Task<int> RunAvailabilityCheck(IWebProxy? webProxy)
{
try
{
if (webProxy == null)
{
var httpPort = LazyConfig.Instance.GetLocalPort(Global.InboundHttp);
webProxy = new WebProxy(Global.Loopback, httpPort);
webProxy = GetWebProxy(true);
}
try
{
var config = LazyConfig.Instance.GetConfig();
string status = GetRealPingTime(config.speedTestItem.speedPingTestUrl, webProxy, 10, out int responseTime);
bool noError = Utils.IsNullOrEmpty(status);
return noError ? responseTime : -1;
int responseTime = await GetRealPingTime(config.speedTestItem.speedPingTestUrl, webProxy, 10);
return responseTime;
}
catch (Exception ex)
{
@@ -285,31 +281,29 @@ namespace v2rayN.Handler
}
}
public string GetRealPingTime(string url, IWebProxy? webProxy, int downloadTimeout, out int responseTime)
public async Task<int> GetRealPingTime(string url, IWebProxy? webProxy, int downloadTimeout)
{
string msg = string.Empty;
responseTime = -1;
int responseTime = -1;
try
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Timeout = downloadTimeout * 1000;
myHttpWebRequest.Proxy = webProxy;
Stopwatch timer = Stopwatch.StartNew();
using HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
if (myHttpWebResponse.StatusCode is not HttpStatusCode.OK and not HttpStatusCode.NoContent)
using var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(downloadTimeout));
using var client = new HttpClient(new SocketsHttpHandler()
{
msg = myHttpWebResponse.StatusDescription;
}
Proxy = webProxy,
UseProxy = webProxy != null
});
await client.GetAsync(url, cts.Token);
responseTime = timer.Elapsed.Milliseconds;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
msg = ex.Message;
//Utils.SaveLog(ex.Message, ex);
}
return msg;
return responseTime;
}
private WebProxy? GetWebProxy(bool blProxy)

View File

@@ -113,9 +113,9 @@ namespace v2rayN.Handler
var mdif = (KeyModifiers)_fsModifiers;
var key = KeyInterop.KeyFromVirtualKey(_vkey);
if ((mdif | KeyModifiers.Ctrl) == KeyModifiers.Ctrl) _hotkeyStr.Append($"{KeyModifiers.Ctrl}+");
if ((mdif | KeyModifiers.Alt) == KeyModifiers.Alt) _hotkeyStr.Append($"{KeyModifiers.Alt}+");
if ((mdif | KeyModifiers.Shift) == KeyModifiers.Shift) _hotkeyStr.Append($"{KeyModifiers.Shift}+");
if ((mdif & KeyModifiers.Ctrl) == KeyModifiers.Ctrl) _hotkeyStr.Append($"{KeyModifiers.Ctrl}+");
if ((mdif & KeyModifiers.Alt) == KeyModifiers.Alt) _hotkeyStr.Append($"{KeyModifiers.Alt}+");
if ((mdif & KeyModifiers.Shift) == KeyModifiers.Shift) _hotkeyStr.Append($"{KeyModifiers.Shift}+");
_hotkeyStr.Append(key.ToString());
foreach (var name in _hotkeyTriggerDic[hotkeycode])

View File

@@ -1,4 +1,5 @@
using v2rayN.Base;
using System.Runtime.Intrinsics.X86;
using v2rayN.Base;
using v2rayN.Mode;
namespace v2rayN.Handler
@@ -18,6 +19,7 @@ namespace v2rayN.Handler
SqliteHelper.Instance.CreateTable<ServerStatItem>();
SqliteHelper.Instance.CreateTable<RoutingItem>();
SqliteHelper.Instance.CreateTable<ProfileExItem>();
SqliteHelper.Instance.CreateTable<DNSItem>();
}
#region Config
@@ -128,6 +130,15 @@ namespace v2rayN.Handler
return SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.indexId == indexId);
}
public ProfileItem? GetProfileItemViaRemarks(string remarks)
{
if (Utils.IsNullOrEmpty(remarks))
{
return null;
}
return SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.remarks == remarks);
}
public List<RoutingItem> RoutingItems()
{
return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).OrderBy(t => t.sort).ToList();
@@ -138,6 +149,16 @@ namespace v2rayN.Handler
return SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(it => it.locked == false && it.id == id);
}
public List<DNSItem> DNSItems()
{
return SqliteHelper.Instance.Table<DNSItem>().ToList();
}
public DNSItem GetDNSItem(ECoreType eCoreType)
{
return SqliteHelper.Instance.Table<DNSItem>().FirstOrDefault(it => it.coreType == eCoreType);
}
#endregion Config
#region Core Type
@@ -146,14 +167,14 @@ namespace v2rayN.Handler
{
if (GetCoreType(profileItem, EConfigType.Shadowsocks) == ECoreType.v2fly)
{
return Global.ssSecuritys;
return Global.SsSecuritys;
}
if (GetCoreType(profileItem, EConfigType.Shadowsocks) == ECoreType.Xray)
{
return Global.ssSecuritysInXray;
return Global.SsSecuritysInXray;
}
return Global.ssSecuritysInSagerNet;
return Global.SsSecuritysInSagerNet;
}
public ECoreType GetCoreType(ProfileItem profileItem, EConfigType eConfigType)
@@ -184,13 +205,13 @@ namespace v2rayN.Handler
return coreInfos!.FirstOrDefault(t => t.coreType == coreType);
}
public List<CoreInfo>? GetCoreInfos()
public List<CoreInfo> GetCoreInfos()
{
if (coreInfos == null)
{
InitCoreInfo();
}
return coreInfos;
return coreInfos!;
}
private void InitCoreInfo()
@@ -201,7 +222,7 @@ namespace v2rayN.Handler
{
coreType = ECoreType.v2rayN,
coreUrl = Global.NUrl,
coreReleaseApiUrl = Global.NUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreReleaseApiUrl = Global.NUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.NUrl + "/download/{0}/v2rayN-32.zip",
coreDownloadUrl64 = Global.NUrl + "/download/{0}/v2rayN.zip",
coreDownloadUrlArm64 = Global.NUrl + "/download/{0}/v2rayN-arm64.zip"
@@ -212,11 +233,11 @@ namespace v2rayN.Handler
coreType = ECoreType.v2fly,
coreExes = new List<string> { "wv2ray", "v2ray" },
arguments = "",
coreUrl = Global.v2flyCoreUrl,
coreReleaseApiUrl = Global.v2flyCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreUrl = Global.V2flyCoreUrl,
coreReleaseApiUrl = Global.V2flyCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
match = "V2Ray",
versionArg = "-version",
redirectInfo = true,
@@ -228,7 +249,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "SagerNet", "v2ray" },
arguments = "run",
coreUrl = Global.SagerNetCoreUrl,
coreReleaseApiUrl = Global.SagerNetCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreReleaseApiUrl = Global.SagerNetCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
@@ -241,12 +262,12 @@ namespace v2rayN.Handler
{
coreType = ECoreType.v2fly_v5,
coreExes = new List<string> { "v2ray" },
arguments = "run",
coreUrl = Global.v2flyCoreUrl,
coreReleaseApiUrl = Global.v2flyCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
arguments = "run -c config.json -format jsonv5",
coreUrl = Global.V2flyCoreUrl,
coreReleaseApiUrl = Global.V2flyCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
match = "V2Ray",
versionArg = "version",
redirectInfo = true,
@@ -256,12 +277,12 @@ namespace v2rayN.Handler
{
coreType = ECoreType.Xray,
coreExes = new List<string> { "xray", "wxray" },
arguments = "",
coreUrl = Global.xrayCoreUrl,
coreReleaseApiUrl = Global.xrayCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrl64 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
arguments = "run {0}",
coreUrl = Global.XrayCoreUrl,
coreReleaseApiUrl = Global.XrayCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.XrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrl64 = Global.XrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.XrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
match = "Xray",
versionArg = "-version",
redirectInfo = true,
@@ -272,11 +293,11 @@ namespace v2rayN.Handler
coreType = ECoreType.clash,
coreExes = new List<string> { "clash-windows-amd64-v3", "clash-windows-amd64", "clash-windows-386", "clash" },
arguments = "-f config.json",
coreUrl = Global.clashCoreUrl,
coreReleaseApiUrl = Global.clashCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.clashCoreUrl + "/download/{0}/clash-windows-386-{0}.zip",
coreDownloadUrl64 = Global.clashCoreUrl + "/download/{0}/clash-windows-amd64-{0}.zip",
coreDownloadUrlArm64 = Global.clashCoreUrl + "/download/{0}/clash-windows-arm64-{0}.zip",
coreUrl = Global.ClashCoreUrl,
coreReleaseApiUrl = Global.ClashCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.ClashCoreUrl + "/download/{0}/clash-windows-386-{0}.zip",
coreDownloadUrl64 = Global.ClashCoreUrl + "/download/{0}/clash-windows-amd64-{0}.zip",
coreDownloadUrlArm64 = Global.ClashCoreUrl + "/download/{0}/clash-windows-arm64-{0}.zip",
match = "v",
versionArg = "-v",
redirectInfo = true,
@@ -287,26 +308,37 @@ namespace v2rayN.Handler
coreType = ECoreType.clash_meta,
coreExes = new List<string> { "Clash.Meta-windows-amd64-compatible", "Clash.Meta-windows-amd64", "Clash.Meta-windows-386", "Clash.Meta", "clash" },
arguments = "-f config.json",
coreUrl = Global.clashMetaCoreUrl,
coreReleaseApiUrl = Global.clashMetaCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-386-{0}.zip",
coreDownloadUrl64 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-amd64-compatible-{0}.zip",
coreDownloadUrlArm64 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-arm64-{0}.zip",
coreUrl = Global.ClashMetaCoreUrl,
coreReleaseApiUrl = Global.ClashMetaCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.ClashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-386-{0}.zip",
coreDownloadUrl64 = Global.ClashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-amd64-compatible-{0}.zip",
coreDownloadUrlArm64 = Global.ClashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-arm64-{0}.zip",
match = "v",
versionArg = "-v",
redirectInfo = true,
});
coreInfos.Add(new CoreInfo
{
coreType = ECoreType.mihomo,
coreExes = new List<string> { $"mihomo-windows-amd64{(Avx2.X64.IsSupported ? "" : "-compatible")}", "mihomo-windows-amd64-compatible", "mihomo-windows-amd64", "mihomo-windows-386", "mihomo", "clash" },
arguments = "-f config.yaml",
coreUrl = Global.MihomoCoreUrl,
coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
match = "Mihomo",
redirectInfo = true,
});
coreInfos.Add(new CoreInfo
{
coreType = ECoreType.hysteria,
coreExes = new List<string> { "hysteria-windows-amd64", "hysteria-windows-386", "hysteria" },
arguments = "",
coreUrl = Global.hysteriaCoreUrl,
coreReleaseApiUrl = Global.hysteriaCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-386.exe",
coreDownloadUrl64 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-amd64.exe",
coreDownloadUrlArm64 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-arm64.exe",
coreUrl = Global.HysteriaCoreUrl,
coreReleaseApiUrl = Global.HysteriaCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-386.exe",
coreDownloadUrl64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-amd64.exe",
coreDownloadUrlArm64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-arm64.exe",
redirectInfo = true,
});
@@ -315,7 +347,7 @@ namespace v2rayN.Handler
coreType = ECoreType.naiveproxy,
coreExes = new List<string> { "naiveproxy", "naive" },
arguments = "config.json",
coreUrl = Global.naiveproxyCoreUrl,
coreUrl = Global.NaiveproxyCoreUrl,
redirectInfo = false,
});
@@ -324,7 +356,7 @@ namespace v2rayN.Handler
coreType = ECoreType.tuic,
coreExes = new List<string> { "tuic-client", "tuic" },
arguments = "-c config.json",
coreUrl = Global.tuicCoreUrl,
coreUrl = Global.TuicCoreUrl,
redirectInfo = true,
});
@@ -332,16 +364,37 @@ namespace v2rayN.Handler
{
coreType = ECoreType.sing_box,
coreExes = new List<string> { "sing-box-client", "sing-box" },
arguments = "run",
coreUrl = Global.singboxCoreUrl,
arguments = "run {0} --disable-color",
coreUrl = Global.SingboxCoreUrl,
redirectInfo = true,
coreReleaseApiUrl = Global.singboxCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.singboxCoreUrl + "/download/{0}/sing-box-{1}-windows-386.zip",
coreDownloadUrl64 = Global.singboxCoreUrl + "/download/{0}/sing-box-{1}-windows-amd64.zip",
coreDownloadUrlArm64 = Global.singboxCoreUrl + "/download/{0}/sing-box-{1}-windows-arm64.zip",
coreReleaseApiUrl = Global.SingboxCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-386.zip",
coreDownloadUrl64 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-amd64.zip",
coreDownloadUrlArm64 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-arm64.zip",
match = "sing-box",
versionArg = "version",
});
coreInfos.Add(new CoreInfo
{
coreType = ECoreType.juicity,
coreExes = new List<string> { "juicity-client", "juicity" },
arguments = "run -c config.json",
coreUrl = Global.JuicityCoreUrl
});
coreInfos.Add(new CoreInfo
{
coreType = ECoreType.hysteria2,
coreExes = new List<string> { "hysteria-windows-amd64", "hysteria-windows-386", "hysteria" },
arguments = "",
coreUrl = Global.HysteriaCoreUrl,
coreReleaseApiUrl = Global.HysteriaCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-386.exe",
coreDownloadUrl64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-amd64.exe",
coreDownloadUrlArm64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-arm64.exe",
redirectInfo = true,
});
}
#endregion Core Type

View File

@@ -77,7 +77,7 @@ namespace v2rayN.Handler
return null;
}
var item = ConfigHandler.GetDefaultRouting(ref config);
var item = ConfigHandler.GetDefaultRouting(config);
if (item == null || Utils.IsNullOrEmpty(item.customIcon) || !File.Exists(item.customIcon))
{
return null;
@@ -144,9 +144,7 @@ namespace v2rayN.Handler
{
return;
}
//Config configCopy = Utils.DeepCopy(config);
//configCopy.index = index;
if (CoreConfigHandler.Export2ClientConfig(item, fileName, out string msg) != 0)
if (CoreConfigHandler.GenerateClientConfig(item, fileName, out string msg, out string content) != 0)
{
UI.Show(msg);
}
@@ -156,134 +154,15 @@ namespace v2rayN.Handler
}
}
public void Export2ServerConfig(ProfileItem item, Config config)
{
if (item == null)
{
return;
}
if (item.configType is not EConfigType.VMess and not EConfigType.VLESS)
{
UI.Show(ResUI.NonVmessService);
return;
}
SaveFileDialog fileDialog = new()
{
Filter = "Config|*.json",
FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != true)
{
return;
}
string fileName = fileDialog.FileName;
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
//Config configCopy = Utils.DeepCopy(config);
//configCopy.index = index;
if (CoreConfigHandler.Export2ServerConfig(item, fileName, out string msg) != 0)
{
UI.Show(msg);
}
else
{
UI.ShowWarning(string.Format(ResUI.SaveServerConfigurationIn, fileName));
}
}
public void BackupGuiNConfig(Config config, bool auto = false)
{
string fileName = $"guiNConfig_{DateTime.Now:yyyy_MM_dd_HH_mm_ss_fff}.json";
if (auto)
{
fileName = Utils.GetBackupPath(fileName);
}
else
{
SaveFileDialog fileDialog = new()
{
FileName = fileName,
Filter = "guiNConfig|*.json",
FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != true)
{
return;
}
fileName = fileDialog.FileName;
}
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
var ret = Utils.ToJsonFile(config, fileName);
if (!auto)
{
if (ret == 0)
{
UI.Show(ResUI.OperationSuccess);
}
else
{
UI.ShowWarning(ResUI.OperationFailed);
}
}
}
public bool RestoreGuiNConfig(ref Config config)
{
var fileContent = string.Empty;
OpenFileDialog fileDialog = new();
fileDialog.InitialDirectory = Utils.GetBackupPath("");
fileDialog.Filter = "guiNConfig|*.json|All|*.*";
fileDialog.FilterIndex = 2;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() == true)
{
fileContent = Utils.LoadResource(fileDialog.FileName);
}
else
{
return false;
}
if (Utils.IsNullOrEmpty(fileContent))
{
UI.ShowWarning(ResUI.OperationFailed);
return false;
}
var resConfig = Utils.FromJson<Config>(fileContent);
if (resConfig == null)
{
UI.ShowWarning(ResUI.OperationFailed);
return false;
}
//backup first
BackupGuiNConfig(config, true);
config = resConfig;
LazyConfig.Instance.SetConfig(config);
return true;
}
public void UpdateTask(Config config, Action<bool, string> update)
{
Task.Run(() => UpdateTaskRunSubscription(config, update));
Task.Run(() => UpdateTaskRunGeo(config, update));
}
private void UpdateTaskRunSubscription(Config config, Action<bool, string> update)
private async Task UpdateTaskRunSubscription(Config config, Action<bool, string> update)
{
Thread.Sleep(60000);
await Task.Delay(60000);
Utils.SaveLog("UpdateTaskRunSubscription");
var updateHandle = new UpdateHandle();
@@ -304,19 +183,19 @@ namespace v2rayN.Handler
Utils.SaveLog("subscription" + msg);
});
item.updateTime = updateTime;
ConfigHandler.AddSubItem(ref config, item);
ConfigHandler.AddSubItem(config, item);
Thread.Sleep(5000);
await Task.Delay(5000);
}
Thread.Sleep(60000);
await Task.Delay(60000);
}
}
private void UpdateTaskRunGeo(Config config, Action<bool, string> update)
private async Task UpdateTaskRunGeo(Config config, Action<bool, string> update)
{
var autoUpdateGeoTime = DateTime.Now;
Thread.Sleep(1000 * 120);
await Task.Delay(1000 * 120);
Utils.SaveLog("UpdateTaskRunGeo");
var updateHandle = new UpdateHandle();
@@ -327,24 +206,15 @@ namespace v2rayN.Handler
{
if ((dtNow - autoUpdateGeoTime).Hours % config.guiItem.autoUpdateInterval == 0)
{
updateHandle.UpdateGeoFile("geosite", config, (bool success, string msg) =>
updateHandle.UpdateGeoFileAll(config, (bool success, string msg) =>
{
update(false, msg);
if (success)
Utils.SaveLog("geosite" + msg);
});
updateHandle.UpdateGeoFile("geoip", config, (bool success, string msg) =>
{
update(false, msg);
if (success)
Utils.SaveLog("geoip" + msg);
});
autoUpdateGeoTime = dtNow;
}
}
Thread.Sleep(1000 * 3600);
await Task.Delay(1000 * 3600);
}
}

View File

@@ -26,7 +26,7 @@ namespace v2rayN.Handler
public void SendMessage(string msg, bool time)
{
msg = $"{DateTime.Now} {msg}";
msg = $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {msg}";
MessageBus.Current.SendMessage(msg, "MsgView");
}
}

View File

@@ -24,7 +24,7 @@ namespace v2rayN.Handler
_lstProfileEx = new(SqliteHelper.Instance.Table<ProfileExItem>());
Task.Run(() =>
Task.Run(async () =>
{
while (true)
{
@@ -38,7 +38,7 @@ namespace v2rayN.Handler
SqliteHelper.Instance.Replace(item);
}
}
Thread.Sleep(1000 * 60);
await Task.Delay(1000 * 60);
}
});
}
@@ -51,7 +51,7 @@ namespace v2rayN.Handler
}
}
private void AddProfileEx(string indexId, ref ProfileExItem profileEx)
private void AddProfileEx(string indexId, ref ProfileExItem? profileEx)
{
profileEx = new()
{

View File

@@ -1,37 +1,68 @@
using Microsoft.Win32;
using System.Runtime.InteropServices;
using static v2rayN.Handler.ProxySetting.InternetConnectionOption;
namespace v2rayN.Handler
{
internal class ProxySetting
{
/// <summary>
// set to use no proxy
/// </summary>
/// <exception cref="ApplicationException">Error message with win32 error code</exception>
public static bool UnsetProxy()
{
return SetProxy(null, null, 1);
}
/// <summary>
/// Set system proxy settings
/// </summary>
/// <param name="strProxy"> proxy address</param>
/// <param name="exceptions">exception addresses that do not use proxy</param>
/// <param name="type">type of proxy defined in PerConnFlags
/// PROXY_TYPE_DIRECT = 0x00000001, // direct connection (no proxy)
/// PROXY_TYPE_PROXY = 0x00000002, // via named proxy
/// PROXY_TYPE_AUTO_PROXY_URL = 0x00000004, // autoproxy script URL
/// PROXY_TYPE_AUTO_DETECT = 0x00000008 // use autoproxy detection
/// </param>
/// <exception cref="ApplicationException">Error message with win32 error code</exception>
/// <returns>true: one of connnection is successfully updated proxy settings</returns>
public static bool SetProxy(string? strProxy, string? exceptions, int type)
{
// set proxy for LAN
bool result = SetConnectionProxy(null, strProxy, exceptions, type);
// set proxy for dial up connections
var connections = EnumerateRasEntries();
foreach (var connection in connections)
{
result |= SetConnectionProxy(connection, strProxy, exceptions, type);
}
return result;
}
private static bool SetConnectionProxy(string? connectionName, string? strProxy, string? exceptions, int type)
{
InternetPerConnOptionList list = new();
int optionCount = 1;
if (type == 1)
if (type == 1) // No proxy
{
optionCount = 1;
}
else if (type is 2 or 4)
else if (type is 2 or 4) // named proxy or autoproxy script URL
{
optionCount = Utils.IsNullOrEmpty(exceptions) ? 2 : 3;
}
int m_Int = (int)PerConnFlags.PROXY_TYPE_DIRECT;
PerConnOption m_Option = PerConnOption.INTERNET_PER_CONN_FLAGS;
if (type == 2)
if (type == 2) // named proxy
{
m_Int = (int)(PerConnFlags.PROXY_TYPE_DIRECT | PerConnFlags.PROXY_TYPE_PROXY);
m_Option = PerConnOption.INTERNET_PER_CONN_PROXY_SERVER;
}
else if (type == 4)
else if (type == 4) // autoproxy script url
{
m_Int = (int)(PerConnFlags.PROXY_TYPE_DIRECT | PerConnFlags.PROXY_TYPE_AUTO_PROXY_URL);
m_Option = PerConnOption.INTERNET_PER_CONN_AUTOCONFIG_URL;
@@ -47,24 +78,31 @@ namespace v2rayN.Handler
if (optionCount > 1)
{
options[1].m_Option = m_Option;
options[1].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(strProxy);
options[1].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(strProxy); // !! remember to deallocate memory 1
// except for these addresses ...
if (optionCount > 2)
{
options[2].m_Option = PerConnOption.INTERNET_PER_CONN_PROXY_BYPASS;
options[2].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(exceptions);
options[2].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(exceptions); // !! remember to deallocate memory 2
}
}
// default stuff
list.dwSize = Marshal.SizeOf(list);
list.szConnection = IntPtr.Zero;
if (connectionName != null)
{
list.szConnection = Marshal.StringToHGlobalAuto(connectionName); // !! remember to deallocate memory 3
}
else
{
list.szConnection = IntPtr.Zero;
}
list.dwOptionCount = options.Length;
list.dwOptionError = 0;
int optSize = Marshal.SizeOf(typeof(InternetConnectionOption));
// make a pointer out of all that ...
IntPtr optionsPtr = Marshal.AllocCoTaskMem(optSize * options.Length);
IntPtr optionsPtr = Marshal.AllocCoTaskMem(optSize * options.Length); // !! remember to deallocate memory 4
// copy the array over into that spot in memory ...
for (int i = 0; i < options.Length; ++i)
{
@@ -83,26 +121,82 @@ namespace v2rayN.Handler
list.options = optionsPtr;
// and then make a pointer out of the whole list
IntPtr ipcoListPtr = Marshal.AllocCoTaskMem(list.dwSize);
IntPtr ipcoListPtr = Marshal.AllocCoTaskMem(list.dwSize); // !! remember to deallocate memory 5
Marshal.StructureToPtr(list, ipcoListPtr, false);
// and finally, call the API method!
int returnvalue = NativeMethods.InternetSetOption(IntPtr.Zero,
bool isSuccess = NativeMethods.InternetSetOption(IntPtr.Zero,
InternetOption.INTERNET_OPTION_PER_CONNECTION_OPTION,
ipcoListPtr, list.dwSize) ? -1 : 0;
if (returnvalue == 0)
ipcoListPtr, list.dwSize);
int returnvalue = 0; // ERROR_SUCCESS
if (!isSuccess)
{ // get the error codes, they might be helpful
returnvalue = Marshal.GetLastWin32Error();
returnvalue = Marshal.GetLastPInvokeError();
}
// FREE the data ASAP
Marshal.FreeCoTaskMem(optionsPtr);
Marshal.FreeCoTaskMem(ipcoListPtr);
if (returnvalue > 0)
{ // throw the error codes, they might be helpful
//throw new Win32Exception(Marshal.GetLastWin32Error());
else
{
// Notify the system that the registry settings have been changed and cause them to be refreshed
NativeMethods.InternetSetOption(IntPtr.Zero, InternetOption.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
NativeMethods.InternetSetOption(IntPtr.Zero, InternetOption.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
}
return (returnvalue < 0);
// FREE the data ASAP
if (list.szConnection != IntPtr.Zero) Marshal.FreeHGlobal(list.szConnection); // release mem 3
if (optionCount > 1)
{
Marshal.FreeHGlobal(options[1].m_Value.m_StringPtr); // release mem 1
if (optionCount > 2)
{
Marshal.FreeHGlobal(options[2].m_Value.m_StringPtr); // release mem 2
}
}
Marshal.FreeCoTaskMem(optionsPtr); // release mem 4
Marshal.FreeCoTaskMem(ipcoListPtr); // release mem 5
if (returnvalue != 0)
{
// throw the error codes, they might be helpful
throw new ApplicationException($"Set Internet Proxy failed with error code: {Marshal.GetLastWin32Error()}");
}
return true;
}
/// <summary>
/// Retrieve list of connections including LAN and WAN to support PPPoE connection
/// </summary>
/// <returns>A list of RAS connection names. May be empty list if no dial up connection.</returns>
/// <exception cref="ApplicationException">Error message with win32 error code</exception>
private static IEnumerable<string> EnumerateRasEntries()
{
int entries = 0;
// attempt to query with 1 entry buffer
RASENTRYNAME[] rasEntryNames = new RASENTRYNAME[1];
int bufferSize = Marshal.SizeOf(typeof(RASENTRYNAME));
rasEntryNames[0].dwSize = Marshal.SizeOf(typeof(RASENTRYNAME));
uint result = NativeMethods.RasEnumEntries(null, null, rasEntryNames, ref bufferSize, ref entries);
// increase buffer if the buffer is not large enough
if (result == (uint)ErrorCode.ERROR_BUFFER_TOO_SMALL)
{
rasEntryNames = new RASENTRYNAME[bufferSize / Marshal.SizeOf(typeof(RASENTRYNAME))];
for (int i = 0; i < rasEntryNames.Length; i++)
{
rasEntryNames[i].dwSize = Marshal.SizeOf(typeof(RASENTRYNAME));
}
result = NativeMethods.RasEnumEntries(null, null, rasEntryNames, ref bufferSize, ref entries);
}
if (result == 0)
{
var entryNames = new List<string>();
for (int i = 0; i < entries; i++)
{
entryNames.Add(rasEntryNames[i].szEntryName);
}
return entryNames;
}
throw new ApplicationException($"RasEnumEntries failed with error code: {result}");
}
#region WinInet structures
@@ -145,6 +239,25 @@ namespace v2rayN.Handler
[FieldOffset(0)]
public IntPtr m_StringPtr;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct RASENTRYNAME
{
public int dwSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxEntryName + 1)]
public string szEntryName;
public int dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH + 1)]
public string szPhonebookPath;
}
// Constants
public const int RAS_MaxEntryName = 256;
public const int MAX_PATH = 260; // Standard MAX_PATH value in Windows
}
#endregion WinInet structures
@@ -156,7 +269,9 @@ namespace v2rayN.Handler
//
public enum InternetOption : uint
{
INTERNET_OPTION_PER_CONNECTION_OPTION = 75
INTERNET_OPTION_PER_CONNECTION_OPTION = 75,
INTERNET_OPTION_REFRESH = 37,
INTERNET_OPTION_SETTINGS_CHANGED = 39
}
//
@@ -182,6 +297,12 @@ namespace v2rayN.Handler
PROXY_TYPE_AUTO_DETECT = 0x00000008 // use autoproxy detection
}
public enum ErrorCode : uint
{
ERROR_BUFFER_TOO_SMALL = 603,
ERROR_INVALID_SIZE = 632
}
#endregion WinInet enums
internal static class NativeMethods
@@ -189,6 +310,15 @@ namespace v2rayN.Handler
[DllImport("WinInet.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InternetSetOption(IntPtr hInternet, InternetOption dwOption, IntPtr lpBuffer, int dwBufferLength);
[DllImport("Rasapi32.dll", CharSet = CharSet.Auto)]
public static extern uint RasEnumEntries(
string? reserved, // Reserved, must be null
string? lpszPhonebook, // Pointer to full path and filename of phone-book file. If this parameter is NULL, the entries are enumerated from all the remote access phone-book files
[In, Out] RASENTRYNAME[]? lprasentryname, // Buffer to receive RAS entry names
ref int lpcb, // Size of the buffer
ref int lpcEntries // Number of entries written to the buffer
);
}
//判断是否使用代理

View File

@@ -29,6 +29,8 @@ namespace v2rayN.Handler
EConfigType.Socks => ShareSocks(item),
EConfigType.Trojan => ShareTrojan(item),
EConfigType.VLESS => ShareVLESS(item),
EConfigType.Hysteria2 => ShareHysteria2(item),
EConfigType.Tuic => ShareTuic(item),
_ => null,
};
@@ -66,7 +68,7 @@ namespace v2rayN.Handler
url = Utils.ToJson(vmessQRCode);
url = Utils.Base64Encode(url);
url = $"{Global.vmessProtocol}{url}";
url = $"{Global.ProtocolShares[EConfigType.VMess]}{url}";
return url;
}
@@ -89,7 +91,7 @@ namespace v2rayN.Handler
//new Sip002
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
url = $"{Global.ssProtocol}{url}{remark}";
url = $"{Global.ProtocolShares[EConfigType.Shadowsocks]}{url}{remark}";
return url;
}
@@ -110,7 +112,7 @@ namespace v2rayN.Handler
//new
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
url = $"{Global.socksProtocol}{url}{remark}";
url = $"{Global.ProtocolShares[EConfigType.Socks]}{url}{remark}";
return url;
}
@@ -130,7 +132,7 @@ namespace v2rayN.Handler
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.trojanProtocol}{url}{query}{remark}";
url = $"{Global.ProtocolShares[EConfigType.Trojan]}{url}{query}{remark}";
return url;
}
@@ -158,7 +160,65 @@ namespace v2rayN.Handler
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.vlessProtocol}{url}{query}{remark}";
url = $"{Global.ProtocolShares[EConfigType.VLESS]}{url}{query}{remark}";
return url;
}
private static string ShareHysteria2(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utils.IsNullOrEmpty(item.alpn))
{
dicQuery.Add("alpn", Utils.UrlEncode(item.alpn));
}
dicQuery.Add("insecure", item.allowInsecure.ToLower() == "true" ? "1" : "0");
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Hysteria2]}{url}{query}{remark}";
return url;
}
private static string ShareTuic(ProfileItem item)
{
string url = string.Empty;
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utils.IsNullOrEmpty(item.alpn))
{
dicQuery.Add("alpn", Utils.UrlEncode(item.alpn));
}
dicQuery.Add("congestion_control", item.headerType);
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
$"{item.id}:{item.security}",
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Tuic]}{url}{query}{remark}";
return url;
}
@@ -299,7 +359,7 @@ namespace v2rayN.Handler
return null;
}
if (result.StartsWith(Global.vmessProtocol))
if (result.StartsWith(Global.ProtocolShares[EConfigType.VMess]))
{
int indexSplit = result.IndexOf("?");
if (indexSplit > 0)
@@ -311,7 +371,7 @@ namespace v2rayN.Handler
profileItem = ResolveVmess(result, out msg);
}
}
else if (result.StartsWith(Global.ssProtocol))
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Shadowsocks]))
{
msg = ResUI.ConfigurationFormatIncorrect;
@@ -327,7 +387,7 @@ namespace v2rayN.Handler
profileItem.configType = EConfigType.Shadowsocks;
}
else if (result.StartsWith(Global.socksProtocol))
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Socks]))
{
msg = ResUI.ConfigurationFormatIncorrect;
@@ -343,16 +403,26 @@ namespace v2rayN.Handler
profileItem.configType = EConfigType.Socks;
}
else if (result.StartsWith(Global.trojanProtocol))
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Trojan]))
{
msg = ResUI.ConfigurationFormatIncorrect;
profileItem = ResolveTrojan(result);
}
else if (result.StartsWith(Global.vlessProtocol))
else if (result.StartsWith(Global.ProtocolShares[EConfigType.VLESS]))
{
profileItem = ResolveStdVLESS(result);
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2]) || result.StartsWith(Global.Hysteria2ProtocolShare))
{
msg = ResUI.ConfigurationFormatIncorrect;
profileItem = ResolveHysteria2(result);
}
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Tuic]))
{
profileItem = ResolveTuic(result);
}
else
{
msg = ResUI.NonvmessOrssProtocol;
@@ -377,7 +447,7 @@ namespace v2rayN.Handler
configType = EConfigType.VMess
};
result = result[Global.vmessProtocol.Length..];
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
result = Utils.Base64Decode(result);
//转成Json
@@ -425,7 +495,7 @@ namespace v2rayN.Handler
{
configType = EConfigType.VMess
};
result = result[Global.vmessProtocol.Length..];
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
int indexSplit = result.IndexOf("?");
if (indexSplit > 0)
{
@@ -484,7 +554,6 @@ namespace v2rayN.Handler
switch (i.streamSecurity)
{
case "tls":
// TODO tls config
break;
default:
@@ -499,13 +568,10 @@ namespace v2rayN.Handler
case "tcp":
string t1 = q["type"] ?? "none";
i.headerType = t1;
// TODO http option
break;
case "kcp":
i.headerType = q["type"] ?? "none";
// TODO kcp seed
break;
case "ws":
@@ -633,7 +699,7 @@ namespace v2rayN.Handler
server.security = details.Groups["method"].Value;
server.id = details.Groups["password"].Value;
server.address = details.Groups["hostname"].Value;
server.port = int.Parse(details.Groups["port"].Value);
server.port = Utils.ToInt(details.Groups["port"].Value);
return server;
}
@@ -646,7 +712,7 @@ namespace v2rayN.Handler
{
configType = EConfigType.Socks
};
result = result[Global.socksProtocol.Length..];
result = result[Global.ProtocolShares[EConfigType.Socks].Length..];
//remark
int indexRemark = result.IndexOf("#");
if (indexRemark > 0)
@@ -762,6 +828,53 @@ namespace v2rayN.Handler
return item;
}
private static ProfileItem ResolveHysteria2(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Hysteria2
};
Uri url = new(result);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
item.id = url.UserInfo;
var query = HttpUtility.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
item.allowInsecure = (query["insecure"] ?? "") == "1" ? "true" : "false";
return item;
}
private static ProfileItem ResolveTuic(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Tuic
};
Uri url = new(result);
item.address = url.IdnHost;
item.port = url.Port;
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
var userInfoParts = url.UserInfo.Split(new[] { ':' }, 2);
if (userInfoParts.Length == 2)
{
item.id = userInfoParts[0];
item.security = userInfoParts[1];
}
var query = HttpUtility.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
item.headerType = query["congestion_control"] ?? "";
return item;
}
private static int ResolveStdTransport(NameValueCollection query, ref ProfileItem item)
{
item.flow = query["flow"] ?? "";

View File

@@ -95,7 +95,7 @@ namespace v2rayN.Handler
}
}
private void RunPingSub(Action<ServerTestItem> updateFun)
private async Task RunPingSubAsync(Action<ServerTestItem> updateFun)
{
try
{
@@ -111,7 +111,7 @@ namespace v2rayN.Handler
}
}
Thread.Sleep(10);
await Task.Delay(10);
}
catch (Exception ex)
{
@@ -119,21 +119,21 @@ namespace v2rayN.Handler
}
}
private void RunPing()
private async void RunPing()
{
RunPingSub((ServerTestItem it) =>
{
long time = Ping(it.address);
var output = FormatOut(time, Global.DelayUnit);
await RunPingSubAsync((ServerTestItem it) =>
{
long time = Ping(it.address);
var output = FormatOut(time, Global.DelayUnit);
ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
UpdateFunc(it.indexId, output);
});
ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
UpdateFunc(it.indexId, output);
});
}
private void RunTcping()
private async void RunTcping()
{
RunPingSub((ServerTestItem it) =>
await RunPingSubAsync((ServerTestItem it) =>
{
int time = GetTcpingTime(it.address, it.port);
var output = FormatOut(time, Global.DelayUnit);
@@ -150,7 +150,7 @@ namespace v2rayN.Handler
{
string msg = string.Empty;
pid = _coreHandler.LoadCoreConfigString(_config, _selecteds);
pid = _coreHandler.LoadCoreConfigSpeedtest(_selecteds);
if (pid < 0)
{
UpdateFunc("", ResUI.FailedToRunCore);
@@ -158,7 +158,7 @@ namespace v2rayN.Handler
}
DownloadHandle downloadHandle = new DownloadHandle();
//Thread.Sleep(5000);
List<Task> tasks = new();
foreach (var it in _selecteds)
{
@@ -170,12 +170,12 @@ namespace v2rayN.Handler
{
continue;
}
tasks.Add(Task.Run(() =>
tasks.Add(Task.Run(async () =>
{
try
{
WebProxy webProxy = new(Global.Loopback, it.port);
string output = GetRealPingTime(downloadHandle, webProxy);
string output = await GetRealPingTime(downloadHandle, webProxy);
ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
UpdateFunc(it.indexId, output);
@@ -187,7 +187,6 @@ namespace v2rayN.Handler
Utils.SaveLog(ex.Message, ex);
}
}));
//Thread.Sleep(100);
}
Task.WaitAll(tasks.ToArray());
}
@@ -197,7 +196,10 @@ namespace v2rayN.Handler
}
finally
{
if (pid > 0) _coreHandler.CoreStopPid(pid);
if (pid > 0)
{
_coreHandler.CoreStopPid(pid);
}
ProfileExHandler.Instance.SaveTo();
}
@@ -212,7 +214,7 @@ namespace v2rayN.Handler
// _selecteds = _selecteds.OrderBy(t => t.delay).ToList();
//}
pid = _coreHandler.LoadCoreConfigString(_config, _selecteds);
pid = _coreHandler.LoadCoreConfigSpeedtest(_selecteds);
if (pid < 0)
{
UpdateFunc("", ResUI.FailedToRunCore);
@@ -269,7 +271,7 @@ namespace v2rayN.Handler
private async Task RunSpeedTestMulti()
{
int pid = -1;
pid = _coreHandler.LoadCoreConfigString(_config, _selecteds);
pid = _coreHandler.LoadCoreConfigSpeedtest(_selecteds);
if (pid < 0)
{
UpdateFunc("", ResUI.FailedToRunCore);
@@ -312,10 +314,10 @@ namespace v2rayN.Handler
}
UpdateFunc(it.indexId, "", msg);
});
Thread.Sleep(2000);
await Task.Delay(2000);
}
Thread.Sleep((timeout + 2) * 1000);
await Task.Delay((timeout + 2) * 1000);
if (pid > 0)
{
@@ -329,16 +331,16 @@ namespace v2rayN.Handler
{
await RunRealPing();
Thread.Sleep(1000);
await Task.Delay(1000);
await RunSpeedTestMulti();
}
public string GetRealPingTime(DownloadHandle downloadHandle, IWebProxy webProxy)
public async Task<string> GetRealPingTime(DownloadHandle downloadHandle, IWebProxy webProxy)
{
string status = downloadHandle.GetRealPingTime(_config.speedTestItem.speedPingTestUrl, webProxy, 10, out int responseTime);
int responseTime = await downloadHandle.GetRealPingTime(_config.speedTestItem.speedPingTestUrl, webProxy, 10);
//string output = Utils.IsNullOrEmpty(status) ? FormatOut(responseTime, "ms") : status;
return FormatOut(Utils.IsNullOrEmpty(status) ? responseTime : -1, Global.DelayUnit);
return FormatOut(responseTime, Global.DelayUnit);
}
private int GetTcpingTime(string url, int port)

View File

@@ -1,7 +1,4 @@
using Grpc.Core;
using Grpc.Net.Client;
using ProtosLib.Statistics;
using System.Net;
using System.Net;
using System.Net.Sockets;
using v2rayN.Base;
using v2rayN.Mode;
@@ -10,51 +7,40 @@ namespace v2rayN.Handler
{
internal class StatisticsHandler
{
private Mode.Config config_;
private GrpcChannel _channel;
private StatsService.StatsServiceClient _client;
private bool _exitFlag;
private Config _config;
private ServerStatItem? _serverStatItem;
private List<ServerStatItem> _lstServerStat;
public List<ServerStatItem> ServerStat => _lstServerStat;
private Action<ServerSpeedItem> _updateFunc;
private StatisticsV2ray? _statisticsV2Ray;
private StatisticsSingbox? _statisticsSingbox;
public bool Enable
{
get; set;
}
public List<ServerStatItem> ServerStat => _lstServerStat;
public bool Enable { get; set; }
public StatisticsHandler(Mode.Config config, Action<ServerSpeedItem> update)
public StatisticsHandler(Config config, Action<ServerSpeedItem> update)
{
config_ = config;
_config = config;
Enable = config.guiItem.enableStatistics;
if (!Enable)
{
return;
}
_updateFunc = update;
_exitFlag = false;
Init();
GrpcInit();
Global.StatePort = GetFreePort();
Task.Run(Run);
}
private void GrpcInit()
{
if (_channel == null)
{
Global.statePort = GetFreePort();
_channel = GrpcChannel.ForAddress($"{Global.httpProtocol}{Global.Loopback}:{Global.statePort}");
_client = new StatsService.StatsServiceClient(_channel);
}
_statisticsV2Ray = new StatisticsV2ray(config, UpdateServerStat);
_statisticsSingbox = new StatisticsSingbox(config, UpdateServerStat);
}
public void Close()
{
try
{
_exitFlag = true;
//channel_.ShutdownAsync();
_statisticsV2Ray?.Close();
_statisticsSingbox?.Close();
}
catch (Exception ex)
{
@@ -62,57 +48,6 @@ namespace v2rayN.Handler
}
}
public async void Run()
{
while (!_exitFlag)
{
try
{
if (Enable && _channel.State == ConnectivityState.Ready)
{
QueryStatsResponse? res = null;
try
{
res = await _client.QueryStatsAsync(new QueryStatsRequest() { Pattern = "", Reset = true });
}
catch (Exception ex)
{
//Utils.SaveLog(ex.Message, ex);
}
if (res != null)
{
GetServerStatItem(config_.indexId);
ParseOutput(res.Stat, out ServerSpeedItem server);
if (server.proxyUp != 0 || server.proxyDown != 0)
{
_serverStatItem.todayUp += server.proxyUp;
_serverStatItem.todayDown += server.proxyDown;
_serverStatItem.totalUp += server.proxyUp;
_serverStatItem.totalDown += server.proxyDown;
}
if (Global.ShowInTaskbar)
{
server.indexId = config_.indexId;
server.todayUp = _serverStatItem.todayUp;
server.todayDown = _serverStatItem.todayDown;
server.totalUp = _serverStatItem.totalUp;
server.totalDown = _serverStatItem.totalDown;
_updateFunc(server);
}
}
}
var sleep = config_.guiItem.statisticsFreshRate < 1 ? 1 : config_.guiItem.statisticsFreshRate;
Thread.Sleep(1000 * sleep);
await _channel.ConnectAsync();
}
catch
{
}
}
}
public void ClearAllServerStatistics()
{
SqliteHelper.Instance.Execute($"delete from ServerStatItem ");
@@ -142,6 +77,28 @@ namespace v2rayN.Handler
_lstServerStat = SqliteHelper.Instance.Table<ServerStatItem>().ToList();
}
private void UpdateServerStat(ServerSpeedItem server)
{
GetServerStatItem(_config.indexId);
if (server.proxyUp != 0 || server.proxyDown != 0)
{
_serverStatItem.todayUp += server.proxyUp;
_serverStatItem.todayDown += server.proxyDown;
_serverStatItem.totalUp += server.proxyUp;
_serverStatItem.totalDown += server.proxyDown;
}
if (Global.ShowInTaskbar)
{
server.indexId = _config.indexId;
server.todayUp = _serverStatItem.todayUp;
server.todayDown = _serverStatItem.todayDown;
server.totalUp = _serverStatItem.totalUp;
server.totalDown = _serverStatItem.totalDown;
_updateFunc(server);
}
}
private void GetServerStatItem(string indexId)
{
long ticks = DateTime.Now.Date.Ticks;
@@ -177,71 +134,28 @@ namespace v2rayN.Handler
}
}
private void ParseOutput(Google.Protobuf.Collections.RepeatedField<Stat> source, out ServerSpeedItem server)
{
server = new();
try
{
foreach (Stat stat in source)
{
string name = stat.Name;
long value = stat.Value / 1024; //KByte
string[] nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
string type = "";
name = name.Trim();
name = nStr[1];
type = nStr[3];
if (name == Global.agentTag)
{
if (type == "uplink")
{
server.proxyUp = value;
}
else if (type == "downlink")
{
server.proxyDown = value;
}
}
else if (name == Global.directTag)
{
if (type == "uplink")
{
server.directUp = value;
}
else if (type == "downlink")
{
server.directDown = value;
}
}
}
}
catch (Exception ex)
{
//Utils.SaveLog(ex.Message, ex);
}
}
private int GetFreePort()
{
int defaultPort = 28123;
try
{
// TCP stack please do me a favor
TcpListener l = new(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
int defaultPort = 9090;
if (!Utils.PortInUse(defaultPort))
{
return defaultPort;
}
for (int i = 0; i < 3; i++)
{
TcpListener l = new(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
}
}
catch (Exception ex)
catch
{
// in case access denied
Utils.SaveLog(ex.Message, ex);
return defaultPort;
}
return 69090;
}
}
}

View File

@@ -0,0 +1,128 @@
using System.Net.WebSockets;
using System.Text;
using v2rayN.Mode;
namespace v2rayN.Handler
{
internal class StatisticsSingbox
{
private Config _config;
private bool _exitFlag;
private ClientWebSocket? webSocket;
private string url = string.Empty;
private Action<ServerSpeedItem> _updateFunc;
public StatisticsSingbox(Config config, Action<ServerSpeedItem> update)
{
_config = config;
_updateFunc = update;
_exitFlag = false;
Task.Run(() => Run());
}
private async void Init()
{
await Task.Delay(5000);
try
{
url = $"ws://{Global.Loopback}:{Global.StatePort}/traffic";
if (webSocket == null)
{
webSocket = new ClientWebSocket();
await webSocket.ConnectAsync(new Uri(url), CancellationToken.None);
}
}
catch { }
}
public void Close()
{
try
{
_exitFlag = true;
if (webSocket != null)
{
webSocket.Abort();
webSocket = null;
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private async void Run()
{
Init();
while (!_exitFlag)
{
try
{
if (webSocket != null)
{
if (webSocket.State == WebSocketState.Aborted
|| webSocket.State == WebSocketState.Closed)
{
webSocket.Abort();
webSocket = null;
Init();
continue;
}
if (webSocket.State != WebSocketState.Open)
{
continue;
}
var buffer = new byte[1024];
var res = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
while (!res.CloseStatus.HasValue)
{
var result = Encoding.UTF8.GetString(buffer, 0, res.Count);
if (!string.IsNullOrEmpty(result))
{
ParseOutput(result, out ulong up, out ulong down);
_updateFunc(new ServerSpeedItem()
{
proxyUp = (long)(up / 1000),
proxyDown = (long)(down / 1000)
});
}
res = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
}
}
}
catch
{
}
finally
{
await Task.Delay(1000);
}
}
}
private void ParseOutput(string source, out ulong up, out ulong down)
{
up = 0; down = 0;
try
{
var trafficItem = Utils.FromJson<TrafficItem>(source);
if (trafficItem != null)
{
up = trafficItem.up;
down = trafficItem.down;
}
}
catch
{
}
}
}
}

View File

@@ -0,0 +1,119 @@
using Grpc.Core;
using Grpc.Net.Client;
using ProtosLib.Statistics;
using v2rayN.Mode;
namespace v2rayN.Handler
{
internal class StatisticsV2ray
{
private Mode.Config _config;
private GrpcChannel _channel;
private StatsService.StatsServiceClient _client;
private bool _exitFlag;
private Action<ServerSpeedItem> _updateFunc;
public StatisticsV2ray(Mode.Config config, Action<ServerSpeedItem> update)
{
_config = config;
_updateFunc = update;
_exitFlag = false;
GrpcInit();
Task.Run(Run);
}
private void GrpcInit()
{
if (_channel == null)
{
_channel = GrpcChannel.ForAddress($"{Global.HttpProtocol}{Global.Loopback}:{Global.StatePort}");
_client = new StatsService.StatsServiceClient(_channel);
}
}
public void Close()
{
_exitFlag = true;
}
private async void Run()
{
while (!_exitFlag)
{
try
{
if (_channel.State == ConnectivityState.Ready)
{
QueryStatsResponse? res = null;
try
{
res = await _client.QueryStatsAsync(new QueryStatsRequest() { Pattern = "", Reset = true });
}
catch
{
}
if (res != null)
{
ParseOutput(res.Stat, out ServerSpeedItem server);
_updateFunc(server);
}
}
await Task.Delay(1000);
await _channel.ConnectAsync();
}
catch
{
}
}
}
private void ParseOutput(Google.Protobuf.Collections.RepeatedField<Stat> source, out ServerSpeedItem server)
{
server = new();
try
{
foreach (Stat stat in source)
{
string name = stat.Name;
long value = stat.Value / 1024; //KByte
string[] nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
string type = "";
name = name.Trim();
name = nStr[1];
type = nStr[3];
if (name == Global.ProxyTag)
{
if (type == "uplink")
{
server.proxyUp = value;
}
else if (type == "downlink")
{
server.proxyDown = value;
}
}
else if (name == Global.DirectTag)
{
if (type == "uplink")
{
server.directUp = value;
}
else if (type == "downlink")
{
server.directDown = value;
}
}
}
}
catch
{
}
}
}
}

View File

@@ -1,10 +1,5 @@
using PacLib;
using System.Diagnostics;
using System.IO;
using System.Text;
using v2rayN.Mode;
using v2rayN.Properties;
using v2rayN.Tool;
namespace v2rayN.Handler
{
@@ -20,7 +15,6 @@ namespace v2rayN.Handler
// <proxy-server><CR-LF>
// <bypass-list><CR-LF>
// <pac-url>
private static SysproxyConfig? _userSettings = null;
private enum RET_ERRORS : int
{
@@ -34,15 +28,6 @@ namespace v2rayN.Handler
static SysProxyHandle()
{
try
{
FileManager.UncompressFile(Utils.GetTempPath("sysproxy.exe"),
Environment.Is64BitOperatingSystem ? Resources.sysproxy64_exe : Resources.sysproxy_exe);
}
catch (IOException ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
public static bool UpdateSysProxy(Config config, bool forceDisable)
@@ -79,11 +64,11 @@ namespace v2rayN.Handler
.Replace("{http_port}", port.ToString())
.Replace("{socks_port}", portSocks.ToString());
}
SetIEProxy(true, strProxy, strExceptions);
ProxySetting.SetProxy(strProxy, strExceptions, 2); // set a named proxy
}
else if (type == ESysProxyType.ForcedClear)
{
ResetIEProxy();
ProxySetting.UnsetProxy(); // set to no proxy
}
else if (type == ESysProxyType.Unchanged)
{
@@ -91,8 +76,8 @@ namespace v2rayN.Handler
else if (type == ESysProxyType.Pac)
{
PacHandler.Start(Utils.GetConfigPath(), port, portPac);
var strProxy = $"{Global.httpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
SetIEProxy(false, strProxy, "");
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
ProxySetting.SetProxy(strProxy, "", 4); // use pac script url for auto-config proxy
}
if (type != ESysProxyType.Pac)
@@ -118,115 +103,5 @@ namespace v2rayN.Handler
{
}
}
public static void SetIEProxy(bool global, string strProxy, string strExceptions)
{
string arguments = global
? $"global {strProxy} {strExceptions}"
: $"pac {strProxy}";
ExecSysproxy(arguments);
}
// set system proxy to 1 (null) (null) (null)
public static bool ResetIEProxy()
{
try
{
// clear user-wininet.json
//_userSettings = new SysproxyConfig();
//Save();
// clear system setting
ExecSysproxy("set 1 - - -");
}
catch (Exception)
{
return false;
}
return true;
}
private static void ExecSysproxy(string arguments)
{
// using event to avoid hanging when redirect standard output/error
// ref: https://stackoverflow.com/questions/139593/processstartinfo-hanging-on-waitforexit-why
// and http://blog.csdn.net/zhangweixing0/article/details/7356841
using AutoResetEvent outputWaitHandle = new(false);
using AutoResetEvent errorWaitHandle = new(false);
using Process process = new();
// Configure the process using the StartInfo properties.
process.StartInfo.FileName = Utils.GetTempPath("sysproxy.exe");
process.StartInfo.Arguments = arguments;
process.StartInfo.WorkingDirectory = Utils.GetTempPath();
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
// Need to provide encoding info, or output/error strings we got will be wrong.
process.StartInfo.StandardOutputEncoding = Encoding.Unicode;
process.StartInfo.StandardErrorEncoding = Encoding.Unicode;
process.StartInfo.CreateNoWindow = true;
StringBuilder output = new(1024);
StringBuilder error = new(1024);
process.OutputDataReceived += (sender, e) =>
{
if (e.Data == null)
{
outputWaitHandle.Set();
}
else
{
output.AppendLine(e.Data);
}
};
process.ErrorDataReceived += (sender, e) =>
{
if (e.Data == null)
{
errorWaitHandle.Set();
}
else
{
error.AppendLine(e.Data);
}
};
try
{
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
process.WaitForExit();
}
catch (System.ComponentModel.Win32Exception e)
{
// log the arguments
throw new Exception(process.StartInfo.Arguments);
}
string stderr = error.ToString();
string stdout = output.ToString();
int exitCode = process.ExitCode;
if (exitCode != (int)RET_ERRORS.RET_NO_ERROR)
{
throw new Exception(stderr);
}
//if (arguments == "query")
//{
// if (stdout.IsNullOrWhiteSpace() || stdout.IsNullOrEmpty())
// {
// throw new Exception("failed to query wininet settings");
// }
// _queryStr = stdout;
//}
}
}
}

View File

@@ -1,358 +0,0 @@
using System.Diagnostics;
using System.IO;
using System.Reactive.Linq;
using v2rayN.Handler;
using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Base
{
public sealed class TunHandler
{
private static readonly Lazy<TunHandler> _instance = new(() => new());
public static TunHandler Instance => _instance.Value;
private string _tunConfigName = "tunConfig.json";
private static Config _config;
private CoreInfo coreInfo;
private Process? _process;
private static int _socksPort;
private static bool _needRestart = true;
private static bool _isRunning = false;
public TunHandler()
{
_config = LazyConfig.Instance.GetConfig();
Observable.Interval(TimeSpan.FromSeconds(10))
.Subscribe(x =>
{
if (_isRunning && _config.tunModeItem.enableTun)
{
if (_process == null || _process.HasExited)
{
if (Init() == false)
{
return;
}
CoreStart();
Utils.SaveLog("Tun mode monitors restart");
}
}
});
}
public void Start()
{
var socksPort = LazyConfig.Instance.GetLocalPort(Global.InboundSocks);
if (socksPort == _socksPort
&& _process != null
&& !_process.HasExited)
{
_needRestart = false;
}
_socksPort = socksPort;
if (_needRestart)
{
CoreStop();
if (Init() == false)
{
return;
}
CoreStartTest();
CoreStart();
}
}
public void Stop()
{
CoreStop();
}
private bool Init()
{
coreInfo = LazyConfig.Instance.GetCoreInfo(ECoreType.sing_box);
//Template
string configStr = Utils.GetEmbedText(Global.TunSingboxFileName);
if (!Utils.IsNullOrEmpty(_config.tunModeItem.customTemplate) && File.Exists(_config.tunModeItem.customTemplate))
{
var customTemplate = File.ReadAllText(_config.tunModeItem.customTemplate);
if (!Utils.IsNullOrEmpty(customTemplate))
{
configStr = customTemplate;
}
}
if (Utils.IsNullOrEmpty(configStr))
{
return false;
}
//settings
if (_config.tunModeItem.mtu <= 0)
{
_config.tunModeItem.mtu = Convert.ToInt32(Global.TunMtus[0]);
}
if (Utils.IsNullOrEmpty(_config.tunModeItem.stack))
{
_config.tunModeItem.stack = Global.TunStacks[0];
}
configStr = configStr.Replace("$mtu$", $"{_config.tunModeItem.mtu}");
configStr = configStr.Replace("$strict_route$", $"{_config.tunModeItem.strictRoute.ToString().ToLower()}");
configStr = configStr.Replace("$stack$", $"{_config.tunModeItem.stack}");
//logs
configStr = configStr.Replace("$log_disabled$", $"{(!_config.tunModeItem.enabledLog).ToString().ToLower()}");
if (_config.tunModeItem.showWindow)
{
configStr = configStr.Replace("$log_output$", $"");
}
else
{
var dtNow = DateTime.Now;
var log_output = $"\"output\": \"{Utils.GetLogPath($"singbox_{dtNow:yyyy-MM-dd}.txt")}\", ";
configStr = configStr.Replace("$log_output$", $"{log_output.Replace(@"\", @"\\")}");
}
//port
configStr = configStr.Replace("$socksPort$", $"{_socksPort}");
//dns
string dnsObject = String.Empty;
if (_config.tunModeItem.bypassMode)
{
dnsObject = _config.tunModeItem.directDNS;
}
else
{
dnsObject = _config.tunModeItem.proxyDNS;
}
if (dnsObject.IsNullOrEmpty() || Utils.ParseJson(dnsObject)?.ContainsKey("servers") == false)
{
dnsObject = Utils.GetEmbedText(Global.TunSingboxDNSFileName);
}
configStr = configStr.Replace("$dns_object$", dnsObject);
//exe
List<string> lstDnsExe = new();
List<string> lstDirectExe = new();
var coreInfos = LazyConfig.Instance.GetCoreInfos();
foreach (var it in coreInfos)
{
if (it.coreType == ECoreType.v2rayN)
{
continue;
}
foreach (var it2 in it.coreExes)
{
if (!lstDnsExe.Contains(it2) && it.coreType != ECoreType.sing_box)
{
//lstDnsExe.Add(it2);
lstDnsExe.Add($"{it2}.exe");
}
if (!lstDirectExe.Contains(it2))
{
//lstDirectExe.Add(it2);
lstDirectExe.Add($"{it2}.exe");
}
}
}
string strDns = string.Join("\",\"", lstDnsExe.ToArray());
configStr = configStr.Replace("$dnsProcessName$", $"\"{strDns}\"");
string strDirect = string.Join("\",\"", lstDirectExe.ToArray());
configStr = configStr.Replace("$directProcessName$", $"\"{strDirect}\"");
if (_config.tunModeItem.bypassMode)
{
//direct ips
if (_config.tunModeItem.directIP != null && _config.tunModeItem.directIP.Count > 0)
{
var ips = new { outbound = "direct", ip_cidr = _config.tunModeItem.directIP };
configStr = configStr.Replace("$ruleDirectIPs$", "," + Utils.ToJson(ips));
}
//direct process
if (_config.tunModeItem.directProcess != null && _config.tunModeItem.directProcess.Count > 0)
{
var process = new { outbound = "direct", process_name = _config.tunModeItem.directProcess };
configStr = configStr.Replace("$ruleDirectProcess$", "," + Utils.ToJson(process));
}
}
else
{
//proxy ips
if (_config.tunModeItem.proxyIP != null && _config.tunModeItem.proxyIP.Count > 0)
{
var ips = new { outbound = "proxy", ip_cidr = _config.tunModeItem.proxyIP };
configStr = configStr.Replace("$ruleProxyIPs$", "," + Utils.ToJson(ips));
}
//proxy process
if (_config.tunModeItem.proxyProcess != null && _config.tunModeItem.proxyProcess.Count > 0)
{
var process = new { outbound = "proxy", process_name = _config.tunModeItem.proxyProcess };
configStr = configStr.Replace("$ruleProxyProcess$", "," + Utils.ToJson(process));
}
var final = new { outbound = "direct", inbound = "tun-in" };
configStr = configStr.Replace("$ruleFinally$", "," + Utils.ToJson(final));
}
configStr = configStr.Replace("$ruleDirectIPs$", "");
configStr = configStr.Replace("$ruleDirectProcess$", "");
configStr = configStr.Replace("$ruleProxyIPs$", "");
configStr = configStr.Replace("$ruleProxyProcess$", "");
configStr = configStr.Replace("$ruleFinally$", "");
File.WriteAllText(Utils.GetConfigPath(_tunConfigName), configStr);
return true;
}
private void CoreStop()
{
try
{
_isRunning = false;
if (_process != null)
{
KillProcess(_process);
_process.Dispose();
_process = null;
_needRestart = true;
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private string CoreFindexe()
{
string fileName = string.Empty;
foreach (string name in coreInfo.coreExes)
{
string vName = $"{name}.exe";
vName = Utils.GetBinPath(vName, coreInfo.coreType);
if (File.Exists(vName))
{
fileName = vName;
break;
}
}
if (Utils.IsNullOrEmpty(fileName))
{
string msg = string.Format(ResUI.NotFoundCore, Utils.GetBinPath("", coreInfo.coreType), string.Join(", ", coreInfo.coreExes.ToArray()), coreInfo.coreUrl);
Utils.SaveLog(msg);
}
return fileName;
}
private void CoreStart()
{
try
{
string fileName = CoreFindexe();
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
var showWindow = _config.tunModeItem.showWindow;
Process p = new()
{
StartInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = $"run -c \"{Utils.GetConfigPath(_tunConfigName)}\"",
WorkingDirectory = Utils.GetConfigPath(),
UseShellExecute = showWindow,
CreateNoWindow = !showWindow,
//RedirectStandardError = !showWindow,
Verb = "runas",
}
};
p.Start();
_process = p;
_isRunning = true;
if (p.WaitForExit(1000))
{
//if (showWindow)
//{
throw new Exception("start tun mode fail");
//}
//else
//{
// throw new Exception(p.StandardError.ReadToEnd());
//}
}
Global.processJob.AddProcess(p.Handle);
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private void KillProcess(Process p)
{
try
{
p.CloseMainWindow();
p.WaitForExit(100);
if (!p.HasExited)
{
p.Kill();
p.WaitForExit(100);
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private int CoreStartTest()
{
Utils.SaveLog("Tun mode configuration file test start");
try
{
string fileName = CoreFindexe();
if (fileName == "")
{
return -1;
}
Process p = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = $"run -c \"{Utils.GetConfigPath(_tunConfigName)}\"",
WorkingDirectory = Utils.GetConfigPath(),
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
Verb = "runas",
}
};
p.Start();
if (p.WaitForExit(2000))
{
throw new Exception(p.StandardError.ReadToEnd());
}
KillProcess(p);
return 0;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return -1;
}
finally
{
Utils.SaveLog("Tun mode configuration file test end");
}
}
}
}

View File

@@ -9,6 +9,7 @@ using System.Windows;
using v2rayN.Base;
using v2rayN.Mode;
using v2rayN.Resx;
using v2rayN.Tool;
namespace v2rayN.Handler
{
@@ -23,11 +24,13 @@ namespace v2rayN.Handler
{
public bool Success;
public string Msg;
public string Url;
public ResultEventArgs(bool success, string msg)
public ResultEventArgs(bool success, string msg, string url = "")
{
Success = success;
Msg = msg;
Url = url;
}
}
@@ -82,9 +85,10 @@ namespace v2rayN.Handler
if (args.Success)
{
_updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "v2rayN"));
_updateFunc(false, args.Msg);
url = args.Msg;
askToDownload(downloadHandle, url, true);
url = args.Url;
_ = askToDownload(downloadHandle, url, true);
}
else
{
@@ -134,8 +138,10 @@ namespace v2rayN.Handler
if (args.Success)
{
_updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "Core"));
url = args.Msg;
askToDownload(downloadHandle, url, true);
_updateFunc(false, args.Msg);
url = args.Url;
_ = askToDownload(downloadHandle, url, true);
}
else
{
@@ -153,7 +159,7 @@ namespace v2rayN.Handler
_updateFunc = update;
_updateFunc(false, ResUI.MsgUpdateSubscriptionStart);
var subItem = LazyConfig.Instance.SubItems();
var subItem = LazyConfig.Instance.SubItems().OrderBy(t => t.sort).ToList();
if (subItem == null || subItem.Count <= 0)
{
@@ -174,6 +180,10 @@ namespace v2rayN.Handler
//_updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
continue;
}
if (!url.StartsWith(Global.HttpsProtocol) && !url.StartsWith(Global.HttpProtocol))
{
continue;
}
if (item.enabled == false)
{
_updateFunc(false, $"{hashCode}{ResUI.MsgSkipSubscriptionUpdate}");
@@ -261,7 +271,7 @@ namespace v2rayN.Handler
_updateFunc(false, $"{hashCode}{result}");
}
int ret = ConfigHandler.AddBatchServers(ref config, result, id, true);
int ret = ConfigHandler.AddBatchServers(config, result, id, true);
if (ret <= 0)
{
Utils.SaveLog("FailedImportSubscription");
@@ -279,11 +289,271 @@ namespace v2rayN.Handler
});
}
public void UpdateGeoFile(string geoName, Config config, Action<bool, string> update)
public void UpdateGeoFileAll(Config config, Action<bool, string> update)
{
Task.Run(async () =>
{
await UpdateGeoFile("geosite", _config, update);
await UpdateGeoFile("geoip", _config, update);
//await UpdateGeoFile4Singbox("geosite", _config, false, update);
//await UpdateGeoFile4Singbox("geoip", _config, true, update);
});
}
public void RunAvailabilityCheck(Action<bool, string> update)
{
Task.Run(async () =>
{
var time = await (new DownloadHandle()).RunAvailabilityCheck(null);
update(false, string.Format(ResUI.TestMeOutput, time));
});
}
#region private
private async void CheckUpdateAsync(ECoreType type, bool preRelease)
{
try
{
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string url = coreInfo.coreReleaseApiUrl;
var result = await (new DownloadHandle()).DownloadStringAsync(url, true, "");
if (!Utils.IsNullOrEmpty(result))
{
responseHandler(type, result, preRelease);
}
else
{
Utils.SaveLog("StatusCode error: " + url);
return;
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
_updateFunc(false, ex.Message);
}
}
/// <summary>
/// 获取V2RayCore版本
/// </summary>
private SemanticVersion getCoreVersion(ECoreType type)
{
try
{
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string filePath = string.Empty;
foreach (string name in coreInfo.coreExes)
{
string vName = $"{name}.exe";
vName = Utils.GetBinPath(vName, coreInfo.coreType);
if (File.Exists(vName))
{
filePath = vName;
break;
}
}
if (!File.Exists(filePath))
{
string msg = string.Format(ResUI.NotFoundCore, @"", "", "");
//ShowMsg(true, msg);
return new SemanticVersion("");
}
using Process p = new();
p.StartInfo.FileName = filePath;
p.StartInfo.Arguments = coreInfo.versionArg;
p.StartInfo.WorkingDirectory = Utils.StartupPath();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
p.Start();
p.WaitForExit(5000);
string echo = p.StandardOutput.ReadToEnd();
string version = string.Empty;
switch (type)
{
case ECoreType.v2fly:
case ECoreType.SagerNet:
case ECoreType.Xray:
case ECoreType.v2fly_v5:
version = Regex.Match(echo, $"{coreInfo.match} ([0-9.]+) \\(").Groups[1].Value;
break;
case ECoreType.clash:
case ECoreType.clash_meta:
version = Regex.Match(echo, $"v[0-9.]+").Groups[0].Value;
break;
case ECoreType.sing_box:
version = Regex.Match(echo, $"([0-9.]+)").Groups[1].Value;
break;
}
return new SemanticVersion(version);
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
_updateFunc(false, ex.Message);
return new SemanticVersion("");
}
}
private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease)
{
try
{
var gitHubReleases = Utils.FromJson<List<GitHubRelease>>(gitHubReleaseApi);
var gitHubRelease = preRelease ? gitHubReleases!.First() : gitHubReleases!.First(r => r.Prerelease == false);
var version = new SemanticVersion(gitHubRelease!.TagName);
var body = gitHubRelease!.Body;
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
SemanticVersion curVersion;
string message;
string url;
switch (type)
{
case ECoreType.v2fly:
case ECoreType.SagerNet:
case ECoreType.Xray:
case ECoreType.v2fly_v5:
{
curVersion = getCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v"));
string osBit = "64";
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
osBit = "arm64-v8a";
break;
case Architecture.X86:
osBit = "32";
break;
default:
osBit = "64";
break;
}
url = string.Format(coreInfo.coreDownloadUrl64, version.ToVersionString("v"), osBit);
break;
}
case ECoreType.clash:
case ECoreType.clash_meta:
{
curVersion = getCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion);
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
url = coreInfo.coreDownloadUrlArm64;
break;
case Architecture.X86:
url = coreInfo.coreDownloadUrl32;
break;
default:
url = coreInfo.coreDownloadUrl64;
break;
}
url = string.Format(url, version.ToVersionString("v"));
break;
}
case ECoreType.sing_box:
{
curVersion = getCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v"));
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
url = coreInfo.coreDownloadUrlArm64;
break;
case Architecture.X86:
url = coreInfo.coreDownloadUrl32;
break;
default:
url = coreInfo.coreDownloadUrl64;
break;
}
url = string.Format(url, version.ToVersionString("v"), version);
break;
}
case ECoreType.v2rayN:
{
curVersion = new SemanticVersion(FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString());
message = string.Format(ResUI.IsLatestN, type, curVersion);
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
url = string.Format(coreInfo.coreDownloadUrlArm64, version);
break;
case Architecture.X86:
url = string.Format(coreInfo.coreDownloadUrl32, version);
break;
default:
url = string.Format(coreInfo.coreDownloadUrl64, version);
break;
}
break;
}
default:
throw new ArgumentException("Type");
}
if (curVersion >= version && version != new SemanticVersion(0, 0, 0))
{
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message));
return;
}
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, body, url));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
_updateFunc(false, ex.Message);
}
}
private async Task askToDownload(DownloadHandle downloadHandle, string url, bool blAsk)
{
bool blDownload = false;
if (blAsk)
{
if (UI.ShowYesNo(string.Format(ResUI.DownloadYesNo, url)) == MessageBoxResult.Yes)
{
blDownload = true;
}
}
else
{
blDownload = true;
}
if (blDownload)
{
await downloadHandle.DownloadFileAsync(url, true, 600);
}
}
private async Task UpdateGeoFile(string geoName, Config config, Action<bool, string> update)
{
_config = config;
_updateFunc = update;
var url = string.Format(Global.geoUrl, geoName);
var url = string.Format(Global.GeoUrl, geoName);
DownloadHandle downloadHandle = new();
downloadHandle.UpdateCompleted += (sender2, args) =>
@@ -323,271 +593,55 @@ namespace v2rayN.Handler
{
_updateFunc(false, args.GetException().Message);
};
askToDownload(downloadHandle, url, false);
await askToDownload(downloadHandle, url, false);
}
public void RunAvailabilityCheck(Action<bool, string> update)
private async Task UpdateGeoFile4Singbox(string geoName, Config config, bool needStop, Action<bool, string> update)
{
Task.Run(() =>
_config = config;
_updateFunc = update;
var url = string.Format(Global.SingboxGeoUrl, geoName);
DownloadHandle downloadHandle = new();
downloadHandle.UpdateCompleted += async (sender2, args) =>
{
var time = (new DownloadHandle()).RunAvailabilityCheck(null);
update(false, string.Format(ResUI.TestMeOutput, time));
});
}
#region private
private async void CheckUpdateAsync(ECoreType type, bool preRelease)
{
try
{
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string url = coreInfo.coreReleaseApiUrl;
var result = await (new DownloadHandle()).DownloadStringAsync(url, true, "");
if (!Utils.IsNullOrEmpty(result))
if (args.Success)
{
responseHandler(type, result, preRelease);
_updateFunc(false, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, geoName));
var coreHandler = Locator.Current.GetService<CoreHandler>();
try
{
if (needStop)
{
coreHandler?.CoreStop();
await Task.Delay(3000);
}
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
if (File.Exists(fileName))
{
string targetPath = Utils.GetConfigPath($"{geoName}.db");
File.Copy(fileName, targetPath, true);
File.Delete(fileName);
}
if (needStop) coreHandler?.LoadCore();
}
catch (Exception ex)
{
_updateFunc(false, ex.Message);
}
}
else
{
Utils.SaveLog("StatusCode error: " + url);
return;
_updateFunc(false, args.Msg);
}
}
catch (Exception ex)
};
downloadHandle.Error += (sender2, args) =>
{
Utils.SaveLog(ex.Message, ex);
_updateFunc(false, ex.Message);
}
}
/// <summary>
/// 获取V2RayCore版本
/// </summary>
private string getCoreVersion(ECoreType type)
{
try
{
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string filePath = string.Empty;
foreach (string name in coreInfo.coreExes)
{
string vName = $"{name}.exe";
vName = Utils.GetBinPath(vName, coreInfo.coreType);
if (File.Exists(vName))
{
filePath = vName;
break;
}
}
if (!File.Exists(filePath))
{
string msg = string.Format(ResUI.NotFoundCore, @"", "", "");
//ShowMsg(true, msg);
return "";
}
using Process p = new();
p.StartInfo.FileName = filePath;
p.StartInfo.Arguments = coreInfo.versionArg;
p.StartInfo.WorkingDirectory = Utils.StartupPath();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
p.Start();
p.WaitForExit(5000);
string echo = p.StandardOutput.ReadToEnd();
string version = string.Empty;
switch (type)
{
case ECoreType.v2fly:
case ECoreType.SagerNet:
case ECoreType.Xray:
case ECoreType.v2fly_v5:
version = Regex.Match(echo, $"{coreInfo.match} ([0-9.]+) \\(").Groups[1].Value;
break;
case ECoreType.clash:
case ECoreType.clash_meta:
version = Regex.Match(echo, $"v[0-9.]+").Groups[0].Value;
break;
case ECoreType.sing_box:
version = Regex.Match(echo, $"([0-9.]+)").Groups[1].Value;
break;
}
return version;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
_updateFunc(false, ex.Message);
return "";
}
}
private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease)
{
try
{
var gitHubReleases = Utils.FromJson<List<GitHubRelease>>(gitHubReleaseApi);
string version;
if (preRelease)
{
version = gitHubReleases!.First().TagName;
}
else
{
version = gitHubReleases!.First(r => r.Prerelease == false).TagName;
}
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string curVersion;
string message;
string url;
switch (type)
{
case ECoreType.v2fly:
case ECoreType.SagerNet:
case ECoreType.Xray:
case ECoreType.v2fly_v5:
{
curVersion = "v" + getCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, curVersion);
string osBit = "64";
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
osBit = "arm64-v8a";
break;
case Architecture.X86:
osBit = "32";
break;
default:
osBit = "64";
break;
}
url = string.Format(coreInfo.coreDownloadUrl64, version, osBit);
break;
}
case ECoreType.clash:
case ECoreType.clash_meta:
{
curVersion = getCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, curVersion);
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
url = coreInfo.coreDownloadUrlArm64;
break;
case Architecture.X86:
url = coreInfo.coreDownloadUrl32;
break;
default:
url = coreInfo.coreDownloadUrl64;
break;
}
url = string.Format(url, version);
break;
}
case ECoreType.sing_box:
{
curVersion = "v" + getCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, curVersion);
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
url = coreInfo.coreDownloadUrlArm64;
break;
case Architecture.X86:
url = coreInfo.coreDownloadUrl32;
break;
default:
url = coreInfo.coreDownloadUrl64;
break;
}
url = string.Format(url, version, version.Replace("v", ""));
break;
}
case ECoreType.v2rayN:
{
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
message = string.Format(ResUI.IsLatestN, curVersion);
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm64:
url = string.Format(coreInfo.coreDownloadUrlArm64, version);
break;
case Architecture.X86:
url = string.Format(coreInfo.coreDownloadUrl32, version);
break;
default:
url = string.Format(coreInfo.coreDownloadUrl64, version);
break;
}
break;
}
default:
throw new ArgumentException("Type");
}
if (type == ECoreType.v2rayN)
{
decimal.TryParse(curVersion, out decimal decCur);
decimal.TryParse(version, out decimal dec);
if (decCur >= dec)
{
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message));
return;
}
}
if (curVersion == version)
{
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message));
return;
}
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
_updateFunc(false, ex.Message);
}
}
private void askToDownload(DownloadHandle downloadHandle, string url, bool blAsk)
{
bool blDownload = false;
if (blAsk)
{
if (UI.ShowYesNo(string.Format(ResUI.DownloadYesNo, url)) == MessageBoxResult.Yes)
{
blDownload = true;
}
}
else
{
blDownload = true;
}
if (blDownload)
{
downloadHandle.DownloadFileAsync(url, true, 600);
}
_updateFunc(false, args.GetException().Message);
};
await askToDownload(downloadHandle, url, false);
}
#endregion private

View File

@@ -10,14 +10,6 @@
public string indexId { get; set; }
public string subIndexId { get; set; }
public string remoteDNS { get; set; }
/// <summary>
/// Outbound Freedom domainStrategy
/// </summary>
public string domainStrategy4Freedom { get; set; }
public ESysProxyType sysProxyType { get; set; }
public string systemProxyExceptions { get; set; }
public string systemProxyAdvancedProtocol { get; set; }
@@ -35,6 +27,8 @@
public UIItem uiItem { get; set; }
public ConstItem constItem { get; set; }
public SpeedTestItem speedTestItem { get; set; }
public Mux4SboxItem mux4SboxItem { get; set; }
public HysteriaItem hysteriaItem { get; set; }
public List<InItem> inbound { get; set; }
public List<KeyEventItem> globalHotkeys { get; set; }
public List<CoreTypeItem> coreTypeItem { get; set; }

View File

@@ -88,8 +88,6 @@ namespace v2rayN.Mode
public bool enableStatistics { get; set; }
public int statisticsFreshRate { get; set; }
public bool keepOlderDedupl { get; set; }
public bool ignoreGeoUpdateCore { get; set; } = true;
@@ -116,6 +114,7 @@ namespace v2rayN.Mode
public double mainGirdHeight1 { get; set; }
public double mainGirdHeight2 { get; set; }
public bool colorModeDark { get; set; }
public bool followSystemTheme { get; set; }
public string? colorPrimaryName { get; set; }
public string currentLanguage { get; set; }
public string currentFontFamily { get; set; }
@@ -161,19 +160,11 @@ namespace v2rayN.Mode
public class TunModeItem
{
public bool enableTun { get; set; }
public bool showWindow { get; set; }
public bool enabledLog { get; set; }
public bool strictRoute { get; set; }
public bool strictRoute { get; set; } = true;
public string stack { get; set; }
public int mtu { get; set; }
public string customTemplate { get; set; }
public bool bypassMode { get; set; } = true;
public List<string> directIP { get; set; }
public List<string> directProcess { get; set; }
public string directDNS { get; set; }
public List<string> proxyIP { get; set; }
public List<string> proxyProcess { get; set; }
public string proxyDNS { get; set; }
public bool enableExInbound { get; set; }
public bool enableIPv6Address { get; set; } = true;
}
[Serializable]
@@ -192,6 +183,8 @@ namespace v2rayN.Mode
/// </summary>
public string domainStrategy { get; set; }
public string domainStrategy4Singbox { get; set; }
public string domainMatcher { get; set; }
public string routingIndexId { get; set; }
public bool enableRoutingAdvanced { get; set; }
@@ -204,4 +197,21 @@ namespace v2rayN.Mode
public int Width { get; set; }
public int Index { get; set; }
}
[Serializable]
public class Mux4SboxItem
{
public string protocol { get; set; }
public int max_connections { get; set; }
public int min_streams { get; set; }
public int max_streams { get; set; }
public bool padding { get; set; }
}
[Serializable]
public class HysteriaItem
{
public int up_mbps { get; set; }
public int down_mbps { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using SQLite;
namespace v2rayN.Mode
{
[Serializable]
public class DNSItem
{
[PrimaryKey]
public string id { get; set; }
public string remarks { get; set; }
public bool enabled { get; set; } = true;
public ECoreType coreType { get; set; }
public bool useSystemHosts { get; set; }
public string? normalDNS { get; set; }
public string? tunDNS { get; set; }
public string? domainStrategy4Freedom { get; set; }
}
}

View File

@@ -7,6 +7,8 @@
Shadowsocks = 3,
Socks = 4,
VLESS = 5,
Trojan = 6
Trojan = 6,
Hysteria2 = 7,
Tuic = 8
}
}

View File

@@ -8,10 +8,13 @@
v2fly_v5 = 4,
clash = 11,
clash_meta = 12,
mihomo = 13,
hysteria = 21,
naiveproxy = 22,
tuic = 23,
sing_box = 24,
juicity = 25,
hysteria2 = 26,
v2rayN = 99
}
}

View File

@@ -53,6 +53,8 @@ namespace v2rayN.Mode
case EConfigType.Socks:
case EConfigType.VLESS:
case EConfigType.Trojan:
case EConfigType.Hysteria2:
case EConfigType.Tuic:
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break;
@@ -77,7 +79,7 @@ namespace v2rayN.Mode
public string GetNetwork()
{
if (Utils.IsNullOrEmpty(network) || !Global.networks.Contains(network))
if (Utils.IsNullOrEmpty(network) || !Global.Networks.Contains(network))
{
return Global.DefaultNetwork;
}

View File

@@ -16,6 +16,7 @@ namespace v2rayN.Mode
public bool locked { get; set; }
public string customIcon { get; set; }
public string domainStrategy { get; set; }
public string domainStrategy4Singbox { get; set; }
public int sort { get; set; }
}
}

View File

@@ -18,6 +18,8 @@
public List<string> protocol { get; set; }
public List<string> process { get; set; }
public bool enabled { get; set; } = true;
}
}

View File

@@ -23,4 +23,18 @@
get; set;
}
}
[Serializable]
public class TrafficItem
{
public ulong up
{
get; set;
}
public ulong down
{
get; set;
}
}
}

View File

@@ -0,0 +1,213 @@
namespace v2rayN.Mode
{
public class SingboxConfig
{
public Log4Sbox log { get; set; }
public object dns { get; set; }
public List<Inbound4Sbox> inbounds { get; set; }
public List<Outbound4Sbox> outbounds { get; set; }
public Route4Sbox route { get; set; }
public Experimental4Sbox experimental { get; set; }
}
public class Log4Sbox
{
public bool? disabled { get; set; }
public string level { get; set; }
public string output { get; set; }
public bool timestamp { get; set; }
}
public class Dns4Sbox
{
public List<Server4Sbox> servers { get; set; }
public List<Rule4Sbox> rules { get; set; }
public string? final { get; set; }
public string? strategy { get; set; }
public bool? disable_cache { get; set; }
public bool? disable_expire { get; set; }
public bool? independent_cache { get; set; }
public bool? reverse_mapping { get; set; }
public Fakeip4Sbox? fakeip { get; set; }
}
public class Route4Sbox
{
public bool? auto_detect_interface { get; set; }
public List<Rule4Sbox> rules { get; set; }
}
[Serializable]
public class Rule4Sbox
{
public string outbound { get; set; }
public string server { get; set; }
public bool? disable_cache { get; set; }
public List<string>? inbound { get; set; }
public List<string>? protocol { get; set; }
public string type { get; set; }
public string mode { get; set; }
public string network { get; set; }
public List<int>? port { get; set; }
public List<string>? port_range { get; set; }
public List<string>? geosite { get; set; }
public List<string>? domain { get; set; }
public List<string>? domain_suffix { get; set; }
public List<string>? domain_keyword { get; set; }
public List<string>? domain_regex { get; set; }
public List<string>? geoip { get; set; }
public List<string>? ip_cidr { get; set; }
public List<string>? source_ip_cidr { get; set; }
public List<string>? process_name { get; set; }
}
[Serializable]
public class Inbound4Sbox
{
public string type { get; set; }
public string tag { get; set; }
public string listen { get; set; }
public int? listen_port { get; set; }
public string? domain_strategy { get; set; }
public string interface_name { get; set; }
public string inet4_address { get; set; }
public string? inet6_address { get; set; }
public int? mtu { get; set; }
public bool? auto_route { get; set; }
public bool? strict_route { get; set; }
public bool? endpoint_independent_nat { get; set; }
public string? stack { get; set; }
public bool? sniff { get; set; }
public bool? sniff_override_destination { get; set; }
public List<User4Sbox> users { get; set; }
}
public class User4Sbox
{
public string username { get; set; }
public string password { get; set; }
}
public class Outbound4Sbox
{
public string type { get; set; }
public string tag { get; set; }
public string server { get; set; }
public int? server_port { get; set; }
public string uuid { get; set; }
public string security { get; set; }
public int? alter_id { get; set; }
public string flow { get; set; }
public int? up_mbps { get; set; }
public int? down_mbps { get; set; }
public string auth_str { get; set; }
public int? recv_window_conn { get; set; }
public int? recv_window { get; set; }
public bool? disable_mtu_discovery { get; set; }
public string? detour { get; set; }
public string method { get; set; }
public string username { get; set; }
public string password { get; set; }
public string congestion_control { get; set; }
public string? version { get; set; }
public string? network { get; set; }
public string packet_encoding { get; set; }
public Tls4Sbox tls { get; set; }
public Multiplex4Sbox multiplex { get; set; }
public Transport4Sbox transport { get; set; }
}
public class Tls4Sbox
{
public bool enabled { get; set; }
public string server_name { get; set; }
public bool? insecure { get; set; }
public List<string> alpn { get; set; }
public Utls4Sbox utls { get; set; }
public Reality4Sbox reality { get; set; }
}
public class Multiplex4Sbox
{
public bool enabled { get; set; }
public string protocol { get; set; }
public int max_connections { get; set; }
public int min_streams { get; set; }
public int max_streams { get; set; }
public bool padding { get; set; }
}
public class Utls4Sbox
{
public bool enabled { get; set; }
public string fingerprint { get; set; }
}
public class Reality4Sbox
{
public bool enabled { get; set; }
public string public_key { get; set; }
public string short_id { get; set; }
}
public class Transport4Sbox
{
public string type { get; set; }
public List<string>? host { get; set; }
public string? path { get; set; }
public Headers4Sbox? headers { get; set; }
public string service_name { get; set; }
public string idle_timeout { get; set; }
public string ping_timeout { get; set; }
public bool? permit_without_stream { get; set; }
}
public class Headers4Sbox
{
public string? Host { get; set; }
}
public class Server4Sbox
{
public string tag { get; set; }
public string address { get; set; }
public string address_resolver { get; set; }
public string strategy { get; set; }
public string detour { get; set; }
}
public class Experimental4Sbox
{
public V2ray_Api4Sbox v2ray_api { get; set; }
public Clash_Api4Sbox clash_api { get; set; }
}
public class V2ray_Api4Sbox
{
public string listen { get; set; }
public Stats4Sbox stats { get; set; }
}
public class Clash_Api4Sbox
{
public string external_controller { get; set; }
public bool store_selected { get; set; }
}
public class Stats4Sbox
{
public bool enabled { get; set; }
public List<string>? inbounds { get; set; }
public List<string>? outbounds { get; set; }
public List<string>? users { get; set; }
}
public class Fakeip4Sbox
{
public bool enabled { get; set; }
public string inet4_range { get; set; }
public string inet6_range { get; set; }
}
}

View File

@@ -27,5 +27,9 @@ namespace v2rayN.Mode
public long updateTime { get; set; }
public string? convertTarget { get; set; }
public string? prevProfile { get; set; }
public string? nextProfile { get; set; }
}
}

View File

@@ -11,28 +11,28 @@ namespace v2rayN.Mode
/// <summary>
/// 日志配置
/// </summary>
public Log log { get; set; }
public Log4Ray log { get; set; }
/// <summary>
/// 传入连接配置
/// </summary>
public List<Inbounds> inbounds { get; set; }
public List<Inbounds4Ray> inbounds { get; set; }
/// <summary>
/// 传出连接配置
/// </summary>
public List<Outbounds> outbounds { get; set; }
public List<Outbounds4Ray> outbounds { get; set; }
/// <summary>
/// 统计需要, 空对象
/// </summary>
public Stats stats { get; set; }
public Stats4Ray stats { get; set; }
/// </summary>
public API api { get; set; }
public API4Ray api { get; set; }
/// </summary>
public Policy policy;
public Policy4Ray policy;
/// <summary>
/// DNS 配置
@@ -42,30 +42,30 @@ namespace v2rayN.Mode
/// <summary>
/// 路由配置
/// </summary>
public Routing routing { get; set; }
public Routing4Ray routing { get; set; }
}
public class Stats
public class Stats4Ray
{ };
public class API
public class API4Ray
{
public string tag { get; set; }
public List<string> services { get; set; }
}
public class Policy
public class Policy4Ray
{
public SystemPolicy system;
public SystemPolicy4Ray system;
}
public class SystemPolicy
public class SystemPolicy4Ray
{
public bool statsOutboundUplink;
public bool statsOutboundDownlink;
}
public class Log
public class Log4Ray
{
/// <summary>
///
@@ -83,7 +83,7 @@ namespace v2rayN.Mode
public string loglevel { get; set; }
}
public class Inbounds
public class Inbounds4Ray
{
public string tag { get; set; }
@@ -105,20 +105,20 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public Sniffing sniffing { get; set; }
public Sniffing4Ray sniffing { get; set; }
/// <summary>
///
/// </summary>
public Inboundsettings settings { get; set; }
public Inboundsettings4Ray settings { get; set; }
/// <summary>
///
/// </summary>
public StreamSettings streamSettings { get; set; }
public StreamSettings4Ray streamSettings { get; set; }
}
public class Inboundsettings
public class Inboundsettings4Ray
{
/// <summary>
///
@@ -143,7 +143,7 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public List<UsersItem> clients { get; set; }
public List<UsersItem4Ray> clients { get; set; }
/// <summary>
/// VLESS
@@ -152,10 +152,10 @@ namespace v2rayN.Mode
public bool allowTransparent { get; set; }
public List<AccountsItem> accounts { get; set; }
public List<AccountsItem4Ray> accounts { get; set; }
}
public class UsersItem
public class UsersItem4Ray
{
/// <summary>
///
@@ -185,17 +185,17 @@ namespace v2rayN.Mode
/// <summary>
/// VLESS
/// </summary>
public string flow { get; set; }
public string? flow { get; set; }
}
public class Sniffing
public class Sniffing4Ray
{
public bool enabled { get; set; }
public List<string> destOverride { get; set; }
public bool routeOnly { get; set; }
}
public class Outbounds
public class Outbounds4Ray
{
/// <summary>
/// 默认值agentout
@@ -210,35 +210,35 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public Outboundsettings settings { get; set; }
public Outboundsettings4Ray settings { get; set; }
/// <summary>
///
/// </summary>
public StreamSettings streamSettings { get; set; }
public StreamSettings4Ray streamSettings { get; set; }
/// <summary>
///
/// </summary>
public Mux mux { get; set; }
public Mux4Ray mux { get; set; }
}
public class Outboundsettings
public class Outboundsettings4Ray
{
/// <summary>
///
/// </summary>
public List<VnextItem> vnext { get; set; }
public List<VnextItem4Ray> vnext { get; set; }
/// <summary>
///
/// </summary>
public List<ServersItem> servers { get; set; }
public List<ServersItem4Ray> servers { get; set; }
/// <summary>
///
/// </summary>
public Response response { get; set; }
public Response4Ray response { get; set; }
/// <summary>
///
@@ -251,7 +251,7 @@ namespace v2rayN.Mode
public int? userLevel { get; set; }
}
public class VnextItem
public class VnextItem4Ray
{
/// <summary>
///
@@ -266,10 +266,10 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public List<UsersItem> users { get; set; }
public List<UsersItem4Ray> users { get; set; }
}
public class ServersItem
public class ServersItem4Ray
{
/// <summary>
///
@@ -314,10 +314,10 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public List<SocksUsersItem> users { get; set; }
public List<SocksUsersItem4Ray> users { get; set; }
}
public class SocksUsersItem
public class SocksUsersItem4Ray
{
/// <summary>
///
@@ -335,7 +335,7 @@ namespace v2rayN.Mode
public int level { get; set; }
}
public class Mux
public class Mux4Ray
{
/// <summary>
///
@@ -348,7 +348,7 @@ namespace v2rayN.Mode
public int concurrency { get; set; }
}
public class Response
public class Response4Ray
{
/// <summary>
///
@@ -356,7 +356,7 @@ namespace v2rayN.Mode
public string type { get; set; }
}
public class Dns
public class Dns4Ray
{
/// <summary>
///
@@ -364,7 +364,7 @@ namespace v2rayN.Mode
public List<string> servers { get; set; }
}
public class Routing
public class Routing4Ray
{
/// <summary>
///
@@ -379,10 +379,28 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public List<RulesItem> rules { get; set; }
public List<RulesItem4Ray> rules { get; set; }
}
public class StreamSettings
[Serializable]
public class RulesItem4Ray
{
public string type { get; set; }
public string port { get; set; }
public List<string> inboundTag { get; set; }
public string outboundTag { get; set; }
public List<string> ip { get; set; }
public List<string> domain { get; set; }
public List<string> protocol { get; set; }
}
public class StreamSettings4Ray
{
/// <summary>
///
@@ -397,45 +415,50 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public TlsSettings tlsSettings { get; set; }
public TlsSettings4Ray tlsSettings { get; set; }
/// <summary>
/// Tcp传输额外设置
/// </summary>
public TcpSettings tcpSettings { get; set; }
public TcpSettings4Ray tcpSettings { get; set; }
/// <summary>
/// Kcp传输额外设置
/// </summary>
public KcpSettings kcpSettings { get; set; }
public KcpSettings4Ray kcpSettings { get; set; }
/// <summary>
/// ws传输额外设置
/// </summary>
public WsSettings wsSettings { get; set; }
public WsSettings4Ray wsSettings { get; set; }
/// <summary>
/// h2传输额外设置
/// </summary>
public HttpSettings httpSettings { get; set; }
public HttpSettings4Ray httpSettings { get; set; }
/// <summary>
/// QUIC
/// </summary>
public QuicSettings quicSettings { get; set; }
public QuicSettings4Ray quicSettings { get; set; }
/// <summary>
/// VLESS only
/// </summary>
public TlsSettings realitySettings { get; set; }
public TlsSettings4Ray realitySettings { get; set; }
/// <summary>
/// grpc
/// </summary>
public GrpcSettings grpcSettings { get; set; }
public GrpcSettings4Ray grpcSettings { get; set; }
/// <summary>
/// sockopt
/// </summary>
public Sockopt4Ray? sockopt { get; set; }
}
public class TlsSettings
public class TlsSettings4Ray
{
/// <summary>
/// 是否允许不安全连接(用于客户端)
@@ -460,15 +483,15 @@ namespace v2rayN.Mode
public string? spiderX { get; set; }
}
public class TcpSettings
public class TcpSettings4Ray
{
/// <summary>
/// 数据包头部伪装设置
/// </summary>
public Header header { get; set; }
public Header4Ray header { get; set; }
}
public class Header
public class Header4Ray
{
/// <summary>
/// 伪装
@@ -486,7 +509,7 @@ namespace v2rayN.Mode
public object response { get; set; }
}
public class KcpSettings
public class KcpSettings4Ray
{
/// <summary>
///
@@ -526,7 +549,7 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public Header header { get; set; }
public Header4Ray header { get; set; }
/// <summary>
///
@@ -534,7 +557,7 @@ namespace v2rayN.Mode
public string seed { get; set; }
}
public class WsSettings
public class WsSettings4Ray
{
/// <summary>
///
@@ -544,10 +567,10 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public Headers headers { get; set; }
public Headers4Ray headers { get; set; }
}
public class Headers
public class Headers4Ray
{
/// <summary>
///
@@ -561,7 +584,7 @@ namespace v2rayN.Mode
public string UserAgent { get; set; }
}
public class HttpSettings
public class HttpSettings4Ray
{
/// <summary>
///
@@ -574,7 +597,7 @@ namespace v2rayN.Mode
public List<string> host { get; set; }
}
public class QuicSettings
public class QuicSettings4Ray
{
/// <summary>
///
@@ -589,10 +612,10 @@ namespace v2rayN.Mode
/// <summary>
///
/// </summary>
public Header header { get; set; }
public Header4Ray header { get; set; }
}
public class GrpcSettings
public class GrpcSettings4Ray
{
public string serviceName { get; set; }
public bool multiMode { get; set; }
@@ -602,7 +625,7 @@ namespace v2rayN.Mode
public int initial_windows_size { get; set; }
}
public class AccountsItem
public class AccountsItem4Ray
{
/// <summary>
///
@@ -614,4 +637,9 @@ namespace v2rayN.Mode
/// </summary>
public string pass { get; set; }
}
public class Sockopt4Ray
{
public string? dialerProxy { get; set; }
}
}

View File

@@ -219,25 +219,5 @@ namespace v2rayN.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] sysproxy_exe {
get {
object obj = ResourceManager.GetObject("sysproxy_exe", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] sysproxy64_exe {
get {
object obj = ResourceManager.GetObject("sysproxy64_exe", resourceCulture);
return ((byte[])(obj));
}
}
}
}

View File

@@ -118,12 +118,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="sysproxy_exe" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\sysproxy.exe.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="sysproxy64_exe" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\sysproxy64.exe.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="NotifyIcon1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NotifyIcon1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

View File

@@ -169,7 +169,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Failed to get the default configuration 的本地化字符串。
/// 查找类似 Failed to get the default configuration 的本地化字符串。
/// </summary>
public static string FailedGetDefaultConfiguration {
get {
@@ -286,7 +286,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 is not the correct client configuration file, please check 的本地化字符串。
/// 查找类似 Is not the correct client configuration file, please check 的本地化字符串。
/// </summary>
public static string IncorrectClientConfiguration {
get {
@@ -295,7 +295,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 is not the correct configuration, please check 的本地化字符串。
/// 查找类似 Is not the correct configuration, please check 的本地化字符串。
/// </summary>
public static string Incorrectconfiguration {
get {
@@ -304,7 +304,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 is not the correct server configuration file, please check 的本地化字符串。
/// 查找类似 Is not the correct server configuration file, please check 的本地化字符串。
/// </summary>
public static string IncorrectServerConfiguration {
get {
@@ -322,7 +322,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 {0} already up to date. 的本地化字符串。
/// 查找类似 {0} {1} already up to date. 的本地化字符串。
/// </summary>
public static string IsLatestCore {
get {
@@ -331,7 +331,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 {0} already up to date. 的本地化字符串。
/// 查找类似 {0} {1} already up to date. 的本地化字符串。
/// </summary>
public static string IsLatestN {
get {
@@ -447,6 +447,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Next proxy remarks 的本地化字符串。
/// </summary>
public static string LvNextProfile {
get {
return ResourceManager.GetString("LvNextProfile", resourceCulture);
}
}
/// <summary>
/// 查找类似 Port 的本地化字符串。
/// </summary>
@@ -456,6 +465,24 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Previous proxy remakrs 的本地化字符串。
/// </summary>
public static string LvPrevProfile {
get {
return ResourceManager.GetString("LvPrevProfile", resourceCulture);
}
}
/// <summary>
/// 查找类似 Please make sure the remarks exists and is unique 的本地化字符串。
/// </summary>
public static string LvPrevProfileTip {
get {
return ResourceManager.GetString("LvPrevProfileTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Remarks 的本地化字符串。
/// </summary>
@@ -591,6 +618,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Add [Trojan] server 的本地化字符串。
/// </summary>
public static string menuAddHysteria2Server {
get {
return ResourceManager.GetString("menuAddHysteria2Server", resourceCulture);
}
}
/// <summary>
/// 查找类似 Import bulk URL from clipboard (Ctrl+V) 的本地化字符串。
/// </summary>
@@ -636,6 +672,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Add [Tuic] server 的本地化字符串。
/// </summary>
public static string menuAddTuicServer {
get {
return ResourceManager.GetString("menuAddTuicServer", resourceCulture);
}
}
/// <summary>
/// 查找类似 Add [VLESS] server 的本地化字符串。
/// </summary>
@@ -690,6 +735,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 DNS Settings 的本地化字符串。
/// </summary>
public static string menuDNSSetting {
get {
return ResourceManager.GetString("menuDNSSetting", resourceCulture);
}
}
/// <summary>
/// 查找类似 Edit Server (Ctrl+D) 的本地化字符串。
/// </summary>
@@ -717,15 +771,6 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Export selected server for server configuration 的本地化字符串。
/// </summary>
public static string menuExport2ServerConfig {
get {
return ResourceManager.GetString("menuExport2ServerConfig", resourceCulture);
}
}
/// <summary>
/// 查找类似 Export share URLs to clipboard (Ctrl+C) 的本地化字符串。
/// </summary>
@@ -1015,7 +1060,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Remove selected 的本地化字符串。
/// 查找类似 Remove selected (Delete) 的本地化字符串。
/// </summary>
public static string menuRoutingAdvancedRemove {
get {
@@ -1024,7 +1069,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Set as active rule 的本地化字符串。
/// 查找类似 Set as active rule(Enter) 的本地化字符串。
/// </summary>
public static string menuRoutingAdvancedSetDefault {
get {
@@ -1105,7 +1150,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Remove Rules 的本地化字符串。
/// 查找类似 Remove Rules (Delete) 的本地化字符串。
/// </summary>
public static string menuRuleRemove {
get {
@@ -1474,7 +1519,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 is unpacking... 的本地化字符串。
/// 查找类似 Is unpacking...... 的本地化字符串。
/// </summary>
public static string MsgUnpacking {
get {
@@ -1528,7 +1573,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 non-standard service, this feature is invalid 的本地化字符串。
/// 查找类似 Non-standard service, this feature is invalid 的本地化字符串。
/// </summary>
public static string NonVmessService {
get {
@@ -1564,7 +1609,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 operation failed, please check and retry 的本地化字符串。
/// 查找类似 Operation failed, please check and retry 的本地化字符串。
/// </summary>
public static string OperationFailed {
get {
@@ -1698,15 +1743,6 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 The server configuration file is saved at: {0} 的本地化字符串。
/// </summary>
public static string SaveServerConfigurationIn {
get {
return ResourceManager.GetString("SaveServerConfigurationIn", resourceCulture);
}
}
/// <summary>
/// 查找类似 {0}:{1}/s↑ | {2}/s↓ 的本地化字符串。
/// </summary>
@@ -1744,7 +1780,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Waiting for testing 的本地化字符串。
/// 查找类似 Waiting for testing...... 的本地化字符串。
/// </summary>
public static string SpeedtestingWait {
get {
@@ -1781,7 +1817,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Custom configuration server imported successfully. 的本地化字符串。
/// 查找类似 Custom configuration server imported successfully 的本地化字符串。
/// </summary>
public static string SuccessfullyImportedCustomServer {
get {
@@ -1790,7 +1826,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 {0} servers have been imported from clipboard. 的本地化字符串。
/// 查找类似 {0} servers have been imported from clipboard 的本地化字符串。
/// </summary>
public static string SuccessfullyImportedServerViaClipboard {
get {
@@ -1862,7 +1898,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Domain and ip are auto sorted when saving 的本地化字符串。
/// 查找类似 Domain, ip, process are auto sorted when saving 的本地化字符串。
/// </summary>
public static string TbAutoSort {
get {
@@ -1934,7 +1970,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Support DnsObject 的本地化字符串。
/// 查找类似 Support DnsObject, Click to view the document 的本地化字符串。
/// </summary>
public static string TbDnsObjectDoc {
get {
@@ -1942,6 +1978,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Please fill in DNS Structure, Click to view the document 的本地化字符串。
/// </summary>
public static string TbDnsSingboxObjectDoc {
get {
return ResourceManager.GetString("TbDnsSingboxObjectDoc", resourceCulture);
}
}
/// <summary>
/// 查找类似 Domain Matcher 的本地化字符串。
/// </summary>
@@ -1960,6 +2005,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 sing-box domain strategy 的本地化字符串。
/// </summary>
public static string TbdomainStrategy4Singbox {
get {
return ResourceManager.GetString("TbdomainStrategy4Singbox", resourceCulture);
}
}
/// <summary>
/// 查找类似 Edit 的本地化字符串。
/// </summary>
@@ -2041,6 +2095,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Congestion control 的本地化字符串。
/// </summary>
public static string TbHeaderType8 {
get {
return ResourceManager.GetString("TbHeaderType8", resourceCulture);
}
}
/// <summary>
/// 查找类似 UUID(id) 的本地化字符串。
/// </summary>
@@ -2158,6 +2221,33 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Domain 的本地化字符串。
/// </summary>
public static string TbRoutingRuleDomain {
get {
return ResourceManager.GetString("TbRoutingRuleDomain", resourceCulture);
}
}
/// <summary>
/// 查找类似 IP or IP CIDR 的本地化字符串。
/// </summary>
public static string TbRoutingRuleIP {
get {
return ResourceManager.GetString("TbRoutingRuleIP", resourceCulture);
}
}
/// <summary>
/// 查找类似 Full process name (Tun mode) 的本地化字符串。
/// </summary>
public static string TbRoutingRuleProcess {
get {
return ResourceManager.GetString("TbRoutingRuleProcess", resourceCulture);
}
}
/// <summary>
/// 查找类似 3.Block Domain or IP 的本地化字符串。
/// </summary>
@@ -2257,6 +2347,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Click to import default DNS config 的本地化字符串。
/// </summary>
public static string TbSettingDnsImportDefConfig {
get {
return ResourceManager.GetString("TbSettingDnsImportDefConfig", resourceCulture);
}
}
/// <summary>
/// 查找类似 Advanced proxy settings, protocol selection (optional) 的本地化字符串。
/// </summary>
@@ -2285,7 +2384,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Automatic update interval of and Geo (hours) 的本地化字符串。
/// 查找类似 Automatic update interval of Geo (hours) 的本地化字符串。
/// </summary>
public static string TbSettingsAutoUpdateInterval {
get {
@@ -2321,7 +2420,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Core: DNS settings 的本地化字符串。
/// 查找类似 V2ray DNS settings 的本地化字符串。
/// </summary>
public static string TbSettingsCoreDns {
get {
@@ -2329,6 +2428,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 sing-box DNS settings 的本地化字符串。
/// </summary>
public static string TbSettingsCoreDnsSingbox {
get {
return ResourceManager.GetString("TbSettingsCoreDnsSingbox", resourceCulture);
}
}
/// <summary>
/// 查找类似 Core: KCP settings 的本地化字符串。
/// </summary>
@@ -2357,7 +2465,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Copy the font TTF file to the directory guiFonts, restart the settings 的本地化字符串。
/// 查找类似 Copy the font TTF/TTC file to the directory guiFonts, restart the settings 的本地化字符串。
/// </summary>
public static string TbSettingsCurrentFontFamilyTip {
get {
@@ -2446,6 +2554,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Enable additional Inbound 的本地化字符串。
/// </summary>
public static string TbSettingsEnableExInbound {
get {
return ResourceManager.GetString("TbSettingsEnableExInbound", resourceCulture);
}
}
/// <summary>
/// 查找类似 Enable hardware acceleration(Require restart) 的本地化字符串。
/// </summary>
@@ -2455,6 +2572,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Enable IPv6 Address 的本地化字符串。
/// </summary>
public static string TbSettingsEnableIPv6Address {
get {
return ResourceManager.GetString("TbSettingsEnableIPv6Address", resourceCulture);
}
}
/// <summary>
/// 查找类似 Exception 的本地化字符串。
/// </summary>
@@ -2473,6 +2599,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Follow System Theme 的本地化字符串。
/// </summary>
public static string TbSettingsFollowSystemTheme {
get {
return ResourceManager.GetString("TbSettingsFollowSystemTheme", resourceCulture);
}
}
/// <summary>
/// 查找类似 FontSize 的本地化字符串。
/// </summary>
@@ -2491,6 +2626,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Hysteria Max bandwidth (Up/Dw) 的本地化字符串。
/// </summary>
public static string TbSettingsHysteriaBandwidth {
get {
return ResourceManager.GetString("TbSettingsHysteriaBandwidth", resourceCulture);
}
}
/// <summary>
/// 查找类似 Ignore Geo files when updating core 的本地化字符串。
/// </summary>
@@ -2545,6 +2689,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 sing-box Mux Protocol 的本地化字符串。
/// </summary>
public static string TbSettingsMux4SboxProtocol {
get {
return ResourceManager.GetString("TbSettingsMux4SboxProtocol", resourceCulture);
}
}
/// <summary>
/// 查找类似 Turn on Mux Multiplexing 的本地化字符串。
/// </summary>
@@ -2680,15 +2833,6 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Statistics freshrate (second) 的本地化字符串。
/// </summary>
public static string TbSettingsStatisticsFreshRate {
get {
return ResourceManager.GetString("TbSettingsStatisticsFreshRate", resourceCulture);
}
}
/// <summary>
/// 查找类似 Subscription conversion Url 的本地化字符串。
/// </summary>
@@ -2743,15 +2887,6 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Enable: If no route matches, the final proxy 的本地化字符串。
/// </summary>
public static string TbSettingsTunModeBypassModeTip {
get {
return ResourceManager.GetString("TbSettingsTunModeBypassModeTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Custom Template 的本地化字符串。
/// </summary>
@@ -2833,6 +2968,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Use System Hosts 的本地化字符串。
/// </summary>
public static string TbSettingsUseSystemHosts {
get {
return ResourceManager.GetString("TbSettingsUseSystemHosts", resourceCulture);
}
}
/// <summary>
/// 查找类似 ShortId 的本地化字符串。
/// </summary>
@@ -2924,7 +3068,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 * After setting this value, an socks service will be started using V2ray to provide functions such as speed display 的本地化字符串。
/// 查找类似 * After setting this value, an socks service will be started using sing-box to provide functions such as speed display 的本地化字符串。
/// </summary>
public static string TipPreSocksPort {
get {

View File

@@ -187,10 +187,10 @@
<value>پیکربندی اولیه</value>
</data>
<data name="IsLatestCore" xml:space="preserve">
<value>{0} در حال حاضر به روز است.</value>
<value>{0} {1} در حال حاضر به روز است.</value>
</data>
<data name="IsLatestN" xml:space="preserve">
<value>{0} در حال حاضر به روز است.</value>
<value>{0} {1} در حال حاضر به روز است.</value>
</data>
<data name="LvAddress" xml:space="preserve">
<value>آدرس</value>
@@ -300,9 +300,6 @@
<data name="SaveClientConfigurationIn" xml:space="preserve">
<value>The client configuration file is saved at: {0}</value>
</data>
<data name="SaveServerConfigurationIn" xml:space="preserve">
<value>The server configuration file is saved at: {0}</value>
</data>
<data name="StartService" xml:space="preserve">
<value>Start service ({0})...</value>
</data>
@@ -553,9 +550,6 @@
<data name="menuExport2ClientConfig" xml:space="preserve">
<value>سرور انتخابی را برای پیکربندی کلاینت صادر کنید</value>
</data>
<data name="menuExport2ServerConfig" xml:space="preserve">
<value>سرور انتخاب شده را برای پیکربندی سرور صادر کنید</value>
</data>
<data name="menuExport2ShareUrl" xml:space="preserve">
<value>URL های اشتراک گذاری را به کلیپ بورد صادر کنید (Ctrl+C)</value>
</data>
@@ -707,7 +701,7 @@
<value>txtPreSocksPort</value>
</data>
<data name="TipPreSocksPort" xml:space="preserve">
<value>* After setting this value, an socks service will be started using V2ray to provide functions such as speed display</value>
<value>* After setting this value, an socks service will be started using sing-box to provide functions such as speed display</value>
</data>
<data name="TbBrowse" xml:space="preserve">
<value>Browse</value>
@@ -731,7 +725,7 @@
<value>هسته: تنظیمات اولیه</value>
</data>
<data name="TbSettingsCoreDns" xml:space="preserve">
<value>هسته: تنظیمات DNS</value>
<value>V2ray DNS settings</value>
</data>
<data name="TbSettingsCoreKcp" xml:space="preserve">
<value>هسته: تنظیمات KCP</value>
@@ -799,9 +793,6 @@
<data name="TbSettingsStatistics" xml:space="preserve">
<value>فعال کردن آمار (نیاز به راه اندازی مجدد)</value>
</data>
<data name="TbSettingsStatisticsFreshRate" xml:space="preserve">
<value>نرخ تازه سازی آمار (ثانیه)</value>
</data>
<data name="TbSettingsSubConvert" xml:space="preserve">
<value>Subscription conversion Url</value>
</data>

View File

@@ -148,7 +148,7 @@
<value>Failed to generate default configuration file</value>
</data>
<data name="FailedGetDefaultConfiguration" xml:space="preserve">
<value> Failed to get the default configuration</value>
<value>Failed to get the default configuration</value>
</data>
<data name="FailedImportedCustomServer" xml:space="preserve">
<value>Failed to import custom configuration server</value>
@@ -175,22 +175,22 @@
<value>Please fill in the user ID</value>
</data>
<data name="IncorrectClientConfiguration" xml:space="preserve">
<value> is not the correct client configuration file, please check</value>
<value>Is not the correct client configuration file, please check</value>
</data>
<data name="Incorrectconfiguration" xml:space="preserve">
<value> is not the correct configuration, please check</value>
<value>Is not the correct configuration, please check</value>
</data>
<data name="IncorrectServerConfiguration" xml:space="preserve">
<value> is not the correct server configuration file, please check</value>
<value>Is not the correct server configuration file, please check</value>
</data>
<data name="InitialConfiguration" xml:space="preserve">
<value>Initial Configuration</value>
</data>
<data name="IsLatestCore" xml:space="preserve">
<value>{0} already up to date.</value>
<value>{0} {1} already up to date.</value>
</data>
<data name="IsLatestN" xml:space="preserve">
<value>{0} already up to date.</value>
<value>{0} {1} already up to date.</value>
</data>
<data name="LvAddress" xml:space="preserve">
<value>Address</value>
@@ -250,7 +250,7 @@
<value>Invalid subscription content</value>
</data>
<data name="MsgUnpacking" xml:space="preserve">
<value>is unpacking...</value>
<value>Is unpacking......</value>
</data>
<data name="MsgUpdateSubscriptionEnd" xml:space="preserve">
<value>Update subscription end</value>
@@ -268,7 +268,7 @@
<value>Non-VMess or ss protocol</value>
</data>
<data name="NonVmessService" xml:space="preserve">
<value> non-standard service, this feature is invalid</value>
<value>Non-standard service, this feature is invalid</value>
</data>
<data name="NotFoundCore" xml:space="preserve">
<value>The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2}</value>
@@ -277,7 +277,7 @@
<value>Scan completed, no valid QR code found</value>
</data>
<data name="OperationFailed" xml:space="preserve">
<value> operation failed, please check and retry</value>
<value>Operation failed, please check and retry</value>
</data>
<data name="PleaseFillRemarks" xml:space="preserve">
<value>Please Fill Remarks</value>
@@ -300,9 +300,6 @@
<data name="SaveClientConfigurationIn" xml:space="preserve">
<value>The client configuration file is saved at: {0}</value>
</data>
<data name="SaveServerConfigurationIn" xml:space="preserve">
<value>The server configuration file is saved at: {0}</value>
</data>
<data name="StartService" xml:space="preserve">
<value>Start service ({0})...</value>
</data>
@@ -311,10 +308,10 @@
{0}</value>
</data>
<data name="SuccessfullyImportedCustomServer" xml:space="preserve">
<value>Custom configuration server imported successfully.</value>
<value>Custom configuration server imported successfully</value>
</data>
<data name="SuccessfullyImportedServerViaClipboard" xml:space="preserve">
<value>{0} servers have been imported from clipboard.</value>
<value>{0} servers have been imported from clipboard</value>
</data>
<data name="SuccessfullyImportedServerViaScan" xml:space="preserve">
<value>Scan import URL successfully</value>
@@ -508,6 +505,9 @@
<data name="TbSettingsColorMode" xml:space="preserve">
<value>Dark Mode</value>
</data>
<data name="TbSettingsFollowSystemTheme" xml:space="preserve">
<value>Follow System Theme</value>
</data>
<data name="TbSettingsLanguage" xml:space="preserve">
<value>Language(Restart)</value>
</data>
@@ -553,9 +553,6 @@
<data name="menuExport2ClientConfig" xml:space="preserve">
<value>Export selected server for client configuration</value>
</data>
<data name="menuExport2ServerConfig" xml:space="preserve">
<value>Export selected server for server configuration</value>
</data>
<data name="menuExport2ShareUrl" xml:space="preserve">
<value>Export share URLs to clipboard (Ctrl+C)</value>
</data>
@@ -707,7 +704,7 @@
<value>txtPreSocksPort</value>
</data>
<data name="TipPreSocksPort" xml:space="preserve">
<value>* After setting this value, an socks service will be started using V2ray to provide functions such as speed display</value>
<value>* After setting this value, an socks service will be started using sing-box to provide functions such as speed display</value>
</data>
<data name="TbBrowse" xml:space="preserve">
<value>Browse</value>
@@ -725,13 +722,13 @@
<value>Auto hide startup</value>
</data>
<data name="TbSettingsAutoUpdateInterval" xml:space="preserve">
<value>Automatic update interval of and Geo (hours)</value>
<value>Automatic update interval of Geo (hours)</value>
</data>
<data name="TbSettingsCore" xml:space="preserve">
<value>Core: basic settings</value>
</data>
<data name="TbSettingsCoreDns" xml:space="preserve">
<value>Core: DNS settings</value>
<value>V2ray DNS settings</value>
</data>
<data name="TbSettingsCoreKcp" xml:space="preserve">
<value>Core: KCP settings</value>
@@ -799,9 +796,6 @@
<data name="TbSettingsStatistics" xml:space="preserve">
<value>Enable Statistics (Require restart)</value>
</data>
<data name="TbSettingsStatisticsFreshRate" xml:space="preserve">
<value>Statistics freshrate (second)</value>
</data>
<data name="TbSettingsSubConvert" xml:space="preserve">
<value>Subscription conversion Url</value>
</data>
@@ -884,10 +878,10 @@
<value>Import Advanced Rules</value>
</data>
<data name="menuRoutingAdvancedRemove" xml:space="preserve">
<value>Remove selected</value>
<value>Remove selected (Delete)</value>
</data>
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
<value>Set as active rule</value>
<value>Set as active rule(Enter)</value>
</data>
<data name="menuRoutingBasic" xml:space="preserve">
<value>Basic Function</value>
@@ -941,19 +935,19 @@
<value>Rule List</value>
</data>
<data name="menuRuleRemove" xml:space="preserve">
<value>Remove Rules</value>
<value>Remove Rules (Delete)</value>
</data>
<data name="menuRoutingRuleDetailsSetting" xml:space="preserve">
<value>RoutingRuleDetailsSetting</value>
</data>
<data name="TbAutoSort" xml:space="preserve">
<value>Domain and ip are auto sorted when saving</value>
<value>Domain, ip, process are auto sorted when saving</value>
</data>
<data name="TbRuleobjectDoc" xml:space="preserve">
<value>Ruleobject Doc</value>
</data>
<data name="TbDnsObjectDoc" xml:space="preserve">
<value>Support DnsObject</value>
<value>Support DnsObject, Click to view the document</value>
</data>
<data name="SubUrlTips" xml:space="preserve">
<value>Group please leave blank here</value>
@@ -1043,7 +1037,7 @@
<value>FontFamily(Require restart)</value>
</data>
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
<value>Copy the font TTF file to the directory guiFonts, restart the settings</value>
<value>Copy the font TTF/TTC file to the directory guiFonts, restart the settings</value>
</data>
<data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>http port=socks port+1</value>
@@ -1063,9 +1057,6 @@
<data name="TbSettingsTunModeBypassMode" xml:space="preserve">
<value>Bypass Mode</value>
</data>
<data name="TbSettingsTunModeBypassModeTip" xml:space="preserve">
<value>Enable: If no route matches, the final proxy</value>
</data>
<data name="TbSettingsSpeedTestTimeout" xml:space="preserve">
<value>SpeedTest Single Timeout Value</value>
</data>
@@ -1091,7 +1082,7 @@
<value>Enable hardware acceleration(Require restart)</value>
</data>
<data name="SpeedtestingWait" xml:space="preserve">
<value>Waiting for testing</value>
<value>Waiting for testing......</value>
</data>
<data name="TipDisplayLog" xml:space="preserve">
<value>Please turn off when there is an abnormal disconnection</value>
@@ -1120,4 +1111,61 @@
<data name="LvConvertTargetTip" xml:space="preserve">
<value>Please leave blank if no conversion is required</value>
</data>
<data name="menuDNSSetting" xml:space="preserve">
<value>DNS Settings</value>
</data>
<data name="TbSettingsCoreDnsSingbox" xml:space="preserve">
<value>sing-box DNS settings</value>
</data>
<data name="TbDnsSingboxObjectDoc" xml:space="preserve">
<value>Please fill in DNS Structure, Click to view the document</value>
</data>
<data name="TbSettingDnsImportDefConfig" xml:space="preserve">
<value>Click to import default DNS config</value>
</data>
<data name="TbdomainStrategy4Singbox" xml:space="preserve">
<value>sing-box domain strategy</value>
</data>
<data name="TbSettingsMux4SboxProtocol" xml:space="preserve">
<value>sing-box Mux Protocol</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>Full process name (Tun mode)</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP or IP CIDR</value>
</data>
<data name="TbRoutingRuleDomain" xml:space="preserve">
<value>Domain</value>
</data>
<data name="menuAddHysteria2Server" xml:space="preserve">
<value>Add [Trojan] server</value>
</data>
<data name="TbSettingsHysteriaBandwidth" xml:space="preserve">
<value>Hysteria Max bandwidth (Up/Dw)</value>
</data>
<data name="TbSettingsUseSystemHosts" xml:space="preserve">
<value>Use System Hosts</value>
</data>
<data name="menuAddTuicServer" xml:space="preserve">
<value>Add [Tuic] server</value>
</data>
<data name="TbHeaderType8" xml:space="preserve">
<value>Congestion control</value>
</data>
<data name="LvPrevProfile" xml:space="preserve">
<value>Previous proxy remakrs</value>
</data>
<data name="LvNextProfile" xml:space="preserve">
<value>Next proxy remarks</value>
</data>
<data name="LvPrevProfileTip" xml:space="preserve">
<value>Please make sure the remarks exists and is unique</value>
</data>
<data name="TbSettingsEnableExInbound" xml:space="preserve">
<value>Enable additional Inbound</value>
</data>
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
<value>Enable IPv6 Address</value>
</data>
</root>

View File

@@ -187,10 +187,10 @@
<value>Исходная конфигурация</value>
</data>
<data name="IsLatestCore" xml:space="preserve">
<value>{0} является последней версией.</value>
<value>{0} {1} является последней версией.</value>
</data>
<data name="IsLatestN" xml:space="preserve">
<value>{0} является последней версией.</value>
<value>{0} {1} является последней версией.</value>
</data>
<data name="LvAddress" xml:space="preserve">
<value>Адрес</value>
@@ -300,9 +300,6 @@
<data name="SaveClientConfigurationIn" xml:space="preserve">
<value>Файл конфигурации клиента сохранен по адресу: {0}</value>
</data>
<data name="SaveServerConfigurationIn" xml:space="preserve">
<value>Файл конфигурации сервера сохранен по адресу: {0}</value>
</data>
<data name="StartService" xml:space="preserve">
<value>Запуск сервиса ({0})...</value>
</data>
@@ -320,7 +317,7 @@
<value>Сканирование URL-адреса импорта успешна.</value>
</data>
<data name="TestMeOutput" xml:space="preserve">
<value>Пинг текущей службы: {0} мс</value>
<value>Задержка текущего сервера: {0} мс</value>
</data>
<data name="OperationSuccess" xml:space="preserve">
<value>Операция успешна</value>
@@ -338,7 +335,7 @@
<value>Примечания</value>
</data>
<data name="LvUrl" xml:space="preserve">
<value>Url(Необязательно)</value>
<value>URL (необязательно)</value>
</data>
<data name="LvCount" xml:space="preserve">
<value>Количество</value>
@@ -508,6 +505,9 @@
<data name="TbSettingsColorMode" xml:space="preserve">
<value>Тёмный режим</value>
</data>
<data name="TbSettingsFollowSystemTheme" xml:space="preserve">
<value>Следить за системной темой</value>
</data>
<data name="TbSettingsLanguage" xml:space="preserve">
<value>Язык (требуется перезапуск)</value>
</data>
@@ -533,19 +533,19 @@
<value>Очистить всю статистику</value>
</data>
<data name="menuPingServer" xml:space="preserve">
<value>Проверить пинг серверов (Ctrl+P)</value>
<value>Тест на задержку сервера (Ctrl+P)</value>
</data>
<data name="menuRealPingServer" xml:space="preserve">
<value>Тест на реальную задержку серверов (Ctrl+R)</value>
<value>Тест на реальную задержку сервера (Ctrl+R)</value>
</data>
<data name="menuSortServerResult" xml:space="preserve">
<value>Сортировать по результату теста</value>
</data>
<data name="menuSpeedServer" xml:space="preserve">
<value>Проверить скорость загрузки серверов (Ctrl+T)</value>
<value>Тест на скорость загрузки сервера (Ctrl+T)</value>
</data>
<data name="menuTcpingServer" xml:space="preserve">
<value>Тестировать сервера с tcping (Ctrl+O)</value>
<value>Тест задержки с tcping (Ctrl+O)</value>
</data>
<data name="menuTestMe" xml:space="preserve">
<value>Проверить текущий статус службы</value>
@@ -553,9 +553,6 @@
<data name="menuExport2ClientConfig" xml:space="preserve">
<value>Экспортировать выбранный сервер для клиента</value>
</data>
<data name="menuExport2ServerConfig" xml:space="preserve">
<value>Экспортировать выбранный сервер для сервера</value>
</data>
<data name="menuExport2ShareUrl" xml:space="preserve">
<value>Экспорт URL-адресов общего доступа в буфер обмена (Ctrl+C)</value>
</data>
@@ -647,7 +644,7 @@
<value>Тип камуфляжа</value>
</data>
<data name="TbId" xml:space="preserve">
<value>UUID(id)</value>
<value>UUID (id)</value>
</data>
<data name="TbNetwork" xml:space="preserve">
<value>Транспортный протокол сети</value>
@@ -659,7 +656,7 @@
<value>Порт</value>
</data>
<data name="TbRemarks" xml:space="preserve">
<value>Псевдоним (примечания)</value>
<value>Примечание</value>
</data>
<data name="TbRequestHost" xml:space="preserve">
<value>Маскирующий домен (хост)</value>
@@ -707,7 +704,7 @@
<value>txtPreSocksPort</value>
</data>
<data name="TipPreSocksPort" xml:space="preserve">
<value>* После установки этого значения служба socks будет запущена с использованием V2ray для обеспечения таких функций, как отображение скорости</value>
<value>* После установки этого значения служба socks будет запущена с использованием sing-box для обеспечения таких функций, как отображение скорости</value>
</data>
<data name="TbBrowse" xml:space="preserve">
<value>Просмотр</value>
@@ -722,16 +719,22 @@
<value>Разрешить подключения из локальной сети</value>
</data>
<data name="TbSettingsAutoHideStartup" xml:space="preserve">
<value>Auto hide startup</value>
<value>Автоскрытие при автозапуске</value>
</data>
<data name="TbSettingsAutoUpdateInterval" xml:space="preserve">
<value>Интервал автоматического обновления Geo в часах</value>
</data>
<data name="LvAutoUpdateInterval" xml:space="preserve">
<value>Интервал автоматического обновления в минутах</value>
</data>
<data name="TbSettingsCore" xml:space="preserve">
<value>Ядро: базовые настройки</value>
</data>
<data name="TbSettingsCoreDns" xml:space="preserve">
<value>Ядро: настройки DNS</value>
<value>Настройки DNS V2ray</value>
</data>
<data name="TbSettingsCoreDnsSingbox" xml:space="preserve">
<value>Настройки DNS sing-box</value>
</data>
<data name="TbSettingsCoreKcp" xml:space="preserve">
<value>Ядро: настройки KCP</value>
@@ -799,9 +802,6 @@
<data name="TbSettingsStatistics" xml:space="preserve">
<value>Включить статистику (требуется перезагрузка)</value>
</data>
<data name="TbSettingsStatisticsFreshRate" xml:space="preserve">
<value>Частота обновления статистики в секундах</value>
</data>
<data name="TbSettingsSubConvert" xml:space="preserve">
<value>URL-адрес конверсии подписки</value>
</data>
@@ -812,7 +812,7 @@
<value>Включить протокол безопасности TLS v1.3 (обновление подписки)</value>
</data>
<data name="TbSettingsTrayMenuServersLimit" xml:space="preserve">
<value>Tray right-click menu servers display limit</value>
<value>Лимит серверов в меню трея</value>
</data>
<data name="TbSettingsUdpEnabled" xml:space="preserve">
<value>Включить UDP</value>
@@ -941,7 +941,7 @@
<value>Список правил</value>
</data>
<data name="menuRuleRemove" xml:space="preserve">
<value>Удалить правила</value>
<value>Удалить правила (Delete)</value>
</data>
<data name="menuRoutingRuleDetailsSetting" xml:space="preserve">
<value>RoutingRuleDetailsSetting</value>
@@ -956,7 +956,7 @@
<value>Поддержка DnsObject</value>
</data>
<data name="SubUrlTips" xml:space="preserve">
<value>Group please leave blank here</value>
<value>Необязательное поле</value>
</data>
<data name="TipChangeRouting" xml:space="preserve">
<value>Настройки маршрутизации изменены</value>
@@ -968,7 +968,7 @@
<value>Только маршрут</value>
</data>
<data name="menuMixedTestServer" xml:space="preserve">
<value>Тест задержки и скорости (Ctrl+E)</value>
<value>Тест задержки и скорости всех серверов (Ctrl+E)</value>
</data>
<data name="LvTestDelay" xml:space="preserve">
<value>Задержка (ms)</value>
@@ -989,7 +989,7 @@
<value>Импортировать старый конфиг guiNConfig</value>
</data>
<data name="TbEnableTunAs" xml:space="preserve">
<value>Включить интерфейс</value>
<value>Режим VPN</value>
</data>
<data name="TbSettingsNewPort4LAN" xml:space="preserve">
<value>Новый порт для локальной сети</value>
@@ -1043,7 +1043,7 @@
<value>Шрифт (требуется перезагрузка)</value>
</data>
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
<value>Скопируйте файл шрифта TTF в каталог guiFonts, перезапустите настройки</value>
<value>Скопируйте файл шрифта TTF/TTC в каталог guiFonts, перезапустите настройки</value>
</data>
<data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>HTTP port=socks port+1</value>
@@ -1057,4 +1057,19 @@
<data name="TbSettingsEnableHWA" xml:space="preserve">
<value>Включить аппаратное ускорение (требуется перезагрузка)</value>
</data>
</root>
<data name="menuRebootAsAdmin" xml:space="preserve">
<value>Перезагрузить как администратор</value>
</data>
<data name="menuDNSSetting" xml:space="preserve">
<value>Настройки DNS</value>
</data>
<data name="TbSettingsLogEnabledToFile" xml:space="preserve">
<value>Включить логгирование в файл</value>
</data>
<data name="TbSettingsSpeedTestTimeout" xml:space="preserve">
<value>Таймаут одиночного спидтеста</value>
</data>
<data name="TbSettingsSpeedTestUrl" xml:space="preserve">
<value>URL спидтеста</value>
</data>
</root>

View File

@@ -187,10 +187,10 @@
<value>初始化配置</value>
</data>
<data name="IsLatestCore" xml:space="preserve">
<value>{0} 已是最新版本。</value>
<value>{0} {1} 已是最新版本。</value>
</data>
<data name="IsLatestN" xml:space="preserve">
<value>{0} 已是最新版本。</value>
<value>{0} {1} 已是最新版本。</value>
</data>
<data name="LvAddress" xml:space="preserve">
<value>地址</value>
@@ -300,9 +300,6 @@
<data name="SaveClientConfigurationIn" xml:space="preserve">
<value>客户端配置文件保存在:{0}</value>
</data>
<data name="SaveServerConfigurationIn" xml:space="preserve">
<value>服务端配置文件保存在:{0}</value>
</data>
<data name="StartService" xml:space="preserve">
<value>启动服务({0})...</value>
</data>
@@ -508,6 +505,9 @@
<data name="TbSettingsColorMode" xml:space="preserve">
<value>暗黑模式</value>
</data>
<data name="TbSettingsFollowSystemTheme" xml:space="preserve">
<value>是否跟随系统主题</value>
</data>
<data name="TbSettingsLanguage" xml:space="preserve">
<value>语言(重启)</value>
</data>
@@ -553,9 +553,6 @@
<data name="menuExport2ClientConfig" xml:space="preserve">
<value>导出所选服务器为客户端配置</value>
</data>
<data name="menuExport2ServerConfig" xml:space="preserve">
<value>导出所选服务器为服务端配置</value>
</data>
<data name="menuExport2ShareUrl" xml:space="preserve">
<value>批量导出分享URL至剪贴板(多选) (Ctrl+C)</value>
</data>
@@ -707,7 +704,7 @@
<value>Socks端口</value>
</data>
<data name="TipPreSocksPort" xml:space="preserve">
<value>* 自定义配置的Socks端口值可不设置当设置此值后将使用V2ray-core额外启动一个前置Socks服务提供分流和速度显示等功能</value>
<value>* 自定义配置的Socks端口值可不设置当设置此值后将使用sing-box额外启动一个前置Socks服务提供分流和速度显示等功能</value>
</data>
<data name="TbBrowse" xml:space="preserve">
<value>浏览</value>
@@ -731,7 +728,7 @@
<value>Core: 基础设置</value>
</data>
<data name="TbSettingsCoreDns" xml:space="preserve">
<value>Core: DNS设置</value>
<value>V2ray DNS设置</value>
</data>
<data name="TbSettingsCoreKcp" xml:space="preserve">
<value>Core: KCP设置</value>
@@ -799,9 +796,6 @@
<data name="TbSettingsStatistics" xml:space="preserve">
<value>启用统计(实时网速显示,需重启)</value>
</data>
<data name="TbSettingsStatisticsFreshRate" xml:space="preserve">
<value>统计刷新频率(单位秒)</value>
</data>
<data name="TbSettingsSubConvert" xml:space="preserve">
<value>订阅转换网址(可选)</value>
</data>
@@ -884,10 +878,10 @@
<value>一键导入高级规则</value>
</data>
<data name="menuRoutingAdvancedRemove" xml:space="preserve">
<value>移除所选规则</value>
<value>移除所选规则 (Delete)</value>
</data>
<data name="menuRoutingAdvancedSetDefault" xml:space="preserve">
<value>设为活动规则</value>
<value>设为活动规则 (Enter)</value>
</data>
<data name="menuRoutingBasic" xml:space="preserve">
<value>基础功能</value>
@@ -902,7 +896,7 @@
<value>域名解析策略</value>
</data>
<data name="TbenableRoutingAdvanced" xml:space="preserve">
<value>启用路由高级功能</value>
<value>启用高级功能</value>
</data>
<data name="TbRoutingTabBlock" xml:space="preserve">
<value>3.阻止的Domain或IP</value>
@@ -941,19 +935,19 @@
<value>规则列表</value>
</data>
<data name="menuRuleRemove" xml:space="preserve">
<value>移除所选规则</value>
<value>移除所选规则 (Delete)</value>
</data>
<data name="menuRoutingRuleDetailsSetting" xml:space="preserve">
<value>路由规则详情设置</value>
</data>
<data name="TbAutoSort" xml:space="preserve">
<value>保存时Domain和IP自动排序</value>
<value>保存时Domain, IP, 进程名 自动排序</value>
</data>
<data name="TbRuleobjectDoc" xml:space="preserve">
<value>规则详细说明文档</value>
</data>
<data name="TbDnsObjectDoc" xml:space="preserve">
<value>支持填写DnsObject,JSON格式</value>
<value>支持填写DnsObject,JSON格式,点击查看文档</value>
</data>
<data name="SubUrlTips" xml:space="preserve">
<value>普通分组此处请留空</value>
@@ -1043,7 +1037,7 @@
<value>当前字体(需重启)</value>
</data>
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
<value>拷贝字体TTF文件到目录guiFonts重启设置</value>
<value>拷贝字体TTF/TTC文件到目录guiFonts重启设置</value>
</data>
<data name="TbSettingsSocksPortTip" xml:space="preserve">
<value>http端口=socks端口+1</value>
@@ -1063,9 +1057,6 @@
<data name="TbSettingsTunModeBypassMode" xml:space="preserve">
<value>绕行模式</value>
</data>
<data name="TbSettingsTunModeBypassModeTip" xml:space="preserve">
<value>启用:路由无匹配则最终代理</value>
</data>
<data name="TbSettingsSpeedTestTimeout" xml:space="preserve">
<value>测速单个超时值</value>
</data>
@@ -1091,7 +1082,7 @@
<value>启用硬件加速(需重启)</value>
</data>
<data name="SpeedtestingWait" xml:space="preserve">
<value>等待测试中...</value>
<value>等待测试中......</value>
</data>
<data name="TipDisplayLog" xml:space="preserve">
<value>当有异常断流时请关闭</value>
@@ -1117,4 +1108,61 @@
<data name="LvConvertTargetTip" xml:space="preserve">
<value>不需要转换时请留空</value>
</data>
<data name="menuDNSSetting" xml:space="preserve">
<value>DNS设置</value>
</data>
<data name="TbSettingsCoreDnsSingbox" xml:space="preserve">
<value>sing-box DNS设置</value>
</data>
<data name="TbDnsSingboxObjectDoc" xml:space="preserve">
<value>请填写 DNS JSON 结构,点击查看文档</value>
</data>
<data name="TbSettingDnsImportDefConfig" xml:space="preserve">
<value>点击导入默认DNS配置</value>
</data>
<data name="TbdomainStrategy4Singbox" xml:space="preserve">
<value>sing-box域名解析策略</value>
</data>
<data name="TbSettingsMux4SboxProtocol" xml:space="preserve">
<value>sing-box Mux 多路复用协议</value>
</data>
<data name="TbRoutingRuleProcess" xml:space="preserve">
<value>进程名全称 (Tun模式)</value>
</data>
<data name="TbRoutingRuleDomain" xml:space="preserve">
<value>Domain</value>
</data>
<data name="TbRoutingRuleIP" xml:space="preserve">
<value>IP 或 IP CIDR</value>
</data>
<data name="menuAddHysteria2Server" xml:space="preserve">
<value>添加[Hysteria2]服务器</value>
</data>
<data name="TbSettingsHysteriaBandwidth" xml:space="preserve">
<value>Hysteria 最大带宽(Up/Dw)</value>
</data>
<data name="TbSettingsUseSystemHosts" xml:space="preserve">
<value>使用系统hosts</value>
</data>
<data name="menuAddTuicServer" xml:space="preserve">
<value>添加[Tuic]服务器</value>
</data>
<data name="TbHeaderType8" xml:space="preserve">
<value>拥塞控制算法</value>
</data>
<data name="LvPrevProfile" xml:space="preserve">
<value>前置代理别名</value>
</data>
<data name="LvNextProfile" xml:space="preserve">
<value>落地代理別名</value>
</data>
<data name="LvPrevProfileTip" xml:space="preserve">
<value>请确保别名存在并唯一</value>
</data>
<data name="TbSettingsEnableExInbound" xml:space="preserve">
<value>启用额外监听端口</value>
</data>
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
<value>启用IPv6</value>
</data>
</root>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
{
"tag": "proxy",
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "v2ray.cool",
"port": 10086,
"users": [
{
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
"security": "auto"
}
]
}
],
"servers": [
{
"address": "v2ray.cool",
"method": "chacha20",
"ota": false,
"password": "123456",
"port": 10086,
"level": 1
}
]
},
"streamSettings": {
"network": "tcp"
},
"mux": {
"enabled": false
}
}

View File

@@ -1,33 +0,0 @@
{
"log": {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},
"inbounds": [{
"port": 10086,
"protocol": "vmess",
"settings": {
"clients": [{
"id": "23ad6b10-8d1a-40f7-8ad0-e3e35cd38297",
"level": 1,
"email": "t@t.tt"
}]
},
"streamSettings": {
"network": "tcp"
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
}, {
"protocol": "blackhole",
"settings": {},
"tag": "block"
}],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": []
}
}

View File

@@ -0,0 +1,42 @@
{
"log": {
"level": "debug",
"timestamp": true
},
"inbounds": [
{
"type": "socks",
"tag": "socks",
"listen": "127.0.0.1",
"listen_port": 10000
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "",
"server_port": 443
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"tag": "dns_out",
"type": "dns"
}
],
"route": {
"rules": [
{
"protocol": [ "dns" ],
"outbound": "dns_out"
}
]
}
}

View File

@@ -0,0 +1,6 @@
{
"type": "vless",
"tag": "proxy",
"server": "",
"server_port": 443
}

View File

@@ -0,0 +1,32 @@
{
"servers": [
{
"tag": "remote",
"address": "tcp://8.8.8.8",
"detour": "proxy"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
},
{
"tag": "block",
"address": "rcode://success"
}
],
"rules": [
{
"geosite": [
"cn"
],
"server": "local"
},
{
"geosite": [
"category-ads-all"
],
"server": "block"
}
]
}

View File

@@ -0,0 +1,20 @@
{
"hosts": {
"dns.google": "8.8.8.8",
"proxy.example.com": "127.0.0.1"
},
"servers": [
{
"address": "223.5.5.5",
"domains": [
"geosite:cn"
],
"expectIPs": [
"geoip:cn"
]
},
"1.1.1.1",
"8.8.8.8",
"https://dns.google/dns-query"
]
}

View File

@@ -1,97 +0,0 @@
{
"log": {
"disabled": $log_disabled$,
"level": "debug",
$log_output$
"timestamp": true
},
"dns": $dns_object$ ,
"inbounds": [
{
"type": "tun",
"tag": "tun-in",
"interface_name": "singbox_tun",
"inet4_address": "172.19.0.1/30",
"mtu": $mtu$,
"auto_route": true,
"strict_route": $strict_route$,
"stack": "$stack$",
"endpoint_independent_nat": true,
"sniff": true
}
],
"outbounds": [
{
"type": "socks",
"tag": "proxy",
"udp_fragment": true,
"server": "127.0.0.1",
"server_port": $socksPort$
},
{
"type": "block",
"tag": "block"
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "dns",
"tag": "dns_out"
}
],
"route": {
"auto_detect_interface": true,
"rules": [
{
"inbound": "dns_in",
"outbound": "dns_out"
},
{
"protocol": "dns",
"outbound": "dns_out"
},
{
"network": "udp",
"port": [
135,
137,
138,
139,
5353
],
"outbound": "block"
},
{
"ip_cidr": [
"224.0.0.0/3",
"ff00::/8"
],
"outbound": "block"
},
{
"source_ip_cidr": [
"224.0.0.0/3",
"ff00::/8"
],
"outbound": "block"
},
{
"port": 53,
"process_name": [ $dnsProcessName$],
"outbound": "dns_out"
},
{
"process_name": [ $directProcessName$],
"outbound": "direct"
}
$ruleDirectIPs$
$ruleDirectProcess$
$ruleProxyIPs$
$ruleProxyProcess$
$ruleFinally$
]
}
}

View File

@@ -1,31 +1,35 @@
{
"servers": [
{
"tag": "out_dns",
"address": "8.8.8.8",
"detour": "proxy"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
},
{
"tag": "block",
"address": "rcode://success"
}
],
"rules": [
{
"geosite": "cn",
"server": "local",
"disable_cache": true
},
{
"geosite": "category-ads-all",
"server": "block",
"disable_cache": true
}
],
"strategy": "ipv4_only"
}
{
"servers": [
{
"tag": "remote",
"address": "tcp://8.8.8.8",
"detour": "proxy"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
},
{
"tag": "block",
"address": "rcode://success"
}
],
"rules": [
{
"geosite": [
"cn"
],
"server": "local",
"disable_cache": true
},
{
"geosite": [
"category-ads-all"
],
"server": "block",
"disable_cache": true
}
],
"strategy": "ipv4_only"
}

View File

@@ -0,0 +1,12 @@
{
"type": "tun",
"tag": "tun-in",
"interface_name": "singbox_tun",
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"mtu": 9000,
"auto_route": true,
"strict_route": false,
"stack": "system",
"sniff": true
}

View File

@@ -0,0 +1,31 @@
[
{
"protocol": [ "dns" ],
"outbound": "dns_out"
},
{
"network": "udp",
"port": [
135,
137,
138,
139,
5353
],
"outbound": "block"
},
{
"ip_cidr": [
"224.0.0.0/3",
"ff00::/8"
],
"outbound": "block"
},
{
"source_ip_cidr": [
"224.0.0.0/3",
"ff00::/8"
],
"outbound": "block"
}
]

View File

@@ -0,0 +1,182 @@
using v2rayN.Base;
namespace v2rayN.Tool
{
public class SemanticVersion
{
private int major;
private int minor;
private int patch;
private string version;
public SemanticVersion(int major, int minor, int patch)
{
this.major = major;
this.minor = minor;
this.patch = patch;
this.version = $"{major}.{minor}.{patch}";
}
public SemanticVersion(string version)
{
this.version = version.RemovePrefix('v');
try
{
string[] parts = this.version.Split('.');
if (parts.Length == 2)
{
this.major = int.Parse(parts[0]);
this.minor = int.Parse(parts[1]);
this.patch = 0;
}
else if (parts.Length == 3)
{
this.major = int.Parse(parts[0]);
this.minor = int.Parse(parts[1]);
this.patch = int.Parse(parts[2]);
}
else
{
throw new ArgumentException("Invalid version string");
}
}
catch
{
this.major = 0;
this.minor = 0;
this.patch = 0;
//this.version = "0.0.0";
}
}
public override bool Equals(object? obj)
{
if (obj is SemanticVersion other)
{
return this.major == other.major && this.minor == other.minor && this.patch == other.patch;
}
else
{
return false;
}
}
public override int GetHashCode()
{
return this.major.GetHashCode() ^ this.minor.GetHashCode() ^ this.patch.GetHashCode();
}
/// <summary>
/// Use ToVersionString(string? prefix) instead if possible.
/// </summary>
/// <returns>major.minor.patch</returns>
public override string ToString()
{
return this.version;
}
public string ToVersionString(string? prefix = null)
{
if (prefix == null)
{
return this.version;
}
else
{
return $"{prefix}{this.version}";
}
}
public static bool operator ==(SemanticVersion v1, SemanticVersion v2)
{ return v1.Equals(v2); }
public static bool operator !=(SemanticVersion v1, SemanticVersion v2)
{ return !v1.Equals(v2); }
public static bool operator >=(SemanticVersion v1, SemanticVersion v2)
{ return v1.GreaterEquals(v2); }
public static bool operator <=(SemanticVersion v1, SemanticVersion v2)
{ return v1.LessEquals(v2); }
#region Private
private bool GreaterEquals(SemanticVersion other)
{
if (this.major < other.major)
{
return false;
}
else if (this.major > other.major)
{
return true;
}
else
{
if (this.minor < other.minor)
{
return false;
}
else if (this.minor > other.minor)
{
return true;
}
else
{
if (this.patch < other.patch)
{
return false;
}
else if (this.patch > other.patch)
{
return true;
}
else
{
return true;
}
}
}
}
private bool LessEquals(SemanticVersion other)
{
if (this.major < other.major)
{
return true;
}
else if (this.major > other.major)
{
return false;
}
else
{
if (this.minor < other.minor)
{
return true;
}
else if (this.minor > other.minor)
{
return false;
}
else
{
if (this.patch < other.patch)
{
return true;
}
else if (this.patch > other.patch)
{
return false;
}
else
{
return true;
}
}
}
}
#endregion Private
}
}

View File

@@ -12,7 +12,6 @@ using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text;
@@ -466,6 +465,15 @@ namespace v2rayN
return Convert.TryFromBase64String(plainText, buffer, out int _);
}
public static string Convert2Comma(string text)
{
if (string.IsNullOrWhiteSpace(text))
{
return text;
}
return text.Replace("", ",").Replace(Environment.NewLine, ",");
}
#endregion
#region
@@ -554,14 +562,7 @@ namespace v2rayN
return false;
}
//清除要验证字符串中的空格
//domain = domain.TrimEx();
//模式字符串
string pattern = @"^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$";
//验证
return IsMatch(domain, pattern);
return Uri.CheckHostName(domain) == UriHostNameType.Dns;
}
/// <summary>
@@ -896,22 +897,26 @@ namespace v2rayN
}
/// <summary>
/// 深度拷贝
/// DeepCopy
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/// <returns></returns>
public static T DeepCopy<T>(T obj)
{
object retval;
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
//序列化成流
bf.Serialize(ms, obj);
ms.Seek(0, SeekOrigin.Begin);
//反序列化成对象
retval = bf.Deserialize(ms);
return (T)retval;
return FromJson<T>(ToJson(obj, false))!;
// object retval;
// MemoryStream ms = new();
//#pragma warning disable SYSLIB0011 // 类型或成员已过时
// BinaryFormatter bf = new();
//#pragma warning restore SYSLIB0011 // 类型或成员已过时
// //序列化成流
// bf.Serialize(ms, obj);
// ms.Seek(0, SeekOrigin.Begin);
// //反序列化成对象
// retval = bf.Deserialize(ms);
// return (T)retval;
}
/// <summary>
@@ -1045,6 +1050,13 @@ namespace v2rayN
DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, ref attribute, attributeSize);
}
public static bool IsLightTheme()
{
using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
var value = key?.GetValue("AppsUseLightTheme");
return value is int i && i > 0;
}
#endregion
#region TempPath

View File

@@ -90,7 +90,7 @@ namespace v2rayN.ViewModels
item.preSocksPort = SelectedSource.preSocksPort;
}
if (ConfigHandler.EditCustomServer(ref _config, item) == 0)
if (ConfigHandler.EditCustomServer(_config, item) == 0)
{
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
_view.DialogResult = true;
@@ -122,7 +122,7 @@ namespace v2rayN.ViewModels
var item = LazyConfig.Instance.GetProfileItem(SelectedSource.indexId);
item ??= SelectedSource;
item.address = fileName;
if (ConfigHandler.AddCustomServer(ref _config, item, false) == 0)
if (ConfigHandler.AddCustomServer(_config, item, false) == 0)
{
_noticeHandler?.Enqueue(ResUI.SuccessfullyImportedCustomServer);
if (!Utils.IsNullOrEmpty(item.indexId))

View File

@@ -127,23 +127,31 @@ namespace v2rayN.ViewModels
switch (item.configType)
{
case EConfigType.VMess:
ret = ConfigHandler.AddServer(ref _config, item);
ret = ConfigHandler.AddServer(_config, item);
break;
case EConfigType.Shadowsocks:
ret = ConfigHandler.AddShadowsocksServer(ref _config, item);
ret = ConfigHandler.AddShadowsocksServer(_config, item);
break;
case EConfigType.Socks:
ret = ConfigHandler.AddSocksServer(ref _config, item);
ret = ConfigHandler.AddSocksServer(_config, item);
break;
case EConfigType.VLESS:
ret = ConfigHandler.AddVlessServer(ref _config, item);
ret = ConfigHandler.AddVlessServer(_config, item);
break;
case EConfigType.Trojan:
ret = ConfigHandler.AddTrojanServer(ref _config, item);
ret = ConfigHandler.AddTrojanServer(_config, item);
break;
case EConfigType.Hysteria2:
ret = ConfigHandler.AddHysteria2Server(_config, item);
break;
case EConfigType.Tuic:
ret = ConfigHandler.AddTuicServer(_config, item);
break;
}

View File

@@ -0,0 +1,113 @@
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Splat;
using System.Reactive;
using System.Windows;
using v2rayN.Handler;
using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.ViewModels
{
public class DNSSettingViewModel : ReactiveObject
{
private static Config _config;
private NoticeHandler? _noticeHandler;
private Window _view;
[Reactive] public bool useSystemHosts { get; set; }
[Reactive] public string domainStrategy4Freedom { get; set; }
[Reactive] public string normalDNS { get; set; }
[Reactive] public string normalDNS2 { get; set; }
[Reactive] public string tunDNS2 { get; set; }
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
public ReactiveCommand<Unit, Unit> ImportDefConfig4V2rayCmd { get; }
public ReactiveCommand<Unit, Unit> ImportDefConfig4SingboxCmd { get; }
public DNSSettingViewModel(Window view)
{
_config = LazyConfig.Instance.GetConfig();
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
_view = view;
var item = LazyConfig.Instance.GetDNSItem(ECoreType.Xray);
useSystemHosts = item.useSystemHosts;
domainStrategy4Freedom = item?.domainStrategy4Freedom!;
normalDNS = item?.normalDNS!;
var item2 = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
normalDNS2 = item2?.normalDNS!;
tunDNS2 = item2?.tunDNS!;
SaveCmd = ReactiveCommand.Create(() =>
{
SaveSetting();
});
ImportDefConfig4V2rayCmd = ReactiveCommand.Create(() =>
{
normalDNS = Utils.GetEmbedText(Global.DNSV2rayNormalFileName);
});
ImportDefConfig4SingboxCmd = ReactiveCommand.Create(() =>
{
normalDNS2 = Utils.GetEmbedText(Global.DNSSingboxNormalFileName);
tunDNS2 = Utils.GetEmbedText(Global.TunSingboxDNSFileName);
});
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark);
}
private void SaveSetting()
{
if (!Utils.IsNullOrEmpty(normalDNS))
{
var obj = Utils.ParseJson(normalDNS);
if (obj != null && obj.ContainsKey("servers") == true)
{
}
else
{
if (normalDNS.Contains("{") || normalDNS.Contains("}"))
{
UI.Show(ResUI.FillCorrectDNSText);
return;
}
}
}
if (!Utils.IsNullOrEmpty(normalDNS2))
{
var obj2 = Utils.FromJson<Dns4Sbox>(normalDNS2);
if (obj2 == null)
{
UI.Show(ResUI.FillCorrectDNSText);
return;
}
}
if (!Utils.IsNullOrEmpty(tunDNS2))
{
var obj2 = Utils.FromJson<Dns4Sbox>(tunDNS2);
if (obj2 == null)
{
UI.Show(ResUI.FillCorrectDNSText);
return;
}
}
var item = LazyConfig.Instance.GetDNSItem(ECoreType.Xray);
item.domainStrategy4Freedom = domainStrategy4Freedom;
item.useSystemHosts = useSystemHosts;
item.normalDNS = normalDNS;
ConfigHandler.SaveDNSItems(_config, item);
var item2 = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
item2.normalDNS = Utils.ToJson(Utils.ParseJson(normalDNS2));
item2.tunDNS = Utils.ToJson(Utils.ParseJson(tunDNS2));
ConfigHandler.SaveDNSItems(_config, item2);
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
_view.DialogResult = true;
}
}
}

View File

@@ -89,6 +89,8 @@ namespace v2rayN.ViewModels
public ReactiveCommand<Unit, Unit> AddShadowsocksServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddSocksServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddTrojanServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddHysteria2ServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddTuicServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddCustomServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddServerViaClipboardCmd { get; }
public ReactiveCommand<Unit, Unit> AddServerViaScanCmd { get; }
@@ -121,7 +123,6 @@ namespace v2rayN.ViewModels
//servers export
public ReactiveCommand<Unit, Unit> Export2ClientConfigCmd { get; }
public ReactiveCommand<Unit, Unit> Export2ServerConfigCmd { get; }
public ReactiveCommand<Unit, Unit> Export2ShareUrlCmd { get; }
public ReactiveCommand<Unit, Unit> Export2SubContentCmd { get; }
@@ -138,6 +139,7 @@ namespace v2rayN.ViewModels
public ReactiveCommand<Unit, Unit> OptionSettingCmd { get; }
public ReactiveCommand<Unit, Unit> RoutingSettingCmd { get; }
public ReactiveCommand<Unit, Unit> DNSSettingCmd { get; }
public ReactiveCommand<Unit, Unit> GlobalHotkeySettingCmd { get; }
public ReactiveCommand<Unit, Unit> RebootAsAdminCmd { get; }
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
@@ -146,12 +148,15 @@ namespace v2rayN.ViewModels
//CheckUpdate
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateSagerNetCoreCmd { get; }
//public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }
//public ReactiveCommand<Unit, Unit> CheckUpdateSagerNetCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateClashMetaCoreCmd { get; }
//public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
//public ReactiveCommand<Unit, Unit> CheckUpdateClashMetaCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateSingBoxCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateGeoCmd { get; }
public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
@@ -167,8 +172,8 @@ namespace v2rayN.ViewModels
[Reactive]
public ImageSource AppIcon { get; set; }
[Reactive]
public bool BlShowTrayTip { get; set; }
//[Reactive]
//public bool BlShowTrayTip { get; set; }
#endregion Menu
@@ -237,6 +242,9 @@ namespace v2rayN.ViewModels
[Reactive]
public int CurrentFontSize { get; set; }
[Reactive]
public bool FollowSystemTheme { get; set; }
[Reactive]
public string CurrentLanguage { get; set; }
@@ -334,6 +342,14 @@ namespace v2rayN.ViewModels
{
EditServer(true, EConfigType.Trojan);
});
AddHysteria2ServerCmd = ReactiveCommand.Create(() =>
{
EditServer(true, EConfigType.Hysteria2);
});
AddTuicServerCmd = ReactiveCommand.Create(() =>
{
EditServer(true, EConfigType.Tuic);
});
AddCustomServerCmd = ReactiveCommand.Create(() =>
{
EditServer(true, EConfigType.Custom);
@@ -419,10 +435,6 @@ namespace v2rayN.ViewModels
{
Export2ClientConfig();
}, canEditRemove);
Export2ServerConfigCmd = ReactiveCommand.Create(() =>
{
Export2ServerConfig();
}, canEditRemove);
Export2ShareUrlCmd = ReactiveCommand.Create(() =>
{
Export2ShareUrl();
@@ -467,6 +479,10 @@ namespace v2rayN.ViewModels
{
RoutingSetting();
});
DNSSettingCmd = ReactiveCommand.Create(() =>
{
DNSSetting();
});
GlobalHotkeySettingCmd = ReactiveCommand.Create(() =>
{
if ((new GlobalHotkeySettingWindow()).ShowDialog() == true)
@@ -493,26 +509,26 @@ namespace v2rayN.ViewModels
{
CheckUpdateN();
});
CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
{
CheckUpdateCore(ECoreType.v2fly_v5);
});
CheckUpdateSagerNetCoreCmd = ReactiveCommand.Create(() =>
{
CheckUpdateCore(ECoreType.SagerNet);
});
//CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
//{
// CheckUpdateCore(ECoreType.v2fly_v5);
//});
//CheckUpdateSagerNetCoreCmd = ReactiveCommand.Create(() =>
//{
// CheckUpdateCore(ECoreType.SagerNet);
//});
CheckUpdateXrayCoreCmd = ReactiveCommand.Create(() =>
{
CheckUpdateCore(ECoreType.Xray);
});
CheckUpdateClashCoreCmd = ReactiveCommand.Create(() =>
{
CheckUpdateCore(ECoreType.clash);
});
CheckUpdateClashMetaCoreCmd = ReactiveCommand.Create(() =>
{
CheckUpdateCore(ECoreType.clash_meta);
});
//CheckUpdateClashCoreCmd = ReactiveCommand.Create(() =>
//{
// CheckUpdateCore(ECoreType.clash);
//});
//CheckUpdateClashMetaCoreCmd = ReactiveCommand.Create(() =>
//{
// CheckUpdateCore(ECoreType.clash_meta);
//});
CheckUpdateSingBoxCoreCmd = ReactiveCommand.Create(() =>
{
CheckUpdateCore(ECoreType.sing_box);
@@ -555,9 +571,10 @@ namespace v2rayN.ViewModels
private void Init()
{
ConfigHandler.InitBuiltinRouting(ref _config);
//MainFormHandler.Instance.BackupGuiNConfig(_config, true);
_coreHandler = new CoreHandler(UpdateHandler);
ConfigHandler.InitBuiltinRouting(_config);
ConfigHandler.InitBuiltinDNS(_config);
_coreHandler = new CoreHandler(_config, UpdateHandler);
Locator.CurrentMutable.RegisterLazySingleton(() => _coreHandler, typeof(CoreHandler));
if (_config.guiItem.enableStatistics)
{
@@ -617,8 +634,8 @@ namespace v2rayN.ViewModels
return;
}
SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, Global.agentTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown));
SpeedDirectDisplay = string.Format(ResUI.SpeedDisplayText, Global.directTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown));
SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, Global.ProxyTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown));
SpeedDirectDisplay = string.Format(ResUI.SpeedDisplayText, Global.DirectTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown));
if (update.proxyUp + update.proxyDown > 0)
{
@@ -720,7 +737,7 @@ namespace v2rayN.ViewModels
Utils.SaveLog("MyAppExit Begin");
StorageUI();
ConfigHandler.SaveConfig(ref _config);
ConfigHandler.SaveConfig(_config);
//HttpProxyHandle.CloseHttpAgent(config);
if (blWindowsShutDown)
@@ -840,7 +857,7 @@ namespace v2rayN.ViewModels
RefreshServersMenu();
//display running server
var running = ConfigHandler.GetDefaultServer(ref _config);
var running = ConfigHandler.GetDefaultServer(_config);
if (running != null)
{
var runningSummary = running.GetSummary();
@@ -849,7 +866,7 @@ namespace v2rayN.ViewModels
}
else
{
RunningServerDisplay =
RunningServerDisplay = ResUI.CheckServerSettings;
RunningServerToolTipText = ResUI.CheckServerSettings;
}
}));
@@ -939,6 +956,7 @@ namespace v2rayN.ViewModels
{
subid = _subId,
configType = eConfigType,
isSub = false,
};
}
else
@@ -977,7 +995,7 @@ namespace v2rayN.ViewModels
public void AddServerViaClipboard()
{
var clipboardData = Utils.GetClipboardData();
int ret = ConfigHandler.AddBatchServers(ref _config, clipboardData!, _subId, false);
int ret = ConfigHandler.AddBatchServers(_config, clipboardData!, _subId, false);
if (ret > 0)
{
InitSubscriptionView();
@@ -1004,7 +1022,7 @@ namespace v2rayN.ViewModels
}
else
{
int ret = ConfigHandler.AddBatchServers(ref _config, result, _subId, false);
int ret = ConfigHandler.AddBatchServers(_config, result, _subId, false);
if (ret > 0)
{
InitSubscriptionView();
@@ -1051,7 +1069,7 @@ namespace v2rayN.ViewModels
{
return;
}
if (ConfigHandler.CopyServer(ref _config, lstSelecteds) == 0)
if (ConfigHandler.CopyServer(_config, lstSelecteds) == 0)
{
RefreshServers();
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
@@ -1084,7 +1102,7 @@ namespace v2rayN.ViewModels
return;
}
if (ConfigHandler.SetDefaultServerIndex(ref _config, indexId) == 0)
if (ConfigHandler.SetDefaultServerIndex(_config, indexId) == 0)
{
RefreshServers();
Reload();
@@ -1140,7 +1158,7 @@ namespace v2rayN.ViewModels
_dicHeaderSort.TryAdd(colName, true);
_dicHeaderSort.TryGetValue(colName, out bool asc);
if (ConfigHandler.SortServers(ref _config, _subId, colName, asc) != 0)
if (ConfigHandler.SortServers(_config, _subId, colName, asc) != 0)
{
return;
}
@@ -1150,7 +1168,7 @@ namespace v2rayN.ViewModels
public void TestServerAvailability()
{
var item = ConfigHandler.GetDefaultServer(ref _config);
var item = ConfigHandler.GetDefaultServer(_config);
if (item == null || item.configType == EConfigType.Custom)
{
return;
@@ -1204,7 +1222,7 @@ namespace v2rayN.ViewModels
{
return;
}
if (ConfigHandler.MoveServer(ref _config, ref _lstProfile, index, eMove) == 0)
if (ConfigHandler.MoveServer(_config, ref _lstProfile, index, eMove) == 0)
{
RefreshServers();
}
@@ -1215,7 +1233,7 @@ namespace v2rayN.ViewModels
var targetIndex = _profileItems.IndexOf(targetItem);
if (startIndex >= 0 && targetIndex >= 0 && startIndex != targetIndex)
{
if (ConfigHandler.MoveServer(ref _config, ref _lstProfile, startIndex, EMove.Position, targetIndex) == 0)
if (ConfigHandler.MoveServer(_config, ref _lstProfile, startIndex, EMove.Position, targetIndex) == 0)
{
RefreshServers();
}
@@ -1247,17 +1265,6 @@ namespace v2rayN.ViewModels
MainFormHandler.Instance.Export2ClientConfig(item, _config);
}
private void Export2ServerConfig()
{
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
if (item is null)
{
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
return;
}
MainFormHandler.Instance.Export2ServerConfig(item, _config);
}
public void Export2ShareUrl()
{
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
@@ -1348,7 +1355,6 @@ namespace v2rayN.ViewModels
{
//RefreshServers();
Reload();
TunModeSwitch();
}
}
@@ -1357,13 +1363,22 @@ namespace v2rayN.ViewModels
var ret = (new RoutingSettingWindow()).ShowDialog();
if (ret == true)
{
ConfigHandler.InitBuiltinRouting(ref _config);
ConfigHandler.InitBuiltinRouting(_config);
RefreshRoutingsMenu();
//RefreshServers();
Reload();
}
}
private void DNSSetting()
{
var ret = (new DNSSettingWindow()).ShowDialog();
if (ret == true)
{
Reload();
}
}
private void RebootAsAdmin()
{
ProcessStartInfo startInfo = new()
@@ -1399,7 +1414,7 @@ namespace v2rayN.ViewModels
return;
}
var ret = ConfigHandler.ImportOldGuiConfig(ref _config, fileName);
var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
if (ret == 0)
{
RefreshRoutingsMenu();
@@ -1462,12 +1477,7 @@ namespace v2rayN.ViewModels
private void CheckUpdateGeo()
{
Task.Run(() =>
{
var updateHandle = new UpdateHandle();
updateHandle.UpdateGeoFile("geosite", _config, UpdateTaskHandler);
updateHandle.UpdateGeoFile("geoip", _config, UpdateTaskHandler);
});
(new UpdateHandle()).UpdateGeoFileAll(_config, UpdateTaskHandler);
}
#endregion CheckUpdate
@@ -1486,15 +1496,11 @@ namespace v2rayN.ViewModels
BlReloadEnabled = false;
}));
//if (Global.reloadV2ray)
//{
// _noticeHandler?.SendMessage(Global.CommandClearMsg);
//}
await Task.Run(() =>
{
_coreHandler.LoadCore(_config);
_coreHandler.LoadCore();
//ConfigHandler.SaveConfig(ref _config, false);
//ConfigHandler.SaveConfig(_config, false);
ChangeSystemProxyStatus(_config.sysProxyType, false);
});
@@ -1509,7 +1515,7 @@ namespace v2rayN.ViewModels
private void CloseV2ray()
{
ConfigHandler.SaveConfig(ref _config, false);
ConfigHandler.SaveConfig(_config, false);
ChangeSystemProxyStatus(ESysProxyType.ForcedClear, false);
@@ -1530,13 +1536,13 @@ namespace v2rayN.ViewModels
ChangeSystemProxyStatus(type, true);
SystemProxySelected = (int)_config.sysProxyType;
ConfigHandler.SaveConfig(ref _config, false);
ConfigHandler.SaveConfig(_config, false);
}
private void ChangeSystemProxyStatus(ESysProxyType type, bool blChange)
{
SysProxyHandle.UpdateSysProxy(_config, false);
_noticeHandler?.SendMessage(ResUI.TipChangeSystemProxy, true);
SysProxyHandle.UpdateSysProxy(_config, _config.tunModeItem.enableTun ? true : false);
_noticeHandler?.SendMessage(ResUI.TipChangeSystemProxy + _config.sysProxyType.ToString(), true);
Application.Current.Dispatcher.Invoke((Action)(() =>
{
@@ -1598,7 +1604,7 @@ namespace v2rayN.ViewModels
return;
}
if (ConfigHandler.SetDefaultRouting(ref _config, item) == 0)
if (ConfigHandler.SetDefaultRouting(_config, item) == 0)
{
_noticeHandler?.SendMessage(ResUI.TipChangeRouting, true);
Reload();
@@ -1623,19 +1629,7 @@ namespace v2rayN.ViewModels
if (_config.tunModeItem.enableTun != EnableTun)
{
_config.tunModeItem.enableTun = EnableTun;
}
TunModeSwitch();
}
private void TunModeSwitch()
{
if (EnableTun)
{
TunHandler.Instance.Start();
}
else
{
TunHandler.Instance.Stop();
Reload();
}
}
@@ -1669,7 +1663,14 @@ namespace v2rayN.ViewModels
private void RestoreUI()
{
ModifyTheme(_config.uiItem.colorModeDark);
if (FollowSystemTheme)
{
ModifyTheme(!Utils.IsLightTheme());
}
else
{
ModifyTheme(_config.uiItem.colorModeDark);
}
if (!_config.uiItem.colorPrimaryName.IsNullOrEmpty())
{
@@ -1690,6 +1691,7 @@ namespace v2rayN.ViewModels
private void BindingUI()
{
ColorModeDark = _config.uiItem.colorModeDark;
FollowSystemTheme = _config.uiItem.followSystemTheme;
_swatches.AddRange(new SwatchesProvider().Swatches);
if (!_config.uiItem.colorPrimaryName.IsNullOrEmpty())
{
@@ -1697,7 +1699,7 @@ namespace v2rayN.ViewModels
}
CurrentFontSize = _config.uiItem.currentFontSize;
CurrentLanguage = _config.uiItem.currentLanguage;
BlShowTrayTip = _config.uiItem.showTrayTip;
//BlShowTrayTip = _config.uiItem.showTrayTip;
this.WhenAnyValue(
x => x.ColorModeDark,
@@ -1708,10 +1710,25 @@ namespace v2rayN.ViewModels
{
_config.uiItem.colorModeDark = ColorModeDark;
ModifyTheme(ColorModeDark);
ConfigHandler.SaveConfig(ref _config);
ConfigHandler.SaveConfig(_config);
}
});
this.WhenAnyValue(x => x.FollowSystemTheme,
y => y == true)
.Subscribe(c =>
{
if (_config.uiItem.followSystemTheme != FollowSystemTheme)
{
_config.uiItem.followSystemTheme = FollowSystemTheme;
ConfigHandler.SaveConfig(_config);
if (FollowSystemTheme)
{
ModifyTheme(!Utils.IsLightTheme());
}
}
});
this.WhenAnyValue(
x => x.SelectedSwatch,
y => y != null && !y.Name.IsNullOrEmpty())
@@ -1728,7 +1745,7 @@ namespace v2rayN.ViewModels
{
_config.uiItem.colorPrimaryName = SelectedSwatch?.Name;
ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color);
ConfigHandler.SaveConfig(ref _config);
ConfigHandler.SaveConfig(_config);
}
});
@@ -1746,7 +1763,7 @@ namespace v2rayN.ViewModels
Application.Current.Resources["StdFontSize2"] = size + 2;
Application.Current.Resources["StdFontSizeMsg"] = size - 1;
ConfigHandler.SaveConfig(ref _config);
ConfigHandler.SaveConfig(_config);
}
});
@@ -1759,7 +1776,7 @@ namespace v2rayN.ViewModels
{
_config.uiItem.currentLanguage = CurrentLanguage;
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
ConfigHandler.SaveConfig(ref _config);
ConfigHandler.SaveConfig(_config);
}
});
}
@@ -1826,7 +1843,7 @@ namespace v2rayN.ViewModels
if (_config.uiItem.autoHideStartup)
{
Observable.Range(1, 1)
.Delay(TimeSpan.FromSeconds(1))
.Delay(TimeSpan.FromSeconds(2))
.Subscribe(x =>
{
Application.Current.Dispatcher.Invoke(() =>

View File

@@ -31,16 +31,12 @@ namespace v2rayN.ViewModels
[Reactive] public bool defAllowInsecure { get; set; }
[Reactive] public string defFingerprint { get; set; }
[Reactive] public string defUserAgent { get; set; }
[Reactive] public string mux4SboxProtocol { get; set; }
[Reactive] public int hyUpMbps { get; set; }
[Reactive] public int hyDownMbps { get; set; }
#endregion Core
#region Core DNS
[Reactive] public string domainStrategy4Freedom { get; set; }
[Reactive] public string remoteDNS { get; set; }
#endregion Core DNS
#region Core KCP
//[Reactive] public int Kcpmtu { get; set; }
@@ -57,7 +53,6 @@ namespace v2rayN.ViewModels
[Reactive] public bool AutoRun { get; set; }
[Reactive] public bool EnableStatistics { get; set; }
[Reactive] public int StatisticsFreshRate { get; set; }
[Reactive] public bool KeepOlderDedupl { get; set; }
[Reactive] public bool IgnoreGeoUpdateCore { get; set; }
[Reactive] public bool EnableAutoAdjustMainLvColWidth { get; set; }
@@ -85,20 +80,11 @@ namespace v2rayN.ViewModels
#region Tun mode
[Reactive] public bool TunShowWindow { get; set; }
[Reactive] public bool TunEnabledLog { get; set; }
[Reactive] public bool TunStrictRoute { get; set; }
[Reactive] public string TunStack { get; set; }
[Reactive] public int TunMtu { get; set; }
[Reactive] public string TunCustomTemplate { get; set; }
[Reactive] public bool TunBypassMode { get; set; }
[Reactive] public bool TunBypassMode2 { get; set; }
[Reactive] public string TunDirectIP { get; set; }
[Reactive] public string TunDirectProcess { get; set; }
[Reactive] public string TunDirectDNS { get; set; }
[Reactive] public string TunProxyIP { get; set; }
[Reactive] public string TunProxyProcess { get; set; }
[Reactive] public string TunProxyDNS { get; set; }
[Reactive] public bool TunEnableExInbound { get; set; }
[Reactive] public bool TunEnableIPv6Address { get; set; }
#endregion Tun mode
@@ -138,16 +124,12 @@ namespace v2rayN.ViewModels
defAllowInsecure = _config.coreBasicItem.defAllowInsecure;
defFingerprint = _config.coreBasicItem.defFingerprint;
defUserAgent = _config.coreBasicItem.defUserAgent;
mux4SboxProtocol = _config.mux4SboxItem.protocol;
hyUpMbps = _config.hysteriaItem.up_mbps;
hyDownMbps = _config.hysteriaItem.down_mbps;
#endregion Core
#region Core DNS
domainStrategy4Freedom = _config.domainStrategy4Freedom;
remoteDNS = _config.remoteDNS;
#endregion Core DNS
#region Core KCP
//Kcpmtu = _config.kcpItem.mtu;
@@ -164,7 +146,6 @@ namespace v2rayN.ViewModels
AutoRun = _config.guiItem.autoRun;
EnableStatistics = _config.guiItem.enableStatistics;
StatisticsFreshRate = _config.guiItem.statisticsFreshRate;
KeepOlderDedupl = _config.guiItem.keepOlderDedupl;
IgnoreGeoUpdateCore = _config.guiItem.ignoreGeoUpdateCore;
EnableAutoAdjustMainLvColWidth = _config.uiItem.enableAutoAdjustMainLvColWidth;
@@ -192,22 +173,11 @@ namespace v2rayN.ViewModels
#region Tun mode
TunShowWindow = _config.tunModeItem.showWindow;
TunEnabledLog = _config.tunModeItem.enabledLog;
TunStrictRoute = _config.tunModeItem.strictRoute;
TunStack = _config.tunModeItem.stack;
TunMtu = _config.tunModeItem.mtu;
TunCustomTemplate = _config.tunModeItem.customTemplate;
TunBypassMode = _config.tunModeItem.bypassMode;
TunDirectIP = Utils.List2String(_config.tunModeItem.directIP, true);
TunDirectProcess = Utils.List2String(_config.tunModeItem.directProcess, true);
TunDirectDNS = _config.tunModeItem.directDNS;
TunProxyIP = Utils.List2String(_config.tunModeItem.proxyIP, true);
TunProxyProcess = Utils.List2String(_config.tunModeItem.proxyProcess, true);
TunProxyDNS = _config.tunModeItem.proxyDNS;
this.WhenAnyValue(
x => x.TunBypassMode)
.Subscribe(c => TunBypassMode2 = !TunBypassMode);
TunEnableExInbound = _config.tunModeItem.enableExInbound;
TunEnableIPv6Address = _config.tunModeItem.enableIPv6Address;
#endregion Tun mode
@@ -282,19 +252,6 @@ namespace v2rayN.ViewModels
return;
}
var obj = Utils.ParseJson(remoteDNS);
if (obj?.ContainsKey("servers") == true)
{
}
else
{
if (remoteDNS.Contains("{") || remoteDNS.Contains("}"))
{
UI.Show(ResUI.FillCorrectDNSText);
return;
}
}
//if (Utils.IsNullOrEmpty(Kcpmtu.ToString()) || !Utils.IsNumberic(Kcpmtu.ToString())
// || Utils.IsNullOrEmpty(Kcptti.ToString()) || !Utils.IsNumberic(Kcptti.ToString())
// || Utils.IsNullOrEmpty(KcpuplinkCapacity.ToString()) || !Utils.IsNumberic(KcpuplinkCapacity.ToString())
@@ -325,10 +282,9 @@ namespace v2rayN.ViewModels
_config.coreBasicItem.defAllowInsecure = defAllowInsecure;
_config.coreBasicItem.defFingerprint = defFingerprint;
_config.coreBasicItem.defUserAgent = defUserAgent;
//DNS
_config.remoteDNS = remoteDNS;
_config.domainStrategy4Freedom = domainStrategy4Freedom;
_config.mux4SboxItem.protocol = mux4SboxProtocol;
_config.hysteriaItem.up_mbps = hyUpMbps;
_config.hysteriaItem.down_mbps = hyDownMbps;
//Kcp
//_config.kcpItem.mtu = Kcpmtu;
@@ -343,11 +299,6 @@ namespace v2rayN.ViewModels
Utils.SetAutoRun(AutoRun);
_config.guiItem.autoRun = AutoRun;
_config.guiItem.enableStatistics = EnableStatistics;
_config.guiItem.statisticsFreshRate = StatisticsFreshRate;
if (_config.guiItem.statisticsFreshRate > 100 || _config.guiItem.statisticsFreshRate < 1)
{
_config.guiItem.statisticsFreshRate = 1;
}
_config.guiItem.keepOlderDedupl = KeepOlderDedupl;
_config.guiItem.ignoreGeoUpdateCore = IgnoreGeoUpdateCore;
_config.uiItem.enableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth;
@@ -369,24 +320,16 @@ namespace v2rayN.ViewModels
_config.systemProxyAdvancedProtocol = systemProxyAdvancedProtocol;
//tun mode
_config.tunModeItem.showWindow = TunShowWindow;
_config.tunModeItem.enabledLog = TunEnabledLog;
_config.tunModeItem.strictRoute = TunStrictRoute;
_config.tunModeItem.stack = TunStack;
_config.tunModeItem.mtu = TunMtu;
_config.tunModeItem.customTemplate = TunCustomTemplate;
_config.tunModeItem.bypassMode = TunBypassMode;
_config.tunModeItem.directIP = Utils.String2List(TunDirectIP);
_config.tunModeItem.directProcess = Utils.String2List(TunDirectProcess);
_config.tunModeItem.directDNS = Utils.ToJson(Utils.ParseJson(TunDirectDNS));
_config.tunModeItem.proxyIP = Utils.String2List(TunProxyIP);
_config.tunModeItem.proxyProcess = Utils.String2List(TunProxyProcess);
_config.tunModeItem.proxyDNS = Utils.ToJson(Utils.ParseJson(TunProxyDNS));
_config.tunModeItem.enableExInbound = TunEnableExInbound;
_config.tunModeItem.enableIPv6Address = TunEnableIPv6Address;
//coreType
SaveCoreType();
if (ConfigHandler.SaveConfig(ref _config) == 0)
if (ConfigHandler.SaveConfig(_config) == 0)
{
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
_view.DialogResult = true;
@@ -428,6 +371,10 @@ namespace v2rayN.ViewModels
case 6:
type = CoreType6;
break;
case 7:
case 8:
continue;
}
item.coreType = (ECoreType)Enum.Parse(typeof(ECoreType), type);
}

View File

@@ -28,6 +28,9 @@ namespace v2rayN.ViewModels
[Reactive]
public string IP { get; set; }
[Reactive]
public string Process { get; set; }
[Reactive]
public bool AutoSort { get; set; }
@@ -42,7 +45,7 @@ namespace v2rayN.ViewModels
if (rulesItem.id.IsNullOrEmpty())
{
rulesItem.id = Utils.GetGUID(false);
rulesItem.outboundTag = Global.agentTag;
rulesItem.outboundTag = Global.ProxyTag;
rulesItem.enabled = true;
SelectedSource = rulesItem;
}
@@ -53,6 +56,7 @@ namespace v2rayN.ViewModels
Domain = Utils.List2String(SelectedSource.domain, true);
IP = Utils.List2String(SelectedSource.ip, true);
Process = Utils.List2String(SelectedSource.process, true);
SaveCmd = ReactiveCommand.Create(() =>
{
@@ -64,31 +68,34 @@ namespace v2rayN.ViewModels
private void SaveRules()
{
Domain = Utils.Convert2Comma(Domain);
IP = Utils.Convert2Comma(IP);
Process = Utils.Convert2Comma(Process);
if (AutoSort)
{
SelectedSource.domain = Utils.String2ListSorted(Domain);
SelectedSource.ip = Utils.String2ListSorted(IP);
SelectedSource.process = Utils.String2ListSorted(Process);
}
else
{
SelectedSource.domain = Utils.String2List(Domain);
SelectedSource.ip = Utils.String2List(IP);
SelectedSource.process = Utils.String2List(Process);
}
SelectedSource.protocol = ProtocolItems?.ToList();
SelectedSource.inboundTag = InboundTagItems?.ToList();
bool hasRule =
SelectedSource.domain != null
&& SelectedSource.domain.Count > 0
|| SelectedSource.ip != null
&& SelectedSource.ip.Count > 0
|| SelectedSource.protocol != null
&& SelectedSource.protocol.Count > 0
bool hasRule = SelectedSource.domain?.Count > 0
|| SelectedSource.ip?.Count > 0
|| SelectedSource.protocol?.Count > 0
|| SelectedSource.process?.Count > 0
|| !Utils.IsNullOrEmpty(SelectedSource.port);
if (!hasRule)
{
UI.ShowWarning(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP"));
UI.ShowWarning(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP/Process"));
return;
}
//_noticeHandler?.Enqueue(ResUI.OperationSuccess);

View File

@@ -167,7 +167,7 @@ namespace v2rayN.ViewModels
}
}
private void RuleRemove()
public void RuleRemove()
{
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
{
@@ -250,7 +250,7 @@ namespace v2rayN.ViewModels
item.ruleNum = _rules.Count;
item.ruleSet = Utils.ToJson(_rules, false);
if (ConfigHandler.SaveRoutingItem(ref _config, item) == 0)
if (ConfigHandler.SaveRoutingItem(_config, item) == 0)
{
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
_view.DialogResult = true;

View File

@@ -42,6 +42,9 @@ namespace v2rayN.ViewModels
[Reactive]
public string domainMatcher { get; set; }
[Reactive]
public string domainStrategy4Singbox { get; set; }
[Reactive]
public string ProxyDomain { get; set; }
@@ -78,11 +81,12 @@ namespace v2rayN.ViewModels
_view = view;
SelectedSource = new();
ConfigHandler.InitBuiltinRouting(ref _config);
ConfigHandler.InitBuiltinRouting(_config);
enableRoutingAdvanced = _config.routingBasicItem.enableRoutingAdvanced;
domainStrategy = _config.routingBasicItem.domainStrategy;
domainMatcher = _config.routingBasicItem.domainMatcher;
domainStrategy4Singbox = _config.routingBasicItem.domainStrategy4Singbox;
RefreshRoutingItems();
@@ -130,7 +134,7 @@ namespace v2rayN.ViewModels
private void BindingLockedData()
{
_lockedItem = ConfigHandler.GetLockedRoutingItem(ref _config);
_lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
if (_lockedItem != null)
{
_lockedRules = Utils.FromJson<List<RulesItem>>(_lockedItem.ruleSet);
@@ -149,18 +153,18 @@ namespace v2rayN.ViewModels
{
if (_lockedItem != null)
{
_lockedRules[0].domain = Utils.String2List(ProxyDomain.TrimEx());
_lockedRules[0].ip = Utils.String2List(ProxyIP.TrimEx());
_lockedRules[0].domain = Utils.String2List(Utils.Convert2Comma(ProxyDomain.TrimEx()));
_lockedRules[0].ip = Utils.String2List(Utils.Convert2Comma(ProxyIP.TrimEx()));
_lockedRules[1].domain = Utils.String2List(DirectDomain.TrimEx());
_lockedRules[1].ip = Utils.String2List(DirectIP.TrimEx());
_lockedRules[1].domain = Utils.String2List(Utils.Convert2Comma(DirectDomain.TrimEx()));
_lockedRules[1].ip = Utils.String2List(Utils.Convert2Comma(DirectIP.TrimEx()));
_lockedRules[2].domain = Utils.String2List(BlockDomain.TrimEx());
_lockedRules[2].ip = Utils.String2List(BlockIP.TrimEx());
_lockedRules[2].domain = Utils.String2List(Utils.Convert2Comma(BlockDomain.TrimEx()));
_lockedRules[2].ip = Utils.String2List(Utils.Convert2Comma(BlockIP.TrimEx()));
_lockedItem.ruleSet = Utils.ToJson(_lockedRules, false);
ConfigHandler.SaveRoutingItem(ref _config, _lockedItem);
ConfigHandler.SaveRoutingItem(_config, _lockedItem);
}
}
@@ -200,10 +204,11 @@ namespace v2rayN.ViewModels
_config.routingBasicItem.domainStrategy = domainStrategy;
_config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced;
_config.routingBasicItem.domainMatcher = domainMatcher;
_config.routingBasicItem.domainStrategy4Singbox = domainStrategy4Singbox;
EndBindingLockedData();
if (ConfigHandler.SaveConfig(ref _config) == 0)
if (ConfigHandler.SaveConfig(_config) == 0)
{
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
_view.DialogResult = true;
@@ -251,7 +256,7 @@ namespace v2rayN.ViewModels
}
}
private void RoutingAdvancedRemove()
public void RoutingAdvancedRemove()
{
if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty())
{
@@ -275,7 +280,7 @@ namespace v2rayN.ViewModels
IsModified = true;
}
private void RoutingAdvancedSetDefault()
public void RoutingAdvancedSetDefault()
{
var item = LazyConfig.Instance.GetRoutingItem(SelectedSource?.id);
if (item is null)
@@ -284,7 +289,7 @@ namespace v2rayN.ViewModels
return;
}
if (ConfigHandler.SetDefaultRouting(ref _config, item) == 0)
if (ConfigHandler.SetDefaultRouting(_config, item) == 0)
{
RefreshRoutingItems();
IsModified = true;
@@ -293,7 +298,7 @@ namespace v2rayN.ViewModels
private void RoutingAdvancedImportRules()
{
if (ConfigHandler.InitBuiltinRouting(ref _config, true) == 0)
if (ConfigHandler.InitBuiltinRouting(_config, true) == 0)
{
RefreshRoutingItems();
IsModified = true;

View File

@@ -47,7 +47,7 @@ namespace v2rayN.ViewModels
private void SaveSub()
{
string remarks = SelectedSource.remarks;
if (Utils.IsNullOrEmpty(remarks))
if (string.IsNullOrEmpty(remarks))
{
UI.Show(ResUI.PleaseFillRemarks);
return;
@@ -69,9 +69,11 @@ namespace v2rayN.ViewModels
item.sort = SelectedSource.sort;
item.filter = SelectedSource.filter;
item.convertTarget = SelectedSource.convertTarget;
item.prevProfile = SelectedSource.prevProfile;
item.nextProfile = SelectedSource.nextProfile;
}
if (ConfigHandler.AddSubItem(ref _config, item) == 0)
if (ConfigHandler.AddSubItem(_config, item) == 0)
{
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
_view.DialogResult = true;

View File

@@ -104,7 +104,7 @@ namespace v2rayN.ViewModels
foreach (var it in SelectedSources)
{
ConfigHandler.DeleteSubItem(ref _config, it?.id);
ConfigHandler.DeleteSubItem(_config, it?.id);
}
RefreshSubItems();
_noticeHandler?.Enqueue(ResUI.OperationSuccess);

View File

@@ -97,17 +97,17 @@
Grid.Row="2"
Grid.Column="2"
VerticalAlignment="Center"
Orientation="Vertical">
Orientation="Horizontal">
<Button
x:Name="btnBrowse"
Width="100"
Margin="2,0,8,0"
Width="80"
Margin="2,0"
Content="{x:Static resx:ResUI.TbBrowse}"
Style="{StaticResource DefButton}" />
<Button
x:Name="btnEdit"
Width="100"
Margin="2,2,8,0"
Width="80"
Margin="2,0"
Content="{x:Static resx:ResUI.TbEdit}"
Style="{StaticResource DefButton}" />
</StackPanel>
@@ -126,9 +126,8 @@
Width="200"
Margin="4"
HorizontalAlignment="Left"
FontSize="{DynamicResource StdFontSize}"
MaxDropDownHeight="1000"
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
Style="{StaticResource MyOutlinedTextComboBox}" />
<TextBlock
Grid.Row="4"

View File

@@ -11,6 +11,17 @@ namespace v2rayN.Views
public AddServer2Window(ProfileItem profileItem)
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
this.Loaded += Window_Loaded;
ViewModel = new AddServer2ViewModel(profileItem, this);

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,17 @@ namespace v2rayN.Views
public AddServerWindow(ProfileItem profileItem)
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
this.Loaded += Window_Loaded;
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
@@ -24,14 +35,14 @@ namespace v2rayN.Views
if (profileItem.configType == EConfigType.VLESS)
{
Global.coreTypes4VLESS.ForEach(it =>
Global.CoreTypes4VLESS.ForEach(it =>
{
cmbCoreType.Items.Add(it);
});
}
else
{
Global.coreTypes.ForEach(it =>
Global.CoreTypes.ForEach(it =>
{
cmbCoreType.Items.Add(it);
});
@@ -41,20 +52,20 @@ namespace v2rayN.Views
cmbStreamSecurity.Items.Add(string.Empty);
cmbStreamSecurity.Items.Add(Global.StreamSecurity);
Global.networks.ForEach(it =>
Global.Networks.ForEach(it =>
{
cmbNetwork.Items.Add(it);
});
Global.fingerprints.ForEach(it =>
Global.Fingerprints.ForEach(it =>
{
cmbFingerprint.Items.Add(it);
cmbFingerprint2.Items.Add(it);
});
Global.allowInsecures.ForEach(it =>
Global.AllowInsecures.ForEach(it =>
{
cmbAllowInsecure.Items.Add(it);
});
Global.alpns.ForEach(it =>
Global.Alpns.ForEach(it =>
{
cmbAlpn.Items.Add(it);
});
@@ -63,7 +74,7 @@ namespace v2rayN.Views
{
case EConfigType.VMess:
gridVMess.Visibility = Visibility.Visible;
Global.vmessSecuritys.ForEach(it =>
Global.VmessSecuritys.ForEach(it =>
{
cmbSecurity.Items.Add(it);
});
@@ -88,7 +99,7 @@ namespace v2rayN.Views
case EConfigType.VLESS:
gridVLESS.Visibility = Visibility.Visible;
cmbStreamSecurity.Items.Add(Global.StreamSecurityReality);
Global.flows.ForEach(it =>
Global.Flows.ForEach(it =>
{
cmbFlow5.Items.Add(it);
});
@@ -100,11 +111,35 @@ namespace v2rayN.Views
case EConfigType.Trojan:
gridTrojan.Visibility = Visibility.Visible;
Global.flows.ForEach(it =>
cmbStreamSecurity.Items.Add(Global.StreamSecurityReality);
Global.Flows.ForEach(it =>
{
cmbFlow6.Items.Add(it);
});
break;
case EConfigType.Hysteria2:
gridHysteria2.Visibility = Visibility.Visible;
sepa2.Visibility = Visibility.Collapsed;
gridTransport.Visibility = Visibility.Collapsed;
cmbCoreType.IsEnabled = false;
cmbFingerprint.IsEnabled = false;
cmbFingerprint.Text = string.Empty;
break;
case EConfigType.Tuic:
gridTuic.Visibility = Visibility.Visible;
sepa2.Visibility = Visibility.Collapsed;
gridTransport.Visibility = Visibility.Collapsed;
cmbCoreType.IsEnabled = false;
cmbFingerprint.IsEnabled = false;
cmbFingerprint.Text = string.Empty;
Global.TuicCongestionControls.ForEach(it =>
{
cmbHeaderType8.Items.Add(it);
});
break;
}
gridTlsMore.Visibility = Visibility.Hidden;
@@ -144,6 +179,16 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId6.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.flow, v => v.cmbFlow6.Text).DisposeWith(disposables);
break;
case EConfigType.Hysteria2:
this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId7.Text).DisposeWith(disposables);
break;
case EConfigType.Tuic:
this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId8.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity8.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType8.Text).DisposeWith(disposables);
break;
}
this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType.Text).DisposeWith(disposables);
@@ -224,7 +269,7 @@ namespace v2rayN.Views
else if (network is "kcp" or "quic")
{
cmbHeaderType.Items.Add(Global.None);
Global.kcpHeaderTypes.ForEach(it =>
Global.KcpHeaderTypes.ForEach(it =>
{
cmbHeaderType.Items.Add(it);
});

View File

@@ -0,0 +1,170 @@
<reactiveui:ReactiveWindow
x:Class="v2rayN.Views.DNSSettingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net"
xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="{x:Static resx:ResUI.menuDNSSetting}"
Width="1000"
Height="700"
x:TypeArguments="vms:DNSSettingViewModel"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
ResizeMode="NoResize"
ShowInTaskbar="False"
TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextOptions.TextFormattingMode="Display"
TextOptions.TextRenderingMode="Auto"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<DockPanel Margin="8">
<Grid HorizontalAlignment="Center" DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Button
x:Name="btnSave"
Grid.Column="0"
Margin="4"
Content="{x:Static resx:ResUI.TbConfirm}"
Cursor="Hand"
Style="{StaticResource DefButton}" />
<Button
x:Name="btnCancel"
Grid.Column="1"
Margin="4"
Click="btnCancel_Click"
Content="{x:Static resx:ResUI.TbCancel}"
Cursor="Hand"
IsCancel="true"
Style="{StaticResource DefButton}" />
</Grid>
<TabControl HorizontalContentAlignment="Left">
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDns}">
<DockPanel Margin="{StaticResource SettingItemMargin}">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsDomainStrategy4Freedom}" />
<ComboBox
x:Name="cmbdomainStrategy4Freedom"
Width="200"
Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource DefComboBox}" />
</StackPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsUseSystemHosts}" />
<ToggleButton
x:Name="togUseSystemHosts"
Grid.Row="5"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
</StackPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsRemoteDNS}" />
<TextBlock
Margin="8,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkDnsObjectDoc_Click">
<TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" />
</Hyperlink>
</TextBlock>
<Button
x:Name="btnImportDefConfig4V2ray"
Margin="8,0,0,0"
Content="{x:Static resx:ResUI.TbSettingDnsImportDefConfig}"
Cursor="Hand"
Style="{StaticResource DefButton}" />
</StackPanel>
<TextBox
x:Name="txtnormalDNS"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Stretch"
materialDesign:HintAssist.Hint="Http/Socks"
AcceptsReturn="True"
BorderThickness="1"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</DockPanel>
</TabItem>
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDnsSingbox}">
<DockPanel Margin="{StaticResource SettingItemMargin}">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock
Margin="8,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkDnsSingboxObjectDoc_Click">
<TextBlock Text="{x:Static resx:ResUI.TbDnsSingboxObjectDoc}" />
</Hyperlink>
</TextBlock>
<Button
x:Name="btnImportDefConfig4Singbox"
Margin="8,0,0,0"
Content="{x:Static resx:ResUI.TbSettingDnsImportDefConfig}"
Cursor="Hand"
Style="{StaticResource DefButton}" />
</StackPanel>
<Grid Margin="{StaticResource SettingItemMargin}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBox
x:Name="txtnormalDNS2"
Grid.Column="0"
VerticalAlignment="Stretch"
materialDesign:HintAssist.Hint="Http/Socks"
AcceptsReturn="True"
BorderThickness="1"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
<TextBox
x:Name="txttunDNS2"
Grid.Column="2"
VerticalAlignment="Stretch"
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.TbSettingsTunMode}"
AcceptsReturn="True"
BorderThickness="1"
Style="{StaticResource MaterialDesignOutlinedTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</Grid>
</DockPanel>
</TabItem>
</TabControl>
</DockPanel>
</reactiveui:ReactiveWindow>

View File

@@ -0,0 +1,67 @@
using ReactiveUI;
using System.Reactive.Disposables;
using System.Windows;
using v2rayN.Handler;
using v2rayN.Mode;
using v2rayN.ViewModels;
namespace v2rayN.Views
{
public partial class DNSSettingWindow
{
private static Config _config;
public DNSSettingWindow()
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
_config = LazyConfig.Instance.GetConfig();
ViewModel = new DNSSettingViewModel(this);
Global.DomainStrategy4Freedoms.ForEach(it =>
{
cmbdomainStrategy4Freedom.Items.Add(it);
});
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, vm => vm.useSystemHosts, v => v.togUseSystemHosts.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.normalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.normalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.tunDNS2, v => v.txttunDNS2.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables);
});
}
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
{
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject");
}
private void linkDnsSingboxObjectDoc_Click(object sender, RoutedEventArgs e)
{
Utils.ProcessStart("https://sing-box.sagernet.org/zh/configuration/dns/");
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@@ -72,7 +72,8 @@
VerticalAlignment="Top"
AcceptsReturn="True"
IsReadOnly="True"
Style="{StaticResource MyOutlinedTextBox}" />
Style="{StaticResource MyOutlinedTextBox}"
PreviewKeyDown="TxtGlobalHotkey_PreviewKeyDown" />
<TextBlock
Grid.Row="2"
@@ -89,7 +90,8 @@
VerticalAlignment="Top"
AcceptsReturn="True"
IsReadOnly="True"
Style="{StaticResource MyOutlinedTextBox}" />
Style="{StaticResource MyOutlinedTextBox}"
PreviewKeyDown="TxtGlobalHotkey_PreviewKeyDown" />
<TextBlock
Grid.Row="3"
@@ -106,7 +108,8 @@
VerticalAlignment="Top"
AcceptsReturn="True"
IsReadOnly="True"
Style="{StaticResource MyOutlinedTextBox}" />
Style="{StaticResource MyOutlinedTextBox}"
PreviewKeyDown="TxtGlobalHotkey_PreviewKeyDown" />
<TextBlock
Grid.Row="4"
Grid.Column="0"
@@ -122,7 +125,8 @@
VerticalAlignment="Top"
AcceptsReturn="True"
IsReadOnly="True"
Style="{StaticResource MyOutlinedTextBox}" />
Style="{StaticResource MyOutlinedTextBox}"
PreviewKeyDown="TxtGlobalHotkey_PreviewKeyDown" />
<TextBlock
Grid.Row="5"
Grid.Column="0"
@@ -138,7 +142,8 @@
VerticalAlignment="Top"
AcceptsReturn="True"
IsReadOnly="True"
Style="{StaticResource MyOutlinedTextBox}" />
Style="{StaticResource MyOutlinedTextBox}"
PreviewKeyDown="TxtGlobalHotkey_PreviewKeyDown" />
</Grid>
<TextBlock

View File

@@ -16,15 +16,26 @@ namespace v2rayN.Views
public GlobalHotkeySettingWindow()
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
_config = LazyConfig.Instance.GetConfig();
_config.globalHotkeys ??= new List<KeyEventItem>();
txtGlobalHotkey0.KeyDown += TxtGlobalHotkey_KeyDown;
txtGlobalHotkey1.KeyDown += TxtGlobalHotkey_KeyDown;
txtGlobalHotkey2.KeyDown += TxtGlobalHotkey_KeyDown;
txtGlobalHotkey3.KeyDown += TxtGlobalHotkey_KeyDown;
txtGlobalHotkey4.KeyDown += TxtGlobalHotkey_KeyDown;
txtGlobalHotkey0.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
txtGlobalHotkey1.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
txtGlobalHotkey2.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
txtGlobalHotkey3.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
txtGlobalHotkey4.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
HotkeyHandler.Instance.IsPause = true;
this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false;
@@ -45,7 +56,7 @@ namespace v2rayN.Views
BindingData();
}
private void TxtGlobalHotkey_KeyDown(object sender, KeyEventArgs e)
private void TxtGlobalHotkey_PreviewKeyDown(object sender, KeyEventArgs e)
{
e.Handled = true;
var _ModifierKeys = new Key[] { Key.LeftCtrl, Key.RightCtrl, Key.LeftShift,
@@ -101,7 +112,7 @@ namespace v2rayN.Views
{
_config.globalHotkeys = _TextBoxKeyEventItem.Values.ToList();
if (ConfigHandler.SaveConfig(ref _config, false) == 0)
if (ConfigHandler.SaveConfig(_config, false) == 0)
{
HotkeyHandler.Instance.ReLoad();
this.DialogResult = true;

View File

@@ -15,8 +15,6 @@
Title="v2rayN"
Width="900"
Height="700"
MinWidth="900"
MinHeight="700"
x:TypeArguments="vms:MainWindowViewModel"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
@@ -85,6 +83,14 @@
x:Name="menuAddTrojanServer"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuAddTrojanServer}" />
<MenuItem
x:Name="menuAddHysteria2Server"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuAddHysteria2Server}" />
<MenuItem
x:Name="menuAddTuicServer"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuAddTuicServer}" />
<Separator Margin="-40,5" />
<MenuItem
x:Name="menuAddServerViaClipboard"
@@ -151,6 +157,10 @@
x:Name="menuRoutingSetting"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuRoutingSetting}" />
<MenuItem
x:Name="menuDNSSetting"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuDNSSetting}" />
<MenuItem
x:Name="menuGlobalHotkeySetting"
Height="{StaticResource MenuItemHeight}"
@@ -205,20 +215,20 @@
<MenuItem
x:Name="menuCheckUpdateN"
Height="{StaticResource MenuItemHeight}"
Header="v2rayN" />
<MenuItem
Header="V2rayN" />
<!--<MenuItem
x:Name="menuCheckUpdateV2flyCore"
Height="{StaticResource MenuItemHeight}"
Header="V2fly v5 Core" />
<MenuItem
<MenuItem
x:Name="menuCheckUpdateSagerNetCore"
Height="{StaticResource MenuItemHeight}"
Header="SagerNet Core" />
Header="SagerNet Core" />-->
<MenuItem
x:Name="menuCheckUpdateXrayCore"
Height="{StaticResource MenuItemHeight}"
Header="Xray Core" />
<Separator Margin="-40,5" />
<!--<Separator Margin="-40,5" />
<MenuItem
x:Name="menuCheckUpdateClashCore"
Height="{StaticResource MenuItemHeight}"
@@ -227,11 +237,11 @@
x:Name="menuCheckUpdateClashMetaCore"
Height="{StaticResource MenuItemHeight}"
Header="Clash.Meta Core" />
<Separator Margin="-40,5" />
<Separator Margin="-40,5" />-->
<MenuItem
x:Name="menuCheckUpdateSingBoxCore"
Height="{StaticResource MenuItemHeight}"
Header="SingBox Core" />
Header="Sing-box Core" />
<Separator Margin="-40,5" />
<MenuItem
x:Name="menuCheckUpdateGeo"
@@ -300,6 +310,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@@ -315,17 +326,30 @@
x:Name="togDarkMode"
Grid.Row="0"
Grid.Column="1"
Margin="8" />
Margin="8"
IsEnabled="{Binding ElementName=followSystemTheme, Path=IsChecked, Converter={StaticResource InverseBooleanConverter}}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsFollowSystemTheme}" />
<ToggleButton
x:Name="followSystemTheme"
Grid.Row="1"
Grid.Column="1"
Margin="8" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsColor}" />
<ComboBox
x:Name="cmbSwatches"
Grid.Row="1"
Grid.Row="2"
Grid.Column="1"
Width="100"
Margin="8"
@@ -333,28 +357,28 @@
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="2"
Grid.Row="3"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsFontSize}" />
<ComboBox
x:Name="cmbCurrentFontSize"
Grid.Row="2"
Grid.Row="3"
Grid.Column="1"
Width="100"
Margin="8"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="3"
Grid.Row="4"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsLanguage}" />
<ComboBox
x:Name="cmbCurrentLanguage"
Grid.Row="3"
Grid.Row="4"
Grid.Column="1"
Width="100"
Margin="8"
@@ -368,6 +392,7 @@
<WrapPanel Margin="2" DockPanel.Dock="Top">
<ListBox
x:Name="lstGroup"
MaxHeight="120"
FontSize="{DynamicResource StdFontSize}"
ItemContainerStyle="{StaticResource MyChipListBoxItem}"
Style="{StaticResource MaterialDesignChoiceChipPrimaryOutlineListBox}">
@@ -608,10 +633,6 @@
x:Name="menuExport2ClientConfig"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuExport2ClientConfig}" />
<MenuItem
x:Name="menuExport2ServerConfig"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuExport2ServerConfig}" />
<MenuItem
x:Name="menuExport2ShareUrl"
Height="{StaticResource MenuItemHeight}"
@@ -734,12 +755,17 @@
</DataGrid>
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" />
<local:MsgView Grid.Row="2" />
<materialDesign:Snackbar
x:Name="MainSnackbar"
Grid.Row="2"
MessageQueue="{materialDesign:MessageQueue}" />
</Grid>
</DockPanel>
<tb:TaskbarIcon
x:Name="tbNotify"
IconSource="/v2rayN.ico"
NoLeftClickDelay="True">
NoLeftClickDelay="True"
ToolTipText="v2rayN">
<tb:TaskbarIcon.ContextMenu>
<ContextMenu Style="{StaticResource DefContextMenu}">
<MenuItem x:Name="menuSystemProxyClear" Height="{StaticResource MenuItemHeight}">
@@ -842,25 +868,7 @@
Header="{x:Static resx:ResUI.menuExit}" />
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
<tb:TaskbarIcon.TrayToolTip>
<Border
x:Name="borTrayToolTip"
Width="Auto"
Height="Auto"
Background="{DynamicResource MaterialDesignLightBackground}"
BorderBrush="{DynamicResource MaterialDesignDarkBackground}"
BorderThickness="0"
CornerRadius="4">
<TextBlock
Margin="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{DynamicResource MaterialDesignDarkBackground}"
Text="{Binding Mode=OneWay, Path=ToolTipText}" />
</Border>
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<materialDesign:Snackbar x:Name="MainSnackbar" MessageQueue="{materialDesign:MessageQueue}" />
</Grid>
</materialDesign:DialogHost>
</reactiveui:ReactiveWindow>

View File

@@ -2,6 +2,7 @@
using Splat;
using System.ComponentModel;
using System.Reactive.Disposables;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
@@ -24,6 +25,19 @@ namespace v2rayN.Views
public MainWindow()
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
lstGroup.MaxHeight = Math.Floor(SystemParameters.WorkArea.Height * 0.20 / 40) * 40;
_config = LazyConfig.Instance.GetConfig();
App.Current.SessionEnding += Current_SessionEnding;
@@ -72,6 +86,8 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.AddShadowsocksServerCmd, v => v.menuAddShadowsocksServer).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.AddSocksServerCmd, v => v.menuAddSocksServer).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.AddTrojanServerCmd, v => v.menuAddTrojanServer).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.AddHysteria2ServerCmd, v => v.menuAddHysteria2Server).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.AddTuicServerCmd, v => v.menuAddTuicServer).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.AddCustomServerCmd, v => v.menuAddCustomServer).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.AddServerViaClipboardCmd, v => v.menuAddServerViaClipboard).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.AddServerViaScanCmd, v => v.menuAddServerViaScan).DisposeWith(disposables);
@@ -103,7 +119,6 @@ namespace v2rayN.Views
//servers export
this.BindCommand(ViewModel, vm => vm.Export2ClientConfigCmd, v => v.menuExport2ClientConfig).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2ServerConfigCmd, v => v.menuExport2ServerConfig).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2ShareUrlCmd, v => v.menuExport2ShareUrl).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2SubContentCmd, v => v.menuExport2SubContent).DisposeWith(disposables);
@@ -117,6 +132,7 @@ namespace v2rayN.Views
//setting
this.BindCommand(ViewModel, vm => vm.OptionSettingCmd, v => v.menuOptionSetting).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RoutingSettingCmd, v => v.menuRoutingSetting).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.DNSSettingCmd, v => v.menuDNSSetting).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.GlobalHotkeySettingCmd, v => v.menuGlobalHotkeySetting).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
@@ -124,11 +140,11 @@ namespace v2rayN.Views
//checkupdate
this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateV2flyCoreCmd, v => v.menuCheckUpdateV2flyCore).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateSagerNetCoreCmd, v => v.menuCheckUpdateSagerNetCore).DisposeWith(disposables);
//this.BindCommand(ViewModel, vm => vm.CheckUpdateV2flyCoreCmd, v => v.menuCheckUpdateV2flyCore).DisposeWith(disposables);
//this.BindCommand(ViewModel, vm => vm.CheckUpdateSagerNetCoreCmd, v => v.menuCheckUpdateSagerNetCore).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.menuCheckUpdateClashCore).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateClashMetaCoreCmd, v => v.menuCheckUpdateClashMetaCore).DisposeWith(disposables);
//this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.menuCheckUpdateClashCore).DisposeWith(disposables);
//this.BindCommand(ViewModel, vm => vm.CheckUpdateClashMetaCoreCmd, v => v.menuCheckUpdateClashMetaCore).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateSingBoxCoreCmd, v => v.menuCheckUpdateSingBoxCore).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.CheckUpdateGeoCmd, v => v.menuCheckUpdateGeo).DisposeWith(disposables);
@@ -165,7 +181,7 @@ namespace v2rayN.Views
this.OneWayBind(ViewModel, vm => vm.RunningServerToolTipText, v => v.tbNotify.ToolTipText).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.NotifyLeftClickCmd, v => v.tbNotify.LeftClickCommand).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.AppIcon, v => v.Icon).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.BlShowTrayTip, v => v.borTrayToolTip.Visibility).DisposeWith(disposables);
//this.OneWayBind(ViewModel, vm => vm.BlShowTrayTip, v => v.borTrayToolTip.Visibility).DisposeWith(disposables);
//status bar
this.OneWayBind(ViewModel, vm => vm.InboundDisplay, v => v.txtInboundDisplay.Text).DisposeWith(disposables);
@@ -183,6 +199,7 @@ namespace v2rayN.Views
//UI
this.Bind(ViewModel, vm => vm.ColorModeDark, v => v.togDarkMode.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.FollowSystemTheme, v => v.followSystemTheme.IsChecked).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.Swatches, v => v.cmbSwatches.ItemsSource).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSwatch, v => v.cmbSwatches.SelectedItem).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentFontSize, v => v.cmbCurrentFontSize.Text).DisposeWith(disposables);
@@ -206,6 +223,25 @@ namespace v2rayN.Views
{
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
}
var helper = new WindowInteropHelper(this);
var hwndSource = HwndSource.FromHwnd(helper.EnsureHandle());
hwndSource.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
{
if (_config.uiItem.followSystemTheme)
{
const int WM_SETTINGCHANGE = 0x001A;
if (msg == WM_SETTINGCHANGE)
{
if (wParam == IntPtr.Zero && Marshal.PtrToStringUni(lParam) == "ImmersiveColorSet")
{
ViewModel?.ModifyTheme(!Utils.IsLightTheme());
}
}
}
return IntPtr.Zero;
});
}
#region Event
@@ -252,12 +288,7 @@ namespace v2rayN.Views
private void LstProfiles_LoadingRow(object? sender, DataGridRowEventArgs e)
{
//if (e.Row.GetIndex() == 0)
//{
// lstProfiles.Focus();
//}
e.Row.Header = e.Row.GetIndex() + 1;
e.Row.Header = $" {e.Row.GetIndex() + 1}";
}
private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e)
@@ -293,33 +324,35 @@ namespace v2rayN.Views
{
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
{
if (e.Key == Key.V)
switch (e.Key)
{
ViewModel?.AddServerViaClipboard();
}
else if (e.Key == Key.P)
{
ViewModel?.ServerSpeedtest(ESpeedActionType.Ping);
}
else if (e.Key == Key.O)
{
ViewModel?.ServerSpeedtest(ESpeedActionType.Tcping);
}
else if (e.Key == Key.R)
{
ViewModel?.ServerSpeedtest(ESpeedActionType.Realping);
}
else if (e.Key == Key.S)
{
_ = ViewModel?.ScanScreenTaskAsync();
}
else if (e.Key == Key.T)
{
ViewModel?.ServerSpeedtest(ESpeedActionType.Speedtest);
}
else if (e.Key == Key.E)
{
ViewModel?.ServerSpeedtest(ESpeedActionType.Mixedtest);
case Key.V:
ViewModel?.AddServerViaClipboard();
break;
case Key.P:
ViewModel?.ServerSpeedtest(ESpeedActionType.Ping);
break;
case Key.O:
ViewModel?.ServerSpeedtest(ESpeedActionType.Tcping);
break;
case Key.R:
ViewModel?.ServerSpeedtest(ESpeedActionType.Realping);
break;
case Key.S:
_ = ViewModel?.ScanScreenTaskAsync();
break;
case Key.T:
ViewModel?.ServerSpeedtest(ESpeedActionType.Speedtest);
break;
case Key.E:
ViewModel?.ServerSpeedtest(ESpeedActionType.Mixedtest);
break;
}
}
else
@@ -469,11 +502,18 @@ namespace v2rayN.Views
if (!_config.guiItem.enableStatistics)
{
colTodayUp.Visibility = Visibility.Hidden;
colTodayDown.Visibility = Visibility.Hidden;
colTotalUp.Visibility = Visibility.Hidden;
colTodayUp.Visibility =
colTodayDown.Visibility =
colTotalUp.Visibility =
colTotalDown.Visibility = Visibility.Hidden;
}
else
{
colTodayUp.Visibility =
colTodayDown.Visibility =
colTotalUp.Visibility =
colTotalDown.Visibility = Visibility.Visible;
}
}
private void StorageUI()
@@ -488,7 +528,7 @@ namespace v2rayN.Views
lvColumnItem.Add(new()
{
Name = item2.ExName,
Width = item2.Visibility == Visibility.Visible ? Convert.ToInt32(item2.ActualWidth) : 0,
Width = item2.Visibility == Visibility.Visible ? Convert.ToInt32(item2.ActualWidth) : -1,
Index = item2.DisplayIndex
});
}
@@ -501,12 +541,16 @@ namespace v2rayN.Views
private void AddHelpMenuItem()
{
var coreInfos = LazyConfig.Instance.GetCoreInfos();
foreach (var it in coreInfos)
foreach (var it in coreInfos
.Where(t => t.coreType != ECoreType.v2fly
&& t.coreType != ECoreType.clash
&& t.coreType != ECoreType.clash_meta
&& t.coreType != ECoreType.hysteria))
{
var item = new MenuItem()
{
Tag = it.coreUrl.Replace(@"/releases", ""),
Header = string.Format(Resx.ResUI.menuWebsiteItem, it.coreType.ToString().Replace("_", " "))
Header = string.Format(Resx.ResUI.menuWebsiteItem, it.coreType.ToString().Replace("_", " ")).UpperFirstChar()
};
item.Click += MenuItem_Click;
menuHelp.Items.Add(item);

View File

@@ -67,6 +67,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@@ -291,50 +293,50 @@
Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsDefUserAgentTips}" />
</Grid>
</ScrollViewer>
</TabItem>
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDns}">
<DockPanel Margin="{StaticResource SettingItemMargin}">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
<TextBlock
Grid.Row="14"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsDomainStrategy4Freedom}" />
Text="{x:Static resx:ResUI.TbSettingsMux4SboxProtocol}" />
<ComboBox
x:Name="cmbdomainStrategy4Freedom"
x:Name="cmbmux4SboxProtocol"
Grid.Row="14"
Grid.Column="1"
Width="200"
Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource DefComboBox}" />
</StackPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock
Grid.Row="15"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsRemoteDNS}" />
<TextBlock
Margin="8,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkDnsObjectDoc_Click">
<TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" />
</Hyperlink>
</TextBlock>
</StackPanel>
<TextBox
x:Name="txtremoteDNS"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Stretch"
AcceptsReturn="True"
BorderThickness="1"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</DockPanel>
Text="{x:Static resx:ResUI.TbSettingsHysteriaBandwidth}" />
<StackPanel
Grid.Row="15"
Grid.Column="1"
Orientation="Horizontal">
<TextBox
x:Name="txtUpMbps"
Width="90"
Margin="{StaticResource SettingItemMargin}"
materialDesign:HintAssist.Hint="Up"
Style="{StaticResource DefTextBox}" />
<TextBox
x:Name="txtDownMbps"
Width="90"
Margin="{StaticResource SettingItemMargin}"
materialDesign:HintAssist.Hint="Down"
Style="{StaticResource DefTextBox}" />
</StackPanel>
</Grid>
</ScrollViewer>
</TabItem>
<!--<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreKcp}">
@@ -524,21 +526,6 @@
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsStatisticsFreshRate}" />
<ComboBox
x:Name="cmbStatisticsFreshRate"
Grid.Row="3"
Grid.Column="1"
Width="200"
Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="4"
Grid.Column="0"
@@ -735,6 +722,7 @@
Grid.Column="1"
Width="300"
Margin="{StaticResource SettingItemMargin}"
IsEditable="True"
Style="{StaticResource DefComboBox}" />
<TextBlock
@@ -819,11 +807,6 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@@ -831,34 +814,6 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsTunModeShowWindow}" />
<ToggleButton
x:Name="togShowWindow"
Grid.Row="0"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsLogEnabled}" />
<ToggleButton
x:Name="togEnabledLog"
Grid.Row="1"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
@@ -911,26 +866,13 @@
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsTunModeCustomTemplate}" />
<TextBox
x:Name="txtCustomTemplate"
Text="{x:Static resx:ResUI.TbSettingsEnableExInbound}" />
<ToggleButton
x:Name="togEnableExInbound"
Grid.Row="5"
Grid.Column="1"
Width="400"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Top"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap" />
<Button
x:Name="btnBrowse"
Grid.Row="5"
Grid.Column="2"
Width="100"
Margin="2,0,8,0"
Click="btnBrowse_Click"
Content="{x:Static resx:ResUI.TbBrowse}"
Style="{StaticResource DefButton}" />
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="6"
@@ -938,118 +880,13 @@
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsTunModeBypassMode}" />
Text="{x:Static resx:ResUI.TbSettingsEnableIPv6Address}" />
<ToggleButton
x:Name="togBypassMode"
x:Name="togEnableIPv6Address"
Grid.Row="6"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="6"
Grid.Column="2"
Margin="{StaticResource ServerItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsTunModeBypassModeTip}" />
</Grid>
<Grid
x:Name="gridTunModeDirect"
Width="800"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<GroupBox
Grid.Column="0"
Header="{x:Static resx:ResUI.TbSettingsTunModeDirectIP}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtDirectIP"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
<GroupBox
Grid.Column="2"
Header="{x:Static resx:ResUI.TbSettingsTunModeDirectProcess}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtDirectProcess"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
<GridSplitter Grid.Column="3" HorizontalAlignment="Stretch" />
<GroupBox
Grid.Column="4"
Header="{x:Static resx:ResUI.TbSettingsTunModeDNS}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtDirectDNS"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
</Grid>
<Grid
x:Name="gridTunModeProxy"
Width="800"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<GroupBox
Grid.Column="0"
Header="{x:Static resx:ResUI.TbSettingsTunModeProxyIP}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtProxyIP"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
<GroupBox
Grid.Column="2"
Header="{x:Static resx:ResUI.TbSettingsTunModeProxyProcess}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtProxyProcess"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
<GridSplitter Grid.Column="3" HorizontalAlignment="Stretch" />
<GroupBox
Grid.Column="4"
Header="{x:Static resx:ResUI.TbSettingsTunModeDNS}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtProxyDNS"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
</Grid>
</DockPanel>
</TabItem>

View File

@@ -18,6 +18,17 @@ namespace v2rayN.Views
public OptionSettingWindow()
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
_config = LazyConfig.Instance.GetConfig();
@@ -27,26 +38,23 @@ namespace v2rayN.Views
{
cmbsystemProxyAdvancedProtocol.Items.Add(it);
});
Global.LogLevel.ForEach(it =>
Global.LogLevels.ForEach(it =>
{
cmbloglevel.Items.Add(it);
});
Global.fingerprints.ForEach(it =>
Global.Fingerprints.ForEach(it =>
{
cmbdefFingerprint.Items.Add(it);
});
Global.userAgent.ForEach(it =>
Global.UserAgent.ForEach(it =>
{
cmbdefUserAgent.Items.Add(it);
});
Global.domainStrategy4Freedoms.ForEach(it =>
Global.SingboxMuxs.ForEach(it =>
{
cmbdomainStrategy4Freedom.Items.Add(it);
cmbmux4SboxProtocol.Items.Add(it);
});
for (int i = 1; i <= 10; i++)
{
cmbStatisticsFreshRate.Items.Add(i);
}
Global.TunMtus.ForEach(it =>
{
cmbMtu.Items.Add(it);
@@ -55,7 +63,7 @@ namespace v2rayN.Views
{
cmbStack.Items.Add(it);
});
Global.coreTypes.ForEach(it =>
Global.CoreTypes.ForEach(it =>
{
cmbCoreType1.Items.Add(it);
cmbCoreType2.Items.Add(it);
@@ -72,7 +80,7 @@ namespace v2rayN.Views
Global.SpeedTestUrls.ForEach(it =>
{
cmbSpeedTestUrl.Items.Add(it);
});
});
Global.SubConvertUrls.ForEach(it =>
{
cmbSubConvertUrl.Items.Add(it);
@@ -81,7 +89,12 @@ namespace v2rayN.Views
//fill fonts
try
{
var files = Directory.GetFiles(Utils.GetFontsPath(), "*.ttf");
string[] searchPatterns = { "*.ttf", "*.ttc" };
var files = new List<string>();
foreach (var pattern in searchPatterns)
{
files.AddRange(Directory.GetFiles(Utils.GetFontsPath(), pattern));
}
var culture = _config.uiItem.currentLanguage == Global.Languages[0] ? "zh-cn" : "en-us";
var culture2 = "en-us";
foreach (var ttf in files)
@@ -137,9 +150,9 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.remoteDNS, v => v.txtremoteDNS.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyDownMbps, v => v.txtDownMbps.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcpmtu, v => v.txtKcpmtu.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcptti, v => v.txtKcptti.Text).DisposeWith(disposables);
@@ -151,7 +164,6 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.AutoRun, v => v.togAutoRun.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableStatistics, v => v.togEnableStatistics.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.StatisticsFreshRate, v => v.cmbStatisticsFreshRate.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KeepOlderDedupl, v => v.togKeepOlderDedupl.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.IgnoreGeoUpdateCore, v => v.togIgnoreGeoUpdateCore.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableAutoAdjustMainLvColWidth, v => v.togEnableAutoAdjustMainLvColWidth.IsChecked).DisposeWith(disposables);
@@ -171,21 +183,11 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.systemProxyAdvancedProtocol, v => v.cmbsystemProxyAdvancedProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.systemProxyExceptions, v => v.txtsystemProxyExceptions.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunShowWindow, v => v.togShowWindow.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunEnabledLog, v => v.togEnabledLog.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunStrictRoute, v => v.togStrictRoute.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunStack, v => v.cmbStack.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunMtu, v => v.cmbMtu.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunCustomTemplate, v => v.txtCustomTemplate.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunBypassMode, v => v.togBypassMode.IsChecked).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.TunBypassMode, v => v.gridTunModeDirect.Visibility, vmToViewConverterOverride: new BooleanToVisibilityTypeConverter()).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.TunBypassMode2, v => v.gridTunModeProxy.Visibility, vmToViewConverterOverride: new BooleanToVisibilityTypeConverter()).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunDirectIP, v => v.txtDirectIP.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunDirectProcess, v => v.txtDirectProcess.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunDirectDNS, v => v.txtDirectDNS.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunProxyIP, v => v.txtProxyIP.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunProxyProcess, v => v.txtProxyProcess.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunProxyDNS, v => v.txtProxyDNS.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunEnableExInbound, v => v.togEnableExInbound.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TunEnableIPv6Address, v => v.togEnableIPv6Address.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType1, v => v.cmbCoreType1.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType2, v => v.cmbCoreType2.Text).DisposeWith(disposables);
@@ -198,11 +200,6 @@ namespace v2rayN.Views
});
}
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
{
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject");
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
@@ -214,7 +211,7 @@ namespace v2rayN.Views
openFileDialog1.Filter = "tunConfig|*.json|All|*.*";
openFileDialog1.ShowDialog();
txtCustomTemplate.Text = openFileDialog1.FileName;
// txtCustomTemplate.Text = openFileDialog1.FileName;
}
}
}

View File

@@ -172,10 +172,12 @@
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<GroupBox
Grid.Column="0"
Header="Domain"
Header="{x:Static resx:ResUI.TbRoutingRuleDomain}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtDomain"
@@ -187,7 +189,7 @@
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
<GroupBox
Grid.Column="2"
Header="IP"
Header="{x:Static resx:ResUI.TbRoutingRuleIP}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtIP"
@@ -196,6 +198,18 @@
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
<GridSplitter Grid.Column="3" HorizontalAlignment="Stretch" />
<GroupBox
Grid.Column="4"
Header="{x:Static resx:ResUI.TbRoutingRuleProcess}"
Style="{StaticResource MyGroupBox}">
<TextBox
Name="txtProcess"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
</Grid>
</DockPanel>
</reactiveui:ReactiveWindow>

View File

@@ -12,16 +12,27 @@ namespace v2rayN.Views
public RoutingRuleDetailsWindow(RulesItem rulesItem)
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
this.Loaded += Window_Loaded;
clbProtocol.SelectionChanged += ClbProtocol_SelectionChanged;
clbInboundTag.SelectionChanged += ClbInboundTag_SelectionChanged;
ViewModel = new RoutingRuleDetailsViewModel(rulesItem, this);
cmbOutboundTag.Items.Add(Global.agentTag);
cmbOutboundTag.Items.Add(Global.directTag);
cmbOutboundTag.Items.Add(Global.blockTag);
Global.Protocols.ForEach(it =>
cmbOutboundTag.Items.Add(Global.ProxyTag);
cmbOutboundTag.Items.Add(Global.DirectTag);
cmbOutboundTag.Items.Add(Global.BlockTag);
Global.RuleProtocols.ForEach(it =>
{
clbProtocol.Items.Add(it);
});
@@ -49,6 +60,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSource.enabled, v => v.togEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Domain, v => v.txtDomain.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Process, v => v.txtProcess.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoSort, v => v.chkAutoSort.IsChecked).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);

View File

@@ -10,7 +10,7 @@
xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="{x:Static resx:ResUI.menuRoutingRuleSetting}"
Width="900"
Width="960"
Height="700"
x:TypeArguments="vms:RoutingRuleSettingViewModel"
Background="{DynamicResource MaterialDesignPaper}"
@@ -138,13 +138,26 @@
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbdomainStrategy}" />
<ComboBox
x:Name="cmbdomainStrategy"
<StackPanel
Grid.Row="1"
Grid.Column="1"
Width="200"
Margin="4"
Style="{StaticResource DefComboBox}" />
Orientation="Horizontal">
<ComboBox
x:Name="cmbdomainStrategy"
Width="200"
Margin="4"
Style="{StaticResource DefComboBox}" />
<TextBlock
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbdomainStrategy4Singbox}" />
<ComboBox
x:Name="cmbdomainStrategy4Singbox"
Width="200"
Margin="4"
Style="{StaticResource DefComboBox}" />
</StackPanel>
<TextBlock
Grid.Row="2"
@@ -267,7 +280,7 @@
Binding="{Binding outboundTag}"
Header="outboundTag" />
<DataGridTextColumn
Width="100"
Width="80"
Binding="{Binding port}"
Header="port" />
<DataGridTextColumn
@@ -275,15 +288,15 @@
Binding="{Binding protocols}"
Header="protocol" />
<DataGridTextColumn
Width="120"
Width="110"
Binding="{Binding inboundTags}"
Header="inboundTag" />
<DataGridTextColumn
Width="150"
Width="220"
Binding="{Binding domains}"
Header="domain" />
<DataGridTextColumn
Width="150"
Width="220"
Binding="{Binding ips}"
Header="ip" />
<DataGridTextColumn

View File

@@ -13,6 +13,17 @@ namespace v2rayN.Views
public RoutingRuleSettingWindow(RoutingItem routingItem)
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
this.Loaded += Window_Loaded;
this.PreviewKeyDown += RoutingRuleSettingWindow_PreviewKeyDown;
@@ -20,11 +31,15 @@ namespace v2rayN.Views
lstRules.MouseDoubleClick += LstRules_MouseDoubleClick;
ViewModel = new RoutingRuleSettingViewModel(routingItem, this);
Global.domainStrategys.ForEach(it =>
Global.DomainStrategys.ForEach(it =>
{
cmbdomainStrategy.Items.Add(it);
});
cmbdomainStrategy.Items.Add(string.Empty);
Global.DomainStrategys4Singbox.ForEach(it =>
{
cmbdomainStrategy4Singbox.Items.Add(it);
});
this.WhenActivated(disposables =>
{
@@ -33,6 +48,8 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedRouting.remarks, v => v.txtRemarks.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.domainStrategy, v => v.cmbdomainStrategy.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.domainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.url, v => v.txtUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.customIcon, v => v.txtCustomIcon.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.sort, v => v.txtSort.Text).DisposeWith(disposables);
@@ -90,6 +107,10 @@ namespace v2rayN.Views
{
ViewModel?.MoveRule(EMove.Bottom);
}
else if (e.Key == Key.Delete)
{
ViewModel?.RuleRemove();
}
}
}

View File

@@ -10,7 +10,7 @@
xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="{x:Static resx:ResUI.menuRoutingSetting}"
Width="900"
Width="990"
Height="700"
x:TypeArguments="vms:RoutingSettingViewModel"
Background="{DynamicResource MaterialDesignPaper}"
@@ -52,7 +52,6 @@
Header="{x:Static resx:ResUI.menuRoutingBasicImportRules}" />
</MenuItem>
</Menu>
<Separator />
<Menu Margin="0,8" Style="{StaticResource ToolbarMenu}">
<MenuItem x:Name="menuRoutingAdvanced" Padding="8,0">
<MenuItem.Header>
@@ -106,7 +105,21 @@
Text="{x:Static resx:ResUI.TbdomainMatcher}" />
<ComboBox
x:Name="cmbdomainMatcher"
Width="80"
Width="60"
Margin="8,0,0,0"
Style="{StaticResource DefComboBox}" />
<Separator />
<TextBlock
Margin="8,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkdomainStrategy4Singbox_Click">
<TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy4Singbox}" />
</Hyperlink>
</TextBlock>
<ComboBox
x:Name="cmbdomainStrategy4Singbox"
Width="100"
Margin="8,0,0,0"
Style="{StaticResource DefComboBox}" />
</ToolBar>
@@ -150,6 +163,7 @@
<TabItem HorizontalAlignment="Left" Header="{x:Static resx:ResUI.TbRoutingTabRuleList}">
<DataGrid
x:Name="lstRoutings"
Margin="2,0"
AutoGenerateColumns="False"
BorderThickness="1"
CanUserAddRows="False"
@@ -199,7 +213,7 @@
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn
Width="200"
Width="250"
Binding="{Binding remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" />
<DataGridTextColumn
@@ -211,11 +225,11 @@
Binding="{Binding sort}"
Header="{x:Static resx:ResUI.LvSort}" />
<DataGridTextColumn
Width="260"
Width="300"
Binding="{Binding url}"
Header="{x:Static resx:ResUI.LvUrl}" />
<DataGridTextColumn
Width="260"
Width="300"
Binding="{Binding customIcon}"
Header="{x:Static resx:ResUI.LvCustomIcon}" />
</DataGrid.Columns>

View File

@@ -12,6 +12,17 @@ namespace v2rayN.Views
public RoutingSettingWindow()
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
this.Closing += RoutingSettingWindow_Closing;
this.PreviewKeyDown += RoutingSettingWindow_PreviewKeyDown;
@@ -20,14 +31,18 @@ namespace v2rayN.Views
ViewModel = new RoutingSettingViewModel(this);
Global.domainStrategys.ForEach(it =>
Global.DomainStrategys.ForEach(it =>
{
cmbdomainStrategy.Items.Add(it);
});
Global.domainMatchers.ForEach(it =>
Global.DomainMatchers.ForEach(it =>
{
cmbdomainMatcher.Items.Add(it);
});
Global.DomainStrategys4Singbox.ForEach(it =>
{
cmbdomainStrategy4Singbox.Items.Add(it);
});
this.WhenActivated(disposables =>
{
@@ -37,6 +52,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.enableRoutingAdvanced, v => v.togenableRoutingAdvanced.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.domainStrategy, v => v.cmbdomainStrategy.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.domainMatcher, v => v.cmbdomainMatcher.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.domainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.ProxyDomain, v => v.txtProxyDomain.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.ProxyIP, v => v.txtProxyIP.Text).DisposeWith(disposables);
@@ -45,8 +61,8 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.BlockDomain, v => v.txtBlockDomain.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.BlockIP, v => v.txtBlockIP.Text).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.enableRoutingBasic, v => v.menuRoutingBasic.IsEnabled).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.enableRoutingAdvanced, v => v.menuRoutingAdvanced.IsEnabled).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.enableRoutingBasic, v => v.menuRoutingBasic.Visibility).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.enableRoutingAdvanced, v => v.menuRoutingAdvanced.Visibility).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.enableRoutingBasic, v => v.tabBasic.Visibility).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.enableRoutingAdvanced, v => v.tabAdvanced.Visibility).DisposeWith(disposables);
@@ -72,6 +88,11 @@ namespace v2rayN.Views
private void RoutingSettingWindow_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (ViewModel?.enableRoutingBasic ?? false)
{
return;
}
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
{
if (e.Key == Key.A)
@@ -79,6 +100,14 @@ namespace v2rayN.Views
lstRoutings.SelectAll();
}
}
else if (e.Key is Key.Enter or Key.Return)
{
ViewModel?.RoutingAdvancedSetDefault();
}
else if (e.Key == Key.Delete)
{
ViewModel?.RoutingAdvancedRemove();
}
}
private void menuRoutingAdvancedSelectAll_Click(object sender, System.Windows.RoutedEventArgs e)
@@ -101,6 +130,11 @@ namespace v2rayN.Views
Utils.ProcessStart("https://www.v2fly.org/config/routing.html");
}
private void linkdomainStrategy4Singbox_Click(object sender, RoutedEventArgs e)
{
Utils.ProcessStart("https://sing-box.sagernet.org/zh/configuration/shared/listen/#domain_strategy");
}
private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (ViewModel?.IsModified == true)

View File

@@ -30,17 +30,38 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<DockPanel Margin="8">
<Grid
Margin="8"
HorizontalAlignment="Center"
DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Button
x:Name="btnSave"
Grid.Column="0"
Margin="4"
Content="{x:Static resx:ResUI.TbConfirm}"
Cursor="Hand"
Style="{StaticResource DefButton}" />
<Button
x:Name="btnCancel"
Grid.Column="1"
Margin="4"
Click="btnCancel_Click"
Content="{x:Static resx:ResUI.TbCancel}"
Cursor="Hand"
IsCancel="true"
Style="{StaticResource DefButton}" />
</Grid>
<ScrollViewer
materialDesign:ScrollViewerAssist.IsAutoHideEnabled="True"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<ScrollViewer
materialDesign:ScrollViewerAssist.IsAutoHideEnabled="True"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -51,6 +72,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@@ -196,7 +219,6 @@
AcceptsReturn="True"
Style="{StaticResource MyOutlinedTextBox}" />
<TextBlock
Grid.Row="7"
Grid.Column="0"
@@ -210,10 +232,8 @@
Grid.Column="1"
Margin="4"
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.LvConvertTargetTip}"
FontSize="{DynamicResource StdFontSize}"
MaxDropDownHeight="1000"
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
Style="{StaticResource MyOutlinedTextComboBox}" />
<TextBlock
Grid.Row="8"
@@ -231,32 +251,44 @@
VerticalAlignment="Top"
AcceptsReturn="True"
Style="{StaticResource MyOutlinedTextBox}" />
</Grid>
<Grid
Grid.Row="1"
Margin="8"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Button
x:Name="btnSave"
<TextBlock
Grid.Row="9"
Grid.Column="0"
Margin="4"
Content="{x:Static resx:ResUI.TbConfirm}"
Cursor="Hand"
Style="{StaticResource DefButton}" />
<Button
x:Name="btnCancel"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.LvPrevProfile}" />
<TextBox
x:Name="txtPrevProfile"
Grid.Row="9"
Grid.Column="1"
Width="400"
Margin="4"
Click="btnCancel_Click"
Content="{x:Static resx:ResUI.TbCancel}"
Cursor="Hand"
IsCancel="true"
Style="{StaticResource DefButton}" />
VerticalAlignment="Top"
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.LvPrevProfileTip}"
AcceptsReturn="True"
Style="{StaticResource MyOutlinedTextBox}" />
<TextBlock
Grid.Row="10"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.LvNextProfile}" />
<TextBox
x:Name="txtNextProfile"
Grid.Row="10"
Grid.Column="1"
Width="400"
Margin="4"
VerticalAlignment="Top"
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.LvPrevProfileTip}"
AcceptsReturn="True"
Style="{StaticResource MyOutlinedTextBox}" />
</Grid>
</Grid>
</ScrollViewer>
</ScrollViewer>
</DockPanel>
</reactiveui:ReactiveWindow>

View File

@@ -11,6 +11,17 @@ namespace v2rayN.Views
public SubEditWindow(SubItem subItem)
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
this.Loaded += Window_Loaded;
@@ -32,6 +43,8 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSource.sort, v => v.txtSort.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.filter, v => v.txtFilter.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.convertTarget, v => v.cmbConvertTarget.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.prevProfile, v => v.txtPrevProfile.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.nextProfile, v => v.txtNextProfile.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});

View File

@@ -13,6 +13,17 @@ namespace v2rayN.Views
public SubSettingWindow()
{
InitializeComponent();
// 设置窗口的尺寸不大于屏幕的尺寸
if (this.Width > SystemParameters.WorkArea.Width)
{
this.Width = SystemParameters.WorkArea.Width;
}
if (this.Height > SystemParameters.WorkArea.Height)
{
this.Height = SystemParameters.WorkArea.Height;
}
this.Owner = Application.Current.MainWindow;
ViewModel = new SubSettingViewModel(this);

View File

@@ -10,30 +10,31 @@
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
<FileVersion>6.23</FileVersion>
<FileVersion>6.32</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Downloader" Version="3.0.4" />
<PackageReference Include="MaterialDesignThemes" Version="4.7.1" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.108" />
<PackageReference Include="Downloader" Version="3.0.6" />
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.123" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="QRCoder.Xaml" Version="1.4.3" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
<PackageReference Include="ReactiveUI.Fody" Version="18.4.1" />
<PackageReference Include="ReactiveUI.Validation" Version="3.0.22" />
<PackageReference Include="ReactiveUI.WPF" Version="18.4.1" />
<PackageReference Include="Splat.NLog" Version="14.6.8" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.31" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
<PackageReference Include="ReactiveUI.WPF" Version="19.5.31" />
<PackageReference Include="Splat.NLog" Version="14.8.12" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="app.manifest" />
<EmbeddedResource Include="Sample\tun_singbox">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\SingboxSampleOutbound" />
<EmbeddedResource Include="Sample\SingboxSampleClientConfig">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\tun_singbox_dns">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
@@ -63,8 +64,18 @@
</EmbeddedResource>
<EmbeddedResource Include="Sample\SampleInbound">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\SampleOutbound" />
<EmbeddedResource Include="Sample\tun_singbox_rules">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\SampleServerConfig">
<EmbeddedResource Include="Sample\tun_singbox_inbound">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\dns_v2ray_normal">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\dns_singbox_normal">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="v2rayN.ico">
@@ -99,6 +110,9 @@
<EmbeddedResource Update="Resx\ResUI.zh-Hans.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Resx\ResUI.zh-Hant.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Resx\ResUI.fa-Ir.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
</EmbeddedResource>

View File

@@ -92,9 +92,9 @@ namespace v2rayUpgrade
File.Move(Application.ExecutablePath, thisAppOldFile);
}
string entryOuputPath = GetPath(fullName);
Directory.CreateDirectory(Path.GetDirectoryName(entryOuputPath)!);
entry.ExtractToFile(entryOuputPath, true);
string entryOutputPath = GetPath(fullName);
Directory.CreateDirectory(Path.GetDirectoryName(entryOutputPath)!);
entry.ExtractToFile(entryOutputPath, true);
}
catch (Exception ex)
{
@@ -145,4 +145,4 @@ namespace v2rayUpgrade
return Path.Combine(startupPath, fileName);
}
}
}
}

View File

@@ -13,6 +13,7 @@ namespace v2rayUpgrade
{
Application.EnableVisualStyles();
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm(args));
}

Some files were not shown because too many files have changed in this diff Show More