Compare commits

..

5 Commits
5.22 ... 5.23

Author SHA1 Message Date
2dust
e256ec5401 Update ConfigHandler.cs 2022-05-06 14:37:52 +08:00
2dust
3defba6290 Update ConfigHandler.cs 2022-05-06 13:35:30 +08:00
2dust
c201d986c5 Update AssemblyInfo.cs 2022-05-06 13:33:29 +08:00
2dust
36aad4424e Fix issue when saving gui config 2022-05-06 10:54:10 +08:00
2dust
b29fb1e2a3 add shadowsocks SIP008 https://shadowsocks.org/en/wiki/SIP008-Online-Configuration-Delivery.html 2022-05-02 20:15:19 +08:00
5 changed files with 92 additions and 9 deletions

View File

@@ -123,7 +123,10 @@ namespace v2rayN.Forms
{ {
try try
{ {
v2rayHandler.V2rayStop(); Utils.SaveLog("MyAppExit Begin");
StorageUI();
ConfigHandler.SaveConfig(ref config);
//HttpProxyHandle.CloseHttpAgent(config); //HttpProxyHandle.CloseHttpAgent(config);
if (blWindowsShutDown) if (blWindowsShutDown)
@@ -135,10 +138,11 @@ namespace v2rayN.Forms
SysProxyHandle.UpdateSysProxy(config, true); SysProxyHandle.UpdateSysProxy(config, true);
} }
StorageUI();
ConfigHandler.SaveConfig(ref config);
statistics?.SaveToFile(); statistics?.SaveToFile();
statistics?.Close(); statistics?.Close();
v2rayHandler.V2rayStop();
Utils.SaveLog("MyAppExit End");
} }
catch { } catch { }
} }

View File

@@ -212,18 +212,19 @@ namespace v2rayN.Handler
{ {
//save temp file //save temp file
var temp = $"{configRes}_temp"; var resPath = Utils.GetPath(configRes);
if (Utils.ToJsonFile(config, Utils.GetPath(temp)) != 0) var tempPath = $"{resPath}_temp";
if (Utils.ToJsonFile(config, tempPath) != 0)
{ {
return; return;
} }
if (File.Exists(configRes)) if (File.Exists(resPath))
{ {
File.Delete(configRes); File.Delete(resPath);
} }
//rename //rename
File.Move(temp, configRes); File.Move(tempPath, resPath);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1033,6 +1034,56 @@ namespace v2rayN.Handler
} }
} }
private static int AddBatchServers4SsSIP008(ref Config config, string clipboardData, string subid, List<VmessItem> lstOriSub, string groupId)
{
if (Utils.IsNullOrEmpty(clipboardData))
{
return -1;
}
if (!Utils.IsNullOrEmpty(subid))
{
RemoveServerViaSubid(ref config, subid);
}
//SsSIP008
var lstSsServer = Utils.FromJson<List<SsServer>>(clipboardData);
if (lstSsServer == null || lstSsServer.Count <= 0)
{
var ssSIP008 = Utils.FromJson<SsSIP008>(clipboardData);
if (ssSIP008 != null && ssSIP008.servers != null && ssSIP008.servers.Count > 0)
{
lstSsServer = ssSIP008.servers;
}
}
if (lstSsServer != null && lstSsServer.Count > 0)
{
int counter = 0;
foreach (var it in lstSsServer)
{
var ssItem = new VmessItem()
{
subid = subid,
groupId = groupId,
remarks = it.remarks,
security = it.method,
id = it.password,
address = it.server,
port = Utils.ToInt(it.server_port)
};
if (AddShadowsocksServer(ref config, ssItem, false) == 0)
{
counter++;
}
}
ToJsonFile(config);
return counter;
}
return -1;
}
public static int AddBatchServers(ref Config config, string clipboardData, string subid, string groupId) public static int AddBatchServers(ref Config config, string clipboardData, string subid, string groupId)
{ {
List<VmessItem> lstOriSub = null; List<VmessItem> lstOriSub = null;
@@ -1047,6 +1098,11 @@ namespace v2rayN.Handler
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, lstOriSub, groupId); counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, lstOriSub, groupId);
} }
if (counter < 1)
{
counter = AddBatchServers4SsSIP008(ref config, clipboardData, subid, lstOriSub, groupId);
}
//maybe other sub //maybe other sub
if (counter < 1) if (counter < 1)
{ {

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
namespace v2rayN.Mode
{
public class SsSIP008
{
public List<SsServer> servers { get; set; }
}
[Serializable]
public class SsServer
{
public string remarks { get; set; }
public string server { get; set; }
public string server_port { get; set; }
public string method { get; set; }
public string password { get; set; }
public string plugin { get; set; }
}
}

View File

@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”: // 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")] //[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("5.22")] [assembly: AssemblyFileVersion("5.23")]

View File

@@ -216,6 +216,7 @@
<Compile Include="Mode\SysproxyConfig.cs" /> <Compile Include="Mode\SysproxyConfig.cs" />
<Compile Include="Mode\EConfigType.cs" /> <Compile Include="Mode\EConfigType.cs" />
<Compile Include="Mode\ServerTestItem.cs" /> <Compile Include="Mode\ServerTestItem.cs" />
<Compile Include="Mode\SsSIP008.cs" />
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>