Skip to content

Commit 290e021

Browse files
committed
Finish 4.9.0
添加 速度优先负载均衡(实验) 添加 订阅最近更新时间 界面 编辑节点显示横向滚动条,IPv6地址过滤 优化 更新订阅的排序和自动删除相同节点 优化 http请求使用自定义User-Agent
1 parent 278ccdb commit 290e021

9 files changed

+107
-49
lines changed

shadowsocks-csharp/Controller/UpdateChecker.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class UpdateChecker
2121

2222
public const string Name = "ShadowsocksR";
2323
public const string Copyright = "Copyright © BreakWa11 2017. Fork from Shadowsocks by clowwindy";
24-
public const string Version = "4.8.1";
24+
public const string Version = "4.9.0";
2525
#if !_DOTNET_4_0
2626
public const string NetVer = "2.0";
2727
#elif !_CONSOLE
@@ -50,7 +50,7 @@ public void CheckUpdate(Configuration config)
5050
http.Headers.Add("User-Agent",
5151
String.IsNullOrEmpty(config.proxyUserAgent) ?
5252
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.3319.102 Safari/537.36"
53-
: config.proxyUserAgent);
53+
: config.proxyUserAgent);
5454
if (UseProxy)
5555
{
5656
WebProxy proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort);

shadowsocks-csharp/Controller/UpdateFreeNode.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ public class UpdateFreeNode
1717

1818
public event EventHandler NewFreeNodeFound;
1919
public string FreeNodeResult;
20+
public ServerSubscribe subscribeTask;
2021

2122
public const string Name = "ShadowsocksR";
2223

23-
public void CheckUpdate(Configuration config, string URL, bool use_proxy)
24+
public void CheckUpdate(Configuration config, ServerSubscribe subscribeTask, bool use_proxy)
2425
{
2526
FreeNodeResult = null;
2627
try
@@ -45,6 +46,8 @@ public void CheckUpdate(Configuration config, string URL, bool use_proxy)
4546
http.Proxy = null;
4647
}
4748
//UseProxy = !UseProxy;
49+
this.subscribeTask = subscribeTask;
50+
string URL = subscribeTask.URL;
4851
http.DownloadStringCompleted += http_DownloadStringCompleted;
4952
http.DownloadStringAsync(new Uri(URL != null ? URL : UpdateURL));
5053
}
@@ -124,7 +127,7 @@ public bool Next()
124127
else
125128
{
126129
_URL = _serverSubscribes[0].URL;
127-
_updater.CheckUpdate(_config, _URL, _use_proxy);
130+
_updater.CheckUpdate(_config, _serverSubscribes[0], _use_proxy);
128131
_serverSubscribes.RemoveAt(0);
129132
return true;
130133
}

shadowsocks-csharp/Data/cn.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ Proxy With Rule=规则代理
207207
Subscribe Settings=订阅设置
208208
URL=网址
209209
Group name=组名
210+
Last Update=最近更新
210211
Auto update=自动更新
211212

212213
# Messages
@@ -238,6 +239,6 @@ Failed to update registry=无法修改注册表
238239
System Proxy On: =系统代理已启用:
239240
Running: Port {0}=正在运行:端口 {0}
240241
Password NOT match=密码不匹配
241-
Update subscribe SSR node success=SSR服务器订阅更新成功
242-
Update subscribe SSR node failure=SSR服务器订阅更新失败
242+
Update subscribe {0} success=服务器订阅 {0} 更新成功
243+
Update subscribe {0} failure=服务器订阅 {0} 更新失败
243244
Success=成功

shadowsocks-csharp/Data/zh-tw.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ Proxy With Rule=規則代理
195195
Subscribe Settings=訂閱設置
196196
URL=網址
197197
Group name=組名
198+
Last Update=最近更新
198199
Auto update=自動更新
199200

200201
# Messages
@@ -226,6 +227,6 @@ Failed to update registry=無法修改註冊表
226227
System Proxy On: =系統代理已啟用:
227228
Running: Port {0}=正在運行:連接埠 {0}
228229
Password NOT match=密碼不匹配
229-
Update subscribe SSR node success=SSR伺服器訂閱更新成功
230-
Update subscribe SSR node failure=SSR伺服器訂閱更新失敗
230+
Update subscribe {0} success=伺服器訂閱 {0} 更新成功
231+
Update subscribe {0} failure=伺服器訂閱 {0} 更新失敗
231232
Success=成功

shadowsocks-csharp/Model/Configuration.cs

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class ServerSubscribe
7171

7272
public string URL = DEFAULT_FEED_URL;
7373
public string Group;
74+
public UInt64 LastUpdateTime;
7475
}
7576

7677
public class GlobalConfiguration

shadowsocks-csharp/Obfs/AuthChain.cs

+18-8
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ namespace Shadowsocks.Obfs
1010
class xorshift128plus
1111
{
1212
protected UInt64 v0, v1;
13+
protected int init_loop;
1314

14-
public xorshift128plus()
15+
public xorshift128plus(int init_loop_ = 4)
1516
{
1617
v0 = v1 = 0;
18+
init_loop = init_loop_;
1719
}
1820

1921
public UInt64 next()
@@ -42,7 +44,7 @@ public void init_from_bin(byte[] bytes, int datalength)
4244
BitConverter.GetBytes((ushort)datalength).CopyTo(fill_bytes, 0);
4345
v0 = BitConverter.ToUInt64(fill_bytes, 0);
4446
v1 = BitConverter.ToUInt64(fill_bytes, 8);
45-
for (int i = 0; i < 4; ++i)
47+
for (int i = 0; i < init_loop; ++i)
4648
{
4749
next();
4850
}
@@ -202,6 +204,11 @@ public void PackData(byte[] data, int datalength, byte[] outdata, out int outlen
202204
}
203205
}
204206

207+
public virtual void OnInitAuthData(UInt64 unixTimestamp)
208+
{
209+
210+
}
211+
205212
public void PackAuthData(byte[] data, int datalength, byte[] outdata, out int outlength)
206213
{
207214
const int authhead_len = 4 + 8 + 4 + 16 + 4;
@@ -234,6 +241,7 @@ public void PackAuthData(byte[] data, int datalength, byte[] outdata, out int ou
234241
UInt64 utc_time_second = (UInt64)Math.Floor(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds);
235242
UInt32 utc_time = (UInt32)(utc_time_second);
236243
Array.Copy(BitConverter.GetBytes(utc_time), 0, encrypt, 0, 4);
244+
OnInitAuthData(utc_time_second);
237245

238246
encrypt[12] = (byte)(Server.overhead);
239247
encrypt[13] = (byte)(Server.overhead >> 8);
@@ -572,7 +580,7 @@ public override Dictionary<string, int[]> GetObfs()
572580
return _obfs;
573581
}
574582

575-
protected void InitDataSizeList()
583+
protected virtual void InitDataSizeList()
576584
{
577585
xorshift128plus random = new xorshift128plus();
578586
random.init_from_bin(Server.key);
@@ -683,7 +691,7 @@ public override Dictionary<string, int[]> GetObfs()
683691
return _obfs;
684692
}
685693

686-
protected new void InitDataSizeList()
694+
protected override void InitDataSizeList()
687695
{
688696
xorshift128plus random = new xorshift128plus();
689697
random.init_from_bin(Server.key);
@@ -760,7 +768,7 @@ protected void CheckAndPatchDataSize(List<int> data_list, xorshift128plus random
760768
}
761769
}
762770

763-
protected new void InitDataSizeList()
771+
protected override void InitDataSizeList()
764772
{
765773
xorshift128plus random = new xorshift128plus();
766774
random.init_from_bin(Server.key);
@@ -866,7 +874,7 @@ public override Dictionary<string, int[]> GetObfs()
866874
protected UInt64 key_change_datetime_key;
867875
protected List<byte> key_change_datetime_key_bytes = new List<byte>();
868876

869-
protected new void InitDataSizeList()
877+
protected override void InitDataSizeList()
870878
{
871879
xorshift128plus random = new xorshift128plus();
872880
byte[] newKey = new byte[Server.key.Length];
@@ -908,8 +916,10 @@ public override void SetServerInfo(ServerInfo serverInfo)
908916
key_change_interval = interval;
909917
}
910918
}
911-
// https://stackoverflow.com/a/17632585/3548568
912-
UInt64 unixTimestamp = (UInt64)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
919+
}
920+
921+
public override void OnInitAuthData(UInt64 unixTimestamp)
922+
{
913923
key_change_datetime_key = unixTimestamp / key_change_interval;
914924
for (int i = 7; i > -1; --i)
915925
{

shadowsocks-csharp/View/MenuViewController.cs

+13-4
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ void controller_UpdatePACFromGFWListCompleted(object sender, GFWListUpdater.Resu
335335

336336
void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
337337
{
338+
string lastGroup = null;
338339
int count = 0;
339340
if (!String.IsNullOrEmpty(updateFreeNodeChecker.FreeNodeResult))
340341
{
@@ -389,7 +390,6 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
389390
if (!config.isDefaultConfig())
390391
keep_selected_server = true;
391392
}
392-
string lastGroup = null;
393393
string curGroup = null;
394394
foreach (string url in urls)
395395
{
@@ -556,19 +556,28 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
556556
{
557557
config.index = config.configs.Count - 1;
558558
}
559+
if (count > 0)
560+
{
561+
for (int i = 0; i < config.serverSubscribes.Count; ++i)
562+
{
563+
if (config.serverSubscribes[i].URL == updateFreeNodeChecker.subscribeTask.URL)
564+
{
565+
config.serverSubscribes[i].LastUpdateTime = (UInt64)Math.Floor(DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds);
566+
}
567+
}
568+
}
559569
controller.SaveServersConfig(config);
560-
561570
}
562571
}
563572
if (count > 0)
564573
{
565574
ShowBalloonTip(I18N.GetString("Success"),
566-
I18N.GetString("Update subscribe SSR node success"), ToolTipIcon.Info, 10000);
575+
String.Format(I18N.GetString("Update subscribe {0} success"), lastGroup), ToolTipIcon.Info, 10000);
567576
}
568577
else
569578
{
570579
ShowBalloonTip(I18N.GetString("Error"),
571-
I18N.GetString("Update subscribe SSR node failure"), ToolTipIcon.Info, 10000);
580+
String.Format(I18N.GetString("Update subscribe {0} failure"), lastGroup), ToolTipIcon.Info, 10000);
572581
}
573582
if (updateSubscribeManager.Next())
574583
{

shadowsocks-csharp/View/SubscribeForm.Designer.cs

+45-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)