Skip to content

Commit

Permalink
V4.0 修复清除重复节点BUG!
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMRLL authored Oct 6, 2021
1 parent 7372a13 commit 2e29803
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 66 deletions.
8 changes: 4 additions & 4 deletions default.aproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="WinXray" libEmbed="true" icon="\forms\ico\app.ico" ui="win" output="WinXray.exe" CompanyName="WinXray" FileDescription="网络代理通用客户端" LegalCopyright="Copyright (C) WinXray" ProductName="WinXray" InternalName="WinXray" FileVersion="3.9" ProductVersion="3.9" publishDir="\WinXray" dstrip="false" local="false" ignored="false">
<project ver="10" name="WinXray" libEmbed="true" icon="\forms\ico\app.ico" ui="win" output="WinXray.exe" CompanyName="WinXray" FileDescription="网络代理通用客户端" LegalCopyright="Copyright (C) WinXray" ProductName="WinXray" InternalName="WinXray" FileVersion="4.0" ProductVersion="4.0" publishDir="\WinXray" dstrip="false" local="false" ignored="false">
<file name="main" path="main.aardio"/>
<folder name="窗体" path="forms" comment="" embed="true" local="false" ignored="false">
<folder name="ico" path="forms\ico" comment="forms\ico">
<folder name="ico" path="forms\ico" comment="forms\ico" local="false" embed="false" ignored="false">
<file name="app-direct.ico" path="forms\ico\app-direct.ico" comment="forms\ico\app-direct.ico"/>
<file name="app-pac.ico" path="forms\ico\app-pac.ico" comment="forms\ico\app-pac.ico"/>
<file name="app.ico" path="forms\ico\app.ico" comment="forms\ico\app.ico"/>
Expand All @@ -11,11 +11,11 @@
<file name="outbound.aardio" path="forms\main\outbound.aardio" comment="forms\main\outbound.aardio"/>
<file name="pac.aardio" path="forms\main\pac.aardio" comment="forms\main\pac.aardio"/>
<file name="xray.aardio" path="forms\main\xray.aardio" comment="forms\main\xray.aardio"/>
<folder name="config" path="forms\main\config" comment="forms\main\config">
<folder name="config" path="forms\main\config" comment="forms\main\config" local="false" embed="false" ignored="false">
<file name="advancedConfig.aardio" path="forms\main\config\advancedConfig.aardio" comment="forms\main\config\advancedConfig.aardio"/>
<file name="jsonConfig.aardio" path="forms\main\config\jsonConfig.aardio" comment="forms\main\config\jsonConfig.aardio"/>
<file name="subscription.aardio" path="forms\main\config\subscription.aardio" comment="forms\main\config\subscription.aardio"/>
<folder name="coreConfigs" path="forms\main\config\coreConfigs" comment="forms\main\config\coreConfigs">
<folder name="coreConfigs" path="forms\main\config\coreConfigs" comment="forms\main\config\coreConfigs" local="false" embed="false" ignored="false">
<file name="default.json" path="forms\main\config\coreConfigs\default.json" comment="forms\main\config\coreConfigs\default.json"/>
<file name="xray.rules.json" path="forms\main\config\coreConfigs\xray.rules.json" comment="forms\main\config\coreConfigs\xray.rules.json"/>
</folder>
Expand Down
118 changes: 62 additions & 56 deletions forms/main/xray.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ frmXray.listview.insertColumn("加密",90)
frmXray.listview.insertColumn("协议",50)
frmXray.listview.insertColumn("备注",190)
frmXray.listview.insertColumn("响应速度",95)
frmXray.listview.insertColumn("状态",-1)
frmXray.listview.insertColumn("状态",-1);
frmXray.listview.setExtended(0x10000/*_LVS_EX_DOUBLEBUFFER*/);

frmXray.show();
Expand Down Expand Up @@ -469,59 +469,6 @@ var removeOutbounds = function(selectedItems){
if(!xray.core.lastDownloadingCoreFailed) frmXray.btnTcping.oncommand();
}
}
//移除重复节点
frmXray.removeRepeat=function(){
//跳过检测异常
frmXray.listChanging = true;
//避免后台线程改变activeIndex
frmXray.onTcpingReturn = function(outboundIndex,address,succeeded,speedText){};
frmXray.btnTcping.disabledText = null;
frmXray.autoTesting = false;
//标记活动节点
var activeIndex = frmXray.listview.activeOutboundIndex;
var outbounds = config.proxy.outbounds;
for(i=#outbounds;1;-1){
var ob = outbounds[i];
if(activeIndex==i){
ob.active = true;
}
}
//标记重复节点
for(i=1;#outbounds;1){
for(j=1;#outbounds;1){
if( j<=i ){ continue }
if( outbounds[j].address==outbounds[i].address
&& outbounds[j].port==outbounds[i].port ){
outbounds[j].repeat=true;
}
}
}
//删除重复节点
var removecount=0;
for(i=#outbounds;1;-1){
if(outbounds[i].repeat){
table.remove(outbounds,i);
removecount++;
}
}

//保存配置文件
config.proxy.outbounds = outbounds;
config.proxy.save();
frmXray.listview.setTable(outbounds);
//如果把活动节点删了,重新连接
if(activeIndex && (!frmXray.listview.activeOutboundIndex) ){
if( config.settings.autoStartTest) frmXray.btnAutoConnect.oncommand();
}
elseif(frmXray.listview.activeOutboundIndex){
frmXray.listview.setItemText(activeText,activeIndex,frmXray.StatusX);
}
//继续检测异常
frmXray.listChanging = false;

return removecount;
}


import xray.outbounds;
frmXray.listview.onnotify = function(id,code,ptr){
Expand Down Expand Up @@ -611,7 +558,9 @@ frmXray.listview.onnotify = function(id,code,ptr){

popmenu.add('清除「重复」节点',function(id){
var removecount = frmXray.removeRepeat();
if(removecount){ frmXray.edit.print("删除了"+removecount+"个节点") }
if(removecount){
frmXray.edit.print("删除了"+removecount+"个节点")
}
});

popmenu.add("重置为默认服务器列表",
Expand Down Expand Up @@ -738,7 +687,9 @@ frmXray.listview.onnotify = function(id,code,ptr){

popmenu.add('清除「重复」节点',function(id){
var removecount = frmXray.removeRepeat();
if(removecount){ frmXray.edit.print("删除了"+removecount+"个节点") }
if(removecount){
frmXray.edit.print("删除了"+removecount+"个节点")
}
});

popmenu.add("重置为默认服务器列表",
Expand Down Expand Up @@ -939,6 +890,61 @@ frmXray.listview.sortBySpeed = function () {
}
frmXray.listview.setColumnImage(7, desc ? 1 : 0);
}
//移除重复节点(保留序号在前的)
frmXray.removeRepeat=function(){
//跳过检测异常
frmXray.listChanging = true;
//避免后台线程改变activeIndex
frmXray.onTcpingReturn = function(outboundIndex,address,succeeded,speedText){};
frmXray.btnTcping.disabledText = null;
frmXray.autoTesting = false;
//标记活动节点
var activeIndex,activeText = frmXray.listview.activeOutboundIndex;
var outbounds = ..table.clone(config.proxy.outbounds);
if( activeIndex ){
outbounds[activeIndex].active = true;
activeText = frmXray.listview.getItemText(activeIndex);
}
//标记重复节点
for(i=1;#outbounds;1){
for(j=1;#outbounds;1){
if( j<=i ){ continue }
if( outbounds[j].address==outbounds[i].address
&& outbounds[j].port==outbounds[i].port ){
outbounds[j].repeat=true;
}
}
}
//删除重复节点
var removecount=0;
for(i=#outbounds;1;-1){
if(outbounds[i].repeat){
table.remove(outbounds,i);
removecount++;
}
}
//重设活动节点序号
frmXray.listview.activeOutboundIndex = null;
for(i=1;#outbounds;1){
var ob = outbounds[i];
if(ob.active){
frmXray.listview.activeOutboundIndex = i;
activeIndex = i;
}
ob.repeat = null;
ob.active = null;
}
//保存配置文件
config.proxy.outbounds = outbounds;
config.proxy.save();
frmXray.listview.setTable(outbounds);
//重新测速
frmXray.btnTcping.oncommand();
//继续检测异常
frmXray.listChanging = false;

return removecount;
}

import win.imageList;
var iml = win.imageList(16, 15);
Expand Down
10 changes: 7 additions & 3 deletions lib/config.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,25 @@ namespace config {

if(!config.proxy.mode) config.proxy.mode = "pac";
if(!config.proxy.pacPort) config.proxy.pacPort = 0;
if(config.proxy.useHttpGlobal===null){
if(config.proxy.useHttpGlobal === null){
config.proxy.useHttpGlobal = true;
}
if(config.proxy.useSocksPac===null){
if(config.proxy.useSocksPac === null){
config.proxy.useSocksPac = _WIN10_LATER;
}

if(config.proxy.enableGitConfigGithub===null){
if(config.proxy.enableGitConfigGithub === null){
config.proxy.enableGitConfigGithub = true;
}

if(config.proxy.test === null){
config.proxy.test = true;
}

if(config.settings.autoStartTest === null){
config.settings.autoStartTest = true;
}

if(config.proxy.autoRefreshSubscription === null){
config.proxy.autoRefreshSubscription = true;
}
Expand Down
2 changes: 1 addition & 1 deletion main.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ import win.ui;
mainForm = win.form(text="WinXray";right=1019;bottom=679;bgcolor=15793151;border="none")
mainForm.add(
Promote={cls="plus";text="推荐";left=0;top=300;right=85;bottom=380;bkBottom=3;bkLeft=7;bkRight=8;bkTop=2;border={color=-65536};color=16777215;dl=1;dt=1;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-37;name='FontAwesome');padding={bottom=20}};iconText='\uF233';notify=1;textPadding={bottom=10};valign="bottom";x=0.5;y=0.2;z=8};
caption={cls="bkplus";text="WinXray.COM V3.9";left=25;top=9;right=685;bottom=27;align="left";color=6052956;dl=1;dt=1;font=LOGFONT(h=-14);z=6};
caption={cls="bkplus";text="WinXray.COM V4.0";left=25;top=9;right=685;bottom=27;align="left";color=6052956;dl=1;dt=1;font=LOGFONT(h=-14);z=6};
custom={cls="custom";left=83;top=40;right=1022;bottom=679;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;z=3};
navBar={cls="bkplus";left=0;top=37;right=83;bottom=681;bgcolor=3442175;db=1;dl=1;dt=1;z=1};
navJsonConfig={cls="plus";text="配置";left=0;top=132;right=85;bottom=212;bkBottom=3;bkLeft=7;bkRight=8;bkTop=2;border={color=-65536};color=16777215;dl=1;dt=1;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-37;name='FontAwesome');padding={bottom=20}};iconText='\uF0F6';notify=1;textPadding={bottom=10};valign="bottom";x=0.5;y=0.2;z=5};
Expand Down
Binary file modified release/WinXray.7z
Binary file not shown.
Binary file modified release/WinXray32.7z
Binary file not shown.
Binary file modified release/update/checksum.lzma
Binary file not shown.
Binary file modified release/update/files/WinXray.exe.lzma
Binary file not shown.
4 changes: 2 additions & 2 deletions release/update/version.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"description":"右键添加了清除重复节点功能!完善了二维码生成器代码!",
"description":"V4.0 修复清除重复节点BUG!",
"format":".lzma",
"main":"\\WinXray.exe",
"updater":"\\WinXray.exe",
"url":"https://raw.githubusercontent.com/TheMRLL/winxray/main/release/update/",
"version":"3.9"
"version":"4.0"
}
Binary file modified winXray/WinXray.exe
Binary file not shown.
1 change: 1 addition & 0 deletions xray-core/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"inbounds":[{"listen":"127.0.0.1","port":1081,"protocol":"socks","tag":"proxy","settings":{"auth":"noauth","udp":true},"sniffing":{"destOverride":["http","tls"],"enabled":true}},{"listen":"127.0.0.1","port":1082,"protocol":"http","tag":"http_proxy","settings":{},"sniffing":{"destOverride":["http","tls"],"enabled":true}}],"outbounds":[{"protocol":"shadowsocks","tag":"proxy","mux":{"concurrency":-1,"enabled":false},"settings":{"servers":[{"address":"173.82.160.210","level":0,"method":"chacha20-ietf-poly1305","ota":false,"password":"Z3YS0KxB8u5jgp736e834y3DaXwSOYzxlFDFqpNCaalDA9CEIRceZOCAnR2yTS","port":18334}]},"streamSettings":{"network":"tcp"}},{"protocol":"freedom","tag":"direct","settings":{}},{"protocol":"blackhole","tag":"block","settings":{"response":{"type":"http"}}}],"log":{"access":"","error":"","loglevel":"warning"},"routing":{"domainStrategy":"IPIfNonMatch","rules":[{"inboundTag":["api"],"outboundTag":"api","type":"field"}]}}

0 comments on commit 2e29803

Please sign in to comment.