mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
Add shadowsocks subscription support
This commit is contained in:
13
Netch/Models/SS/ShadowsocksServer.cs
Normal file
13
Netch/Models/SS/ShadowsocksServer.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace Netch.Models.SS
|
||||||
|
{
|
||||||
|
public class ShadowsocksServer
|
||||||
|
{
|
||||||
|
public string server { get; set; }
|
||||||
|
public int server_port { get; set; }
|
||||||
|
public string password { get; set; }
|
||||||
|
public string method { get; set; }
|
||||||
|
public string remarks { get; set; }
|
||||||
|
public string plugin { get; set; }
|
||||||
|
public string plugin_opts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
using Netch.Models;
|
using Netch.Models;
|
||||||
|
using Netch.Models.SS;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using VMess = Netch.Models.VMess;
|
||||||
|
|
||||||
namespace Netch.Utils
|
namespace Netch.Utils
|
||||||
{
|
{
|
||||||
@@ -24,14 +28,33 @@ namespace Netch.Utils
|
|||||||
var list = new List<Server>();
|
var list = new List<Server>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var line in text.GetLines())
|
try
|
||||||
{
|
{
|
||||||
var servers = ParseLine(line);
|
var ssServers = JsonConvert.DeserializeObject<List<ShadowsocksServer>>(text);
|
||||||
if (line != null)
|
list.AddRange(ssServers.Select(shadowsocksServer => new Server
|
||||||
{
|
{
|
||||||
list.AddRange(servers);
|
Type = "SS",
|
||||||
|
Hostname = shadowsocksServer.server,
|
||||||
|
Port = shadowsocksServer.server_port,
|
||||||
|
EncryptMethod = shadowsocksServer.method,
|
||||||
|
Password = shadowsocksServer.password,
|
||||||
|
Remark = shadowsocksServer.remarks,
|
||||||
|
Plugin = shadowsocksServer.plugin,
|
||||||
|
PluginOption = shadowsocksServer.plugin_opts
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
catch (JsonReaderException)
|
||||||
|
{
|
||||||
|
foreach (var line in text.GetLines())
|
||||||
|
{
|
||||||
|
var servers = ParseLine(line);
|
||||||
|
if (line != null)
|
||||||
|
{
|
||||||
|
list.AddRange(servers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.Count == 0)
|
if (list.Count == 0)
|
||||||
{
|
{
|
||||||
System.Windows.Forms.MessageBox.Show(@"未找到可导入的链接!", @"错误", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
System.Windows.Forms.MessageBox.Show(@"未找到可导入的链接!", @"错误", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||||
|
|||||||
Reference in New Issue
Block a user