mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-03 05:38:51 +00:00
add shadowsocks SIP008 https://shadowsocks.org/en/wiki/SIP008-Online-Configuration-Delivery.html
This commit is contained in:
parent
d5aa307efb
commit
b29fb1e2a3
3 changed files with 78 additions and 0 deletions
|
@ -1033,6 +1033,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 +1097,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)
|
||||||
{
|
{
|
||||||
|
|
22
v2rayN/v2rayN/Mode/SsSIP008.cs
Normal file
22
v2rayN/v2rayN/Mode/SsSIP008.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue