Skip to content

Commit

Permalink
V 3.1 修复右键新增/编辑代理服务器切换协议报错的问题以及优化代码!
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMRLL authored Mar 16, 2021
1 parent 762fc36 commit fa64dde
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 75 deletions.
6 changes: 3 additions & 3 deletions default.aproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?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.0" ProductVersion="3.0" 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="3.1" ProductVersion="3.1" 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"/>
</folder>
<folder name="main" path="forms\main" comment="forms\main">
<folder name="main" path="forms\main" comment="forms\main" local="false" embed="false" ignored="false">
<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"/>
Expand Down
108 changes: 65 additions & 43 deletions forms/main/outbound.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ btnGenGuid={cls="plus";text="生成";left=914;top=259;right=986;bottom=284;align
btnImportSharedLink={cls="plus";text="导入";left=912;top=471;right=984;bottom=496;align="left";clip=1;db=1;dr=1;font=LOGFONT(h=-13);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=12}};iconText='\uF0C1';notify=1;textPadding={left=30};z=21};
btnInsertField={cls="plus";text="插入更多配置字段";left=10;top=0;right=191;bottom=24;align="left";dl=1;dt=1;font=LOGFONT(h=-13);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=12}};iconText='\uF196 ';notify=1;textPadding={left=30};z=18};
btnSaveOutbound={cls="plus";text="保 存";left=826;top=410;right=929;bottom=446;align="left";bgcolor=11580047;db=1;disabled=1;dr=1;font=LOGFONT(h=-13);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=22}};iconText='\uF0C7';notify=1;textPadding={left=40};z=16};
btnUpdateCore={cls="plus";text="下载 / 更新 NaÏveProxy Core";left=637;top=61;right=979;bottom=89;align="left";color=3947580;dl=1;dt=1;font=LOGFONT(h=-13);iconStyle={align="left";font=LOGFONT(h=-17;name='FontAwesome');padding={left=18}};iconText='\uF0AB';notify=1;textPadding={left=50};z=23};
btnUpdateCore={cls="plus";text="下载 / 更新 NaÏveProxy Core";left=637;top=61;right=979;bottom=89;align="left";color=3947580;dr=1;dt=1;font=LOGFONT(h=-13);iconStyle={align="left";font=LOGFONT(h=-17;name='FontAwesome');padding={left=18}};iconText='\uF0AB';notify=1;textPadding={left=50};z=23};
cmbNetwork={cls="combobox";left=656;top=97;right=814;bottom=123;dr=1;dt=1;edge=1;items={"tcp";"kcp";"ws";"h2";"quic"};mode="dropdown";z=13};
cmbProtocol={cls="combobox";left=656;top=28;right=814;bottom=54;dr=1;dt=1;edge=1;items={"vmess";"vless";"trojan";"trojan-go";"ssr";"shadowsocks";"naive";"socks"};mode="dropdown";z=12};
cmbProtocol={cls="combobox";left=656;top=28;right=814;bottom=54;dr=1;dt=1;edge=1;items={"vmess";"vless";"trojan";"trojan-go";"ssr";"shadowsocks";"naive";"socks";"https";"http"};mode="dropdown";z=12};
cmbSecurity={cls="combobox";left=656;top=140;right=814;bottom=166;dr=1;dt=1;edge=1;items={"auto";"none";"chacha20-poly1305";"aes-128-gcm"};mode="dropdown";z=15};
editAddress={cls="plus";left=656;top=183;right=878;bottom=207;align="left";bgcolor=16777215;border={bottom=1;color=-8355712};dr=1;dt=1;editable="edit";font=LOGFONT(h=-16);textPadding={bottom=1};z=2};
editId={cls="plus";left=656;top=263;right=986;bottom=287;align="left";bgcolor=16777215;border={bottom=1;color=-8355712};clip=1;dr=1;dt=1;editable="edit";font=LOGFONT(h=-16);textPadding={right=75;bottom=1};z=20};
editId={cls="plus";left=656;top=263;right=986;bottom=287;align="left";bgcolor=16777215;border={bottom=1;color=-8355712};clip=1;dr=1;dt=1;editable="edit";font=LOGFONT(h=-16);notify=1;textPadding={right=75;bottom=1};z=20};
editOutbound={cls="edit";left=15;top=25;right=472;bottom=462;db=1;dl=1;dr=1;dt=1;edge=1;font=LOGFONT(h=-13);hscroll=1;multiline=1;vscroll=1;z=14};
editPort={cls="plus";left=656;top=224;right=745;bottom=248;align="left";bgcolor=16777215;border={bottom=1;color=-8355712};dr=1;dt=1;editable="edit";font=LOGFONT(h=-16);textPadding={bottom=1};z=4};
editPort={cls="plus";left=656;top=224;right=745;bottom=248;align="left";bgcolor=16777215;border={bottom=1;color=-8355712};dr=1;dt=1;editable="edit";font=LOGFONT(h=-16);num=1;textPadding={bottom=1};z=4};
editPs={cls="plus";left=656;top=306;right=878;bottom=330;align="left";bgcolor=16777215;border={bottom=1;color=-8355712};dr=1;dt=1;editable="edit";font=LOGFONT(h=-16);textPadding={bottom=1};z=7};
editSharedLink={cls="plus";left=13;top=475;right=986;bottom=499;align="left";bgcolor=16777215;border={bottom=1;color=-8355712};clip=1;db=1;dl=1;dr=1;font=LOGFONT(h=-16);notify=1;textPadding={right=150;bottom=1};z=22};
lbId={cls="static";text="登录用户( id ):";left=492;top=262;right=641;bottom=288;align="right";bgcolor=16777215;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=6};
lbSecurity={cls="static";text="加密方式( security ):";left=473;top=136;right=641;bottom=162;align="right";bgcolor=16777215;dl=1;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=10};
qrPicture={cls="plus";left=510;top=358;right=606;bottom=454;bgcolor=16777215;db=1;dr=1;notify=1;repeat="scale";z=24};
static={cls="static";text="服务器( address ):";left=481;top=178;right=641;bottom=204;align="right";bgcolor=16777215;dl=1;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=3};
static10={cls="static";text="代理协议( protocol ):";left=473;top=26;right=641;bottom=52;align="right";bgcolor=16777215;dl=1;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=11};
static2={cls="static";text="端口( port ):";left=498;top=220;right=641;bottom=246;align="right";bgcolor=16777215;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=5};
static3={cls="static";text="密码( id ):";left=498;top=262;right=641;bottom=288;align="right";bgcolor=16777215;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=6};
static2={cls="static";text="服务端口( port ):";left=498;top=220;right=641;bottom=246;align="right";bgcolor=16777215;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=5};
static4={cls="static";text="备注( ps ):";left=498;top=304;right=641;bottom=330;align="right";bgcolor=16777215;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=8};
static5={cls="static";text="传输协议( network ):";left=473;top=94;right=641;bottom=126;align="right";bgcolor=16777215;dl=1;dr=1;dt=1;font=LOGFONT(h=-16);transparent=1;z=9}
)
Expand All @@ -43,7 +43,7 @@ winform.addOutboundField = function(k,v){
winform.updateSharedLink();
}

winform.cmbProtocol.onListChange = function(){
winform.cmbProtocol.onProtocolChange = function(){
var sel = winform.cmbProtocol.selText;
if(sel=="vmess"){
winform.cmbSecurity.items = {
Expand All @@ -58,6 +58,7 @@ winform.cmbProtocol.onListChange = function(){
winform.cmbNetwork.selIndex = 1;
winform.outboundConfig.network = "tcp";
winform.btnUpdateCore.text = '下载 / 更新支持组件: xray Core';
winform.editId.setCueBannerText("请输入 GUID");
}
elseif(sel=="shadowsocks"){
winform.cmbSecurity.items = {
Expand All @@ -71,6 +72,7 @@ winform.cmbProtocol.onListChange = function(){
winform.cmbNetwork.selIndex = 1;
winform.outboundConfig.network = "tcp";
winform.btnUpdateCore.text = '下载 / 更新支持组件: xray Core';
winform.editId.setCueBannerText("请输入密码");
}
elseif(sel=="ssr"){
winform.cmbNetwork.items = {
Expand All @@ -86,6 +88,7 @@ winform.cmbProtocol.onListChange = function(){
winform.cmbSecurity.selIndex = 1;
winform.outboundConfig.security = "none";
winform.btnUpdateCore.text = '下载 / 更新支持组件: SSR Core';
winform.editId.setCueBannerText("请输入密码");
}
elseif(sel=="vless"){
winform.cmbSecurity.items = {
Expand All @@ -99,7 +102,8 @@ winform.cmbProtocol.onListChange = function(){
}
winform.cmbNetwork.selIndex = 1;
winform.outboundConfig.network = "tcp";
winform.btnUpdateCore.text = '下载 / 更新支持组件: Xray Core';
winform.btnUpdateCore.text = '下载 / 更新支持组件: v2ray Core';
winform.editId.setCueBannerText("请输入 GUID");
}
elseif(sel=="naive"){
winform.cmbNetwork.items = {
Expand All @@ -110,23 +114,29 @@ winform.cmbProtocol.onListChange = function(){

winform.cmbSecurity.items = {}
winform.outboundConfig.security = null;

if(!string.indexOf(winform.editId.text:"",":")){
winform.editId.text = "username:password";
}

winform.btnUpdateCore.text = '下载 / 更新支持组件: NaïveProxy Core';
winform.editId.setCueBannerText("请输入 用户名:密码");
}
elseif(sel=="socks"){
winform.cmbSecurity.items = { }
winform.outboundConfig.security = null;

winform.cmbNetwork.items = {"tcp";}
winform.cmbNetwork.selIndex = 1;
winform.outboundConfig.network = "tcp";
if(!string.indexOf(winform.editId.text:"",":")){
winform.editId.text = "username:password";
}
winform.outboundConfig.network = "tcp";
winform.btnUpdateCore.text = '下载 / 更新支持组件: xray Core';
winform.editId.setCueBannerText("请输入 用户名:密码");
}
elseif(sel=="http" || sel=="https"){
winform.cmbSecurity.items = { }
winform.outboundConfig.security = null;

winform.cmbNetwork.items = {"tcp";}
winform.cmbNetwork.selIndex = 1;
winform.outboundConfig.network = "tcp";
winform.btnUpdateCore.text = '下载 / 更新支持组件: xray Core';
winform.editId.setCueBannerText("请输入 用户名:密码");
}
else {
winform.cmbSecurity.items = { }
Expand All @@ -136,10 +146,15 @@ winform.cmbProtocol.onListChange = function(){
winform.cmbNetwork.selIndex = 1;
winform.outboundConfig.network = "tcp";
winform.btnUpdateCore.text = '下载 / 更新支持组件: xray Core';
winform.editId.setCueBannerText("请输入密码");
}
}

winform.cmbProtocol.onListChange = function(){
winform.cmbProtocol.onProtocolChange();

table.define(winform.outboundConfig);
winform.outboundConfig.protocol = sel;
winform.outboundConfig.protocol = winform.cmbProtocol.selText;;
winform.editOutbound.text = web.json.stringify(winform.outboundConfig,true,false);
winform.updateSharedLink();
}
Expand All @@ -158,8 +173,12 @@ winform.cmbSecurity.onListChange = function(){
winform.updateSharedLink();
}

winform.editId.editBox.onChange = function(){
winform.outboundConfig.id = owner.text;
winform.editId.editBox.onChange = function(){
if( winform.outboundConfig.id == winform.editId.text ){
return;
}

winform.outboundConfig.id = winform.editId.text;
winform.editOutbound.text = web.json.stringify(winform.outboundConfig,true,false);
winform.updateSharedLink();
}
Expand Down Expand Up @@ -285,7 +304,7 @@ var insertFieldMenu = {
};
{ "SSR混淆插件:obfs";
function(id){
winform.addOutboundField("obfs","plain");
winform.addOutboundField("obfs","");
}
};
{ "SSR混淆参数:obfsParam";
Expand Down Expand Up @@ -369,19 +388,7 @@ var onEditChange = win.debounce(

winform.cmbNetwork.selText = data.network;
winform.cmbProtocol.selText = data.protocol;

if(data.protocol=="vmess"){
winform.cmbSecurity.items = { "auto";"none";"chacha20-poly1305";"aes-128-gcm" }
}
elseif(data.protocol=="shadowsocks"){
winform.cmbSecurity.items = { "aes-256-gcm";"aes-128-gcm";"aes-256-cfb";"aes-128-cfb";"chacha20";"chacha20-ietf";"chacha20-poly1305";"chacha20-ietf-poly1305";}
}
elseif(data.protocol=="vless"){
winform.cmbSecurity.items = { "none"; }
}
else {
winform.cmbSecurity.items = { }
}
winform.cmbProtocol.onProtocolChange();
winform.cmbSecurity.selText = data.security;

winform.cmbNetwork.onListChange = cmbNetworkChange;
Expand All @@ -405,8 +412,11 @@ winform.btnSaveOutbound.oncommand = function(id,event){
return winform.editPort.editBox.showErrorTip("配置错误","端口不能为空")
}

if(!#winform.editId.text && (winform.outboundConfig.protocol!="socks") ){
return winform.editId.editBox.showErrorTip("配置错误","当前代理协议密码不能为空")
if( !#winform.editId.text ){
var protocol = winform.outboundConfig.protocol;
if((protocol!="socks") && (protocol!="http") && (protocol!="https")){
return winform.editId.editBox.showErrorTip("配置错误","当前代理协议密码不能为空")
}
}

table.assign(winform.origOutboundConfig,winform.outboundConfig);
Expand All @@ -427,8 +437,11 @@ winform.btnAddOutbound.oncommand = function(id,event){
return winform.editPort.editBox.showErrorTip("配置错误","端口不能为空")
}

if(!#winform.editId.text && (winform.outboundConfig.protocol!="socks") ){
return winform.editId.editBox.showErrorTip("配置错误","当前代理协议密码不能为空")
if(!#winform.editId.text ){
var protocol = winform.outboundConfig.protocol
if( (protocol!="socks") && (protocol!="http") && (protocol!="https") ){
return winform.editId.editBox.showErrorTip("配置错误","当前代理协议密码不能为空")
}
}

table.push(config.proxy.outbounds,winform.outboundConfig);
Expand All @@ -440,8 +453,17 @@ winform.btnAddOutbound.oncommand = function(id,event){

import win.guid;
winform.btnGenGuid.oncommand = function(id,event){
var guid = win.guid.create();
winform.editId.text = string.lower( tostring(guid) );
var sel = winform.cmbProtocol.selText;
if(sel=="socks" || sel=="http" || sel=="https" || sel=="naive" ){
winform.editId.text = "user:" + string.random(16);
}
elseif(sel=="shadowsocks" || sel=="ssr" ){
winform.editId.text = string.random(22,"/@0123456abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
else {
var guid = win.guid.create();
winform.editId.text = string.lower( tostring(guid) );
}
}
winform.btnGenGuid.skin(style.link)

Expand Down Expand Up @@ -544,16 +566,16 @@ winform.btnUpdateCore.oncommand = function(id,event){
}
}
elseif(sel=="vless"){
import xray.core.xray;
var versionTag = xray.core.xray.updateCore();
import xray.core.v2ray;
var versionTag = xray.core.v2ray.updateCore();
if( versionTag ){
publish("uiCommand.restartxrayCore");
winform.btnUpdateCore.disabledText = null;
winform.msgOk("已下载最新 XRay Core 版本:" + versionTag+ '\nxray 内核已切换为:XRay Core',1500)
winform.msgOk("已下载最新 v2ray Core 版本:" + versionTag+ '\nxray 内核已切换为:v2ray Core',1500)
}
else {
winform.btnUpdateCore.disabledText = null;
winform.msgErr("XRay Core 下载失败!");
winform.msgErr("v2ray Core 下载失败!");
}
}
elseif(sel=="naive"){
Expand Down
4 changes: 2 additions & 2 deletions lib/xray/core/_.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ getPath = function(hwnd){
..publish("uiCommand.print","下载后请解压到以下目录内:");
..publish("uiCommand.print",..io.appData("/WinXray/core/"));

import process;
process.execute(..io._exepath,"/github","runas");
//import process;
//process.execute(..io._exepath,"/github","runas");
}
}

Expand Down
Loading

0 comments on commit fa64dde

Please sign in to comment.