Skip to content

Commit

Permalink
Finish 4.9.0
Browse files Browse the repository at this point in the history
添加 速度优先负载均衡(实验)
添加 订阅最近更新时间
界面 编辑节点显示横向滚动条,IPv6地址过滤
优化 更新订阅的排序和自动删除相同节点
优化 http请求使用自定义User-Agent
  • Loading branch information
AkaneAkaza committed Nov 23, 2017
1 parent 278ccdb commit 290e021
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 49 deletions.
4 changes: 2 additions & 2 deletions shadowsocks-csharp/Controller/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class UpdateChecker

public const string Name = "ShadowsocksR";
public const string Copyright = "Copyright © BreakWa11 2017. Fork from Shadowsocks by clowwindy";
public const string Version = "4.8.1";
public const string Version = "4.9.0";
#if !_DOTNET_4_0
public const string NetVer = "2.0";
#elif !_CONSOLE
Expand Down Expand Up @@ -50,7 +50,7 @@ public void CheckUpdate(Configuration config)
http.Headers.Add("User-Agent",
String.IsNullOrEmpty(config.proxyUserAgent) ?
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.3319.102 Safari/537.36"
: config.proxyUserAgent);
: config.proxyUserAgent);
if (UseProxy)
{
WebProxy proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort);
Expand Down
7 changes: 5 additions & 2 deletions shadowsocks-csharp/Controller/UpdateFreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ public class UpdateFreeNode

public event EventHandler NewFreeNodeFound;
public string FreeNodeResult;
public ServerSubscribe subscribeTask;

public const string Name = "ShadowsocksR";

public void CheckUpdate(Configuration config, string URL, bool use_proxy)
public void CheckUpdate(Configuration config, ServerSubscribe subscribeTask, bool use_proxy)
{
FreeNodeResult = null;
try
Expand All @@ -45,6 +46,8 @@ public void CheckUpdate(Configuration config, string URL, bool use_proxy)
http.Proxy = null;
}
//UseProxy = !UseProxy;
this.subscribeTask = subscribeTask;
string URL = subscribeTask.URL;
http.DownloadStringCompleted += http_DownloadStringCompleted;
http.DownloadStringAsync(new Uri(URL != null ? URL : UpdateURL));
}
Expand Down Expand Up @@ -124,7 +127,7 @@ public bool Next()
else
{
_URL = _serverSubscribes[0].URL;
_updater.CheckUpdate(_config, _URL, _use_proxy);
_updater.CheckUpdate(_config, _serverSubscribes[0], _use_proxy);
_serverSubscribes.RemoveAt(0);
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions shadowsocks-csharp/Data/cn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Proxy With Rule=规则代理
Subscribe Settings=订阅设置
URL=网址
Group name=组名
Last Update=最近更新
Auto update=自动更新

# Messages
Expand Down Expand Up @@ -238,6 +239,6 @@ Failed to update registry=无法修改注册表
System Proxy On: =系统代理已启用:
Running: Port {0}=正在运行:端口 {0}
Password NOT match=密码不匹配
Update subscribe SSR node success=SSR服务器订阅更新成功
Update subscribe SSR node failure=SSR服务器订阅更新失败
Update subscribe {0} success=服务器订阅 {0} 更新成功
Update subscribe {0} failure=服务器订阅 {0} 更新失败
Success=成功
5 changes: 3 additions & 2 deletions shadowsocks-csharp/Data/zh-tw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ Proxy With Rule=規則代理
Subscribe Settings=訂閱設置
URL=網址
Group name=組名
Last Update=最近更新
Auto update=自動更新

# Messages
Expand Down Expand Up @@ -226,6 +227,6 @@ Failed to update registry=無法修改註冊表
System Proxy On: =系統代理已啟用:
Running: Port {0}=正在運行:連接埠 {0}
Password NOT match=密碼不匹配
Update subscribe SSR node success=SSR伺服器訂閱更新成功
Update subscribe SSR node failure=SSR伺服器訂閱更新失敗
Update subscribe {0} success=伺服器訂閱 {0} 更新成功
Update subscribe {0} failure=伺服器訂閱 {0} 更新失敗
Success=成功
1 change: 1 addition & 0 deletions shadowsocks-csharp/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class ServerSubscribe

public string URL = DEFAULT_FEED_URL;
public string Group;
public UInt64 LastUpdateTime;
}

public class GlobalConfiguration
Expand Down
26 changes: 18 additions & 8 deletions shadowsocks-csharp/Obfs/AuthChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ namespace Shadowsocks.Obfs
class xorshift128plus
{
protected UInt64 v0, v1;
protected int init_loop;

public xorshift128plus()
public xorshift128plus(int init_loop_ = 4)
{
v0 = v1 = 0;
init_loop = init_loop_;
}

public UInt64 next()
Expand Down Expand Up @@ -42,7 +44,7 @@ public void init_from_bin(byte[] bytes, int datalength)
BitConverter.GetBytes((ushort)datalength).CopyTo(fill_bytes, 0);
v0 = BitConverter.ToUInt64(fill_bytes, 0);
v1 = BitConverter.ToUInt64(fill_bytes, 8);
for (int i = 0; i < 4; ++i)
for (int i = 0; i < init_loop; ++i)
{
next();
}
Expand Down Expand Up @@ -202,6 +204,11 @@ public void PackData(byte[] data, int datalength, byte[] outdata, out int outlen
}
}

public virtual void OnInitAuthData(UInt64 unixTimestamp)
{

}

public void PackAuthData(byte[] data, int datalength, byte[] outdata, out int outlength)
{
const int authhead_len = 4 + 8 + 4 + 16 + 4;
Expand Down Expand Up @@ -234,6 +241,7 @@ public void PackAuthData(byte[] data, int datalength, byte[] outdata, out int ou
UInt64 utc_time_second = (UInt64)Math.Floor(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds);
UInt32 utc_time = (UInt32)(utc_time_second);
Array.Copy(BitConverter.GetBytes(utc_time), 0, encrypt, 0, 4);
OnInitAuthData(utc_time_second);

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

protected void InitDataSizeList()
protected virtual void InitDataSizeList()
{
xorshift128plus random = new xorshift128plus();
random.init_from_bin(Server.key);
Expand Down Expand Up @@ -683,7 +691,7 @@ public override Dictionary<string, int[]> GetObfs()
return _obfs;
}

protected new void InitDataSizeList()
protected override void InitDataSizeList()
{
xorshift128plus random = new xorshift128plus();
random.init_from_bin(Server.key);
Expand Down Expand Up @@ -760,7 +768,7 @@ protected void CheckAndPatchDataSize(List<int> data_list, xorshift128plus random
}
}

protected new void InitDataSizeList()
protected override void InitDataSizeList()
{
xorshift128plus random = new xorshift128plus();
random.init_from_bin(Server.key);
Expand Down Expand Up @@ -866,7 +874,7 @@ public override Dictionary<string, int[]> GetObfs()
protected UInt64 key_change_datetime_key;
protected List<byte> key_change_datetime_key_bytes = new List<byte>();

protected new void InitDataSizeList()
protected override void InitDataSizeList()
{
xorshift128plus random = new xorshift128plus();
byte[] newKey = new byte[Server.key.Length];
Expand Down Expand Up @@ -908,8 +916,10 @@ public override void SetServerInfo(ServerInfo serverInfo)
key_change_interval = interval;
}
}
// https://stackoverflow.com/a/17632585/3548568
UInt64 unixTimestamp = (UInt64)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
}

public override void OnInitAuthData(UInt64 unixTimestamp)
{
key_change_datetime_key = unixTimestamp / key_change_interval;
for (int i = 7; i > -1; --i)
{
Expand Down
17 changes: 13 additions & 4 deletions shadowsocks-csharp/View/MenuViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ void controller_UpdatePACFromGFWListCompleted(object sender, GFWListUpdater.Resu

void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
{
string lastGroup = null;
int count = 0;
if (!String.IsNullOrEmpty(updateFreeNodeChecker.FreeNodeResult))
{
Expand Down Expand Up @@ -389,7 +390,6 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
if (!config.isDefaultConfig())
keep_selected_server = true;
}
string lastGroup = null;
string curGroup = null;
foreach (string url in urls)
{
Expand Down Expand Up @@ -556,19 +556,28 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
{
config.index = config.configs.Count - 1;
}
if (count > 0)
{
for (int i = 0; i < config.serverSubscribes.Count; ++i)
{
if (config.serverSubscribes[i].URL == updateFreeNodeChecker.subscribeTask.URL)
{
config.serverSubscribes[i].LastUpdateTime = (UInt64)Math.Floor(DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds);
}
}
}
controller.SaveServersConfig(config);

}
}
if (count > 0)
{
ShowBalloonTip(I18N.GetString("Success"),
I18N.GetString("Update subscribe SSR node success"), ToolTipIcon.Info, 10000);
String.Format(I18N.GetString("Update subscribe {0} success"), lastGroup), ToolTipIcon.Info, 10000);
}
else
{
ShowBalloonTip(I18N.GetString("Error"),
I18N.GetString("Update subscribe SSR node failure"), ToolTipIcon.Info, 10000);
String.Format(I18N.GetString("Update subscribe {0} failure"), lastGroup), ToolTipIcon.Info, 10000);
}
if (updateSubscribeManager.Next())
{
Expand Down
67 changes: 45 additions & 22 deletions shadowsocks-csharp/View/SubscribeForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 290e021

Please sign in to comment.