Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: shadowsocksr-rm/shadowsocksr-csharp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: shadowsocksrr/shadowsocksr-csharp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Jul 31, 2017

  1. Copy the full SHA
    3aca7dd View commit details
  2. breakwa11/shadowsocks-rss/wiki to shadowsocksrr/shadowsocks-rss/wiki

    Only the aboutItem not change
    Akkariiin committed Jul 31, 2017
    Copy the full SHA
    64abbc4 View commit details

Commits on Aug 2, 2017

  1. Copy the full SHA
    d353522 View commit details
  2. Copy the full SHA
    4faa1c4 View commit details

Commits on Aug 3, 2017

  1. fix issue in auth_chain_c: cannot find payload data issue which case …

    …by not re-init random object
    Akkariiin committed Aug 3, 2017
    Copy the full SHA
    e90dded View commit details

Commits on Aug 8, 2017

  1. update version code

    Akkariiin committed Aug 8, 2017
    Copy the full SHA
    0bb1998 View commit details
  2. Finish 4.8.0

    添加auth_chain_c/d
    修正各个下载链接
    Akkariiin committed Aug 8, 2017
    Copy the full SHA
    3678d9b View commit details
  3. Finish 4.8.0

    添加auth_chain_c/d
    修正各个下载链接
    Akkariiin committed Aug 8, 2017
    Copy the full SHA
    72eeddb View commit details

Commits on Aug 14, 2017

  1. auth_chain_e

    Akkariiin committed Aug 14, 2017
    Copy the full SHA
    781006b View commit details

Commits on Aug 28, 2017

  1. Copy the full SHA
    486a66a View commit details

Commits on Aug 31, 2017

  1. Merge pull request #2 from hardywu/master

    fix(test): correct tmp path for testing
    Akkariiin authored Aug 31, 2017
    Copy the full SHA
    f34fe78 View commit details

Commits on Sep 16, 2017

  1. Copy the full SHA
    498e8ed View commit details

Commits on Sep 18, 2017

  1. Copy the full SHA
    5a76ec7 View commit details
  2. fix(test): correct tmp path for testing

    (cherry picked from commit 486a66a)
    Akkariiin committed Sep 18, 2017
    Copy the full SHA
    42a95b2 View commit details
  3. Copy the full SHA
    8f5a4de View commit details
  4. add AuthChain_f

    Akkariiin committed Sep 18, 2017
    Copy the full SHA
    a82fe9b View commit details

Commits on Sep 22, 2017

  1. fix auth_chain_f

    Akkariiin committed Sep 22, 2017
    Copy the full SHA
    dd9fb57 View commit details

Commits on Sep 24, 2017

  1. Finish 4.8.1

    添加 auth_chain_e/f
    添加 Xchacha20 Xsalsa20 支持
    更新 libsodium 到 v1.0.13
    Akkariiin committed Sep 24, 2017
    Copy the full SHA
    3bca7b7 View commit details

Commits on Sep 26, 2017

  1. fix libss

    AkaneAkaza committed Sep 26, 2017
    Copy the full SHA
    13a9472 View commit details

Commits on Oct 15, 2017

  1. Update gitignore.

    Aspirin Geyer committed Oct 15, 2017
    Copy the full SHA
    20e5ded View commit details
  2. update DLL libsscrypto

    Akkariiin committed Oct 15, 2017
    Copy the full SHA
    90e3bb3 View commit details
  3. Merge remote-tracking branch 'origin/master' into release/4.8.1

    # Conflicts:
    #	shadowsocks-csharp/Data/libsscrypto.dll.gz
    #	shadowsocks-csharp/Data/libsscrypto64.dll.gz
    Akkariiin committed Oct 15, 2017
    Copy the full SHA
    07395da View commit details
  4. Finish 4.8.1

    重新发布 4.8.1
    本次重发布修复上次发布时libsscrypto版本错误导致的问题
    --------------------
    添加 auth_chain_e/f
    添加 Xchacha20 Xsalsa20 支持
    更新 libsodium 到 v1.0.13
    Akkariiin committed Oct 15, 2017
    Copy the full SHA
    073f2c9 View commit details
  5. Remove unneeded loop.

    - Add related UnitTest.
    Aspirin Geyer committed Oct 15, 2017
    Copy the full SHA
    5d838fc View commit details

Commits on Oct 17, 2017

  1. Merge pull request #7 from AspirinGeyer/dev

     Remove unneeded loop.
     Update gitignore.
    Akkariiin authored Oct 17, 2017
    Copy the full SHA
    46ab2ac View commit details
  2. custom UserAgent

    AkaneAkaza committed Oct 17, 2017
    Copy the full SHA
    b002d6d View commit details

Commits on Oct 23, 2017

  1. Add cache flag

    AkaneAkaza committed Oct 23, 2017
    Copy the full SHA
    3d2c439 View commit details

Commits on Nov 6, 2017

  1. Copy the full SHA
    920fbfc View commit details

Commits on Nov 12, 2017

  1. Bugfix: Fix #19, hide IPv6 addr in server list.

    Aspirin Geyer committed Nov 12, 2017
    Copy the full SHA
    f41e791 View commit details
  2. Bugfix: Another hide method.

    - Partially fix bad unittest.
    Aspirin Geyer committed Nov 12, 2017
    Copy the full SHA
    b2f094a View commit details

Commits on Nov 14, 2017

  1. Bugfix: Fix #19, hide IPv6 addr in server list.

    Aspirin Geyer authored and AkaneAkaza committed Nov 14, 2017
    Copy the full SHA
    7350a8f View commit details
  2. Bugfix: Another hide method.

    - Partially fix bad unittest.
    Aspirin Geyer authored and AkaneAkaza committed Nov 14, 2017
    Copy the full SHA
    7f0f270 View commit details
  3. Merge branch 'master' of https://github.com/shadowsocksrr/shadowsocks…

    …r-csharp into hide-ipv6
    Aspirin Geyer committed Nov 14, 2017
    Copy the full SHA
    bceb94c View commit details
  4. Patch: Improved server list.

    - Improved server name hidding function.
    - Add HorizontalScrollBar to ServerListBox.
    - Update related tests.
    Aspirin Geyer committed Nov 14, 2017
    Copy the full SHA
    20a2de5 View commit details
  5. Merge pull request #28 from AspirinGeyer/hide-ipv6

     Patch: Improved server list.
    Aspirin Geyer authored Nov 14, 2017
    Copy the full SHA
    96dc345 View commit details
  6. Fix #26, update README.md.

    Aspirin Geyer committed Nov 14, 2017
    Copy the full SHA
    0193e31 View commit details
  7. Merge pull request #29 from AspirinGeyer/Update-README

    Fix #26, update `README.md`.
    Aspirin Geyer authored Nov 14, 2017
    Copy the full SHA
    6db849b View commit details

Commits on Nov 23, 2017

  1. new balance strategy

    AkaneAkaza committed Nov 23, 2017
    Copy the full SHA
    568e972 View commit details
  2. Copy the full SHA
    278ccdb View commit details
  3. Finish 4.9.0

    添加 速度优先负载均衡(实验)
    添加 订阅最近更新时间
    界面 编辑节点显示横向滚动条,IPv6地址过滤
    优化 更新订阅的排序和自动删除相同节点
    优化 http请求使用自定义User-Agent
    AkaneAkaza committed Nov 23, 2017
    Copy the full SHA
    290e021 View commit details
  4. add appveyor.yml

    AkaneAkaza committed Nov 23, 2017
    Copy the full SHA
    b4d09fd View commit details

Commits on Dec 1, 2017

  1. Update README.md

    update appveyor badge link and pubkey link
    update Copyright
    Akkariiin authored Dec 1, 2017
    Copy the full SHA
    b24fbe7 View commit details
  2. Update README.md

    Aspirin Geyer authored Dec 1, 2017
    Copy the full SHA
    4e18daa View commit details

Commits on Dec 25, 2017

  1. No log if encrypt config

    AkaneAkaza committed Dec 25, 2017
    Copy the full SHA
    ab2e3da View commit details
  2. remove useless code

    AkaneAkaza committed Dec 25, 2017
    Copy the full SHA
    df66d7d View commit details
  3. Copy the full SHA
    7dff386 View commit details
  4. noitify updated subscribes

    AkaneAkaza committed Dec 25, 2017
    Copy the full SHA
    7e2e85f View commit details

Commits on Jan 11, 2018

  1. Copy the full SHA
    6a040b6 View commit details
  2. Copy the full SHA
    6cffafe View commit details

Commits on Jan 20, 2018

  1. Copy the full SHA
    f5c0458 View commit details
Showing with 3,997 additions and 2,113 deletions.
  1. +1 −0 .gitignore
  2. +14 −14 README.md
  3. +19 −0 appveyor.yml
  4. +14 −2 shadowsocks-csharp/Controller/GfwListUpdater.cs
  5. +5 −2 shadowsocks-csharp/Controller/Listener.cs
  6. +69 −20 shadowsocks-csharp/Controller/Local.cs
  7. +22 −13 shadowsocks-csharp/Controller/Logging.cs
  8. +4 −0 shadowsocks-csharp/Controller/ProxyAuth.cs
  9. +1 −81 shadowsocks-csharp/Controller/ProxySocket.cs
  10. +13 −0 shadowsocks-csharp/Controller/ShadowsocksController.cs
  11. +4 −4 shadowsocks-csharp/Controller/Socks5Forwarder.cs
  12. +10 −2 shadowsocks-csharp/Controller/SpeedTest.cs
  13. +7 −4 shadowsocks-csharp/Controller/UpdateChecker.cs
  14. +155 −138 shadowsocks-csharp/Controller/UpdateFreeNode.cs
  15. +19 −6 shadowsocks-csharp/Data/cn.txt
  16. BIN shadowsocks-csharp/Data/libsscrypto.dll.gz
  17. BIN shadowsocks-csharp/Data/libsscrypto64.dll.gz
  18. +32 −7 shadowsocks-csharp/Data/zh-tw.txt
  19. +4 −4 shadowsocks-csharp/Encryption/EncryptorFactory.cs
  20. +11 −8 shadowsocks-csharp/Encryption/IVEncryptor.cs
  21. +2 −2 shadowsocks-csharp/Encryption/LibcryptoEncryptor.cs
  22. +2 −1 shadowsocks-csharp/Encryption/MbedTLS.cs
  23. +2 −7 shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs
  24. +6 −0 shadowsocks-csharp/Encryption/Sodium.cs
  25. +12 −2 shadowsocks-csharp/Encryption/SodiumEncryptor.cs
  26. +119 −68 shadowsocks-csharp/Model/Configuration.cs
  27. +10 −0 shadowsocks-csharp/Model/LRUCache.cs
  28. +23 −53 shadowsocks-csharp/Model/Server.cs
  29. +85 −27 shadowsocks-csharp/Model/ServerSelectStrategy.cs
  30. +12 −0 shadowsocks-csharp/Model/ServerSpeedLog.cs
  31. +2 −2 shadowsocks-csharp/Obfs/Auth.cs
  32. +723 −0 shadowsocks-csharp/Obfs/AuthAkarin.cs
  33. +290 −8 shadowsocks-csharp/Obfs/AuthChain.cs
  34. +6 −0 shadowsocks-csharp/Obfs/ObfsBase.cs
  35. +24 −0 shadowsocks-csharp/Obfs/ObfsFactory.cs
  36. +20 −4 shadowsocks-csharp/Program.cs
  37. +1 −1 shadowsocks-csharp/Properties/AssemblyInfo.cs
  38. +2 −2 shadowsocks-csharp/Util/Base64.cs
  39. +25 −0 shadowsocks-csharp/Util/EnvCheck.cs
  40. +56 −0 shadowsocks-csharp/Util/ServerName.cs
  41. +17 −0 shadowsocks-csharp/Util/Util.cs
  42. +636 −589 shadowsocks-csharp/View/ConfigForm.Designer.cs
  43. +214 −186 shadowsocks-csharp/View/ConfigForm.cs
  44. +3 −1 shadowsocks-csharp/View/LogForm.cs
  45. +144 −66 shadowsocks-csharp/View/MenuViewController.cs
  46. +85 −53 shadowsocks-csharp/View/PortSettingsForm.Designer.cs
  47. +7 −7 shadowsocks-csharp/View/ServerLogForm.cs
  48. +683 −539 shadowsocks-csharp/View/SettingsForm.Designer.cs
  49. +146 −112 shadowsocks-csharp/View/SettingsForm.cs
  50. +10 −7 shadowsocks-csharp/View/ShowTextForm.Designer.cs
  51. +108 −53 shadowsocks-csharp/View/SubscribeForm.Designer.cs
  52. +22 −7 shadowsocks-csharp/View/SubscribeForm.cs
  53. +2 −0 shadowsocks-csharp/shadowsocks-csharp-console.csproj
  54. +2 −0 shadowsocks-csharp/shadowsocks-csharp.csproj
  55. +5 −1 shadowsocks-csharp/shadowsocks-csharp4.0.csproj
  56. +76 −0 test/ServerTest.cs
  57. +6 −6 test/UnitTest.cs
  58. +5 −4 test/test.csproj
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,3 +11,4 @@ TestResults
*.exe

/templates
.vs/
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ShadowsocksR for Windows
=======================

[![Build Status]][Appveyor]
[![Build Status]][Appveyor] <b> <=== \[click this to download nightly version\] </b>

#### Download

@@ -21,7 +21,7 @@ _Optionally_, download and install [Gpg4win](https://www.gpg4win.org/).
From the Windows start menu, launch program **Kleopatra**.
Do **File** > **New Certificate** to create a personal OpenPGP key pair.
Save the signing key from
[breakwa11/pubkey](https://github.com/breakwa11/pubkey) as a text file.
[Akkariiin/pubkey](https://github.com/Akkariiin/pubkey) as a text file.
Then do **File** > **Import Certificates** to import the signing key text file.
After import, select the signing key and do
**Certificates** > **Certify Certificates**.
@@ -37,31 +37,31 @@ For <= Windows 7 or with .Net 2.0, using ShadowsocksR-dotnet2.0.exe.

#### Usage

1. Find ShadowsocksR icon in the notification tray
2. You can add multiple servers in servers menu
1. Find ShadowsocksR icon in the system tray.
2. You can add multiple servers in servers menu.
3. Select Enable System Proxy menu to enable system proxy. Please disable other
proxy addons in your browser, or set them to use system proxy
proxy addons in your browser, or set them to use system proxy.
4. You can also configure your browser proxy manually if you don't want to enable
system proxy. Set Socks5 or HTTP proxy to 127.0.0.1:1080. You can change this
port in Global settings
port in Global settings.
5. You can change PAC rules by editing the PAC file. When you save the PAC file
with any editor, ShadowsocksR will notify browsers about the change automatically
with any editor, ShadowsocksR will notify browsers about the change automatically.
6. You can also update the PAC file from GFWList. Note your modifications to the PAC
file will be lost. However you can put your rules in the user rule file for GFWList.
Don't forget to update from GFWList again after you've edited the user rule
Don't forget to update from GFWList again after you've edited the user rule.
7. For UDP, you need to use SocksCap or ProxyCap to force programs you want
to proxy to tunnel over ShadowsocksR
to proxy to tunnel over ShadowsocksR.

### Develop

Visual Studio Express 2012 is recommended.
Visual Studio Community 2017 is recommended.

#### License

GPLv3

Copyright © BreakWa11 2017. Fork from Shadowsocks by clowwindy
Copyright © Akkariiin 2019. Forked from ShadowsocksR by BreakWa11

[Appveyor]: https://ci.appveyor.com/project/breakwa11/shadowsocksr-csharp
[Build Status]: https://ci.appveyor.com/api/projects/status/itcxnad1y95gf2x5/branch/master?svg=true
[latest release]: https://github.com/shadowsocksr/shadowsocksr-csharp/releases
[Appveyor]: https://ci.appveyor.com/project/Akkariiin/shadowsocksr-csharp
[Build Status]: https://ci.appveyor.com/api/projects/status/ey901turnakim5nv/branch/master?svg=true
[latest release]: https://github.com/shadowsocksrr/shadowsocksr-csharp/releases
19 changes: 19 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 1.0.{build}
image: Visual Studio 2015
environment:
matrix:
- platform: Any CPU
configuration: Debug
- platform: Any CPU
configuration: Release
matrix:
fast_finish: false
build:
parallel: true
verbosity: normal
artifacts:
- path: shadowsocks-csharp\bin\2.0\Release\ShadowsocksR.exe
name: ShadowsocksR-dotnet2.0.exe
- path: shadowsocks-csharp\bin\4.0\Release\ShadowsocksR.exe
name: ShadowsocksR-dotnet4.0.exe

16 changes: 14 additions & 2 deletions shadowsocks-csharp/Controller/GfwListUpdater.cs
Original file line number Diff line number Diff line change
@@ -14,9 +14,9 @@ public class GFWListUpdater
{
private const string GFWLIST_URL = "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt";

private const string GFWLIST_BACKUP_URL = "https://raw.githubusercontent.com/breakwa11/breakwa11.github.io/master/ssr/gfwlist.txt";
private const string GFWLIST_BACKUP_URL = "https://raw.githubusercontent.com/shadowsocksrr/breakwa11.github.io/master/ssr/gfwlist.txt";

private const string GFWLIST_TEMPLATE_URL = "https://raw.githubusercontent.com/breakwa11/breakwa11.github.io/master/ssr/ss_gfw.pac";
private const string GFWLIST_TEMPLATE_URL = "https://raw.githubusercontent.com/shadowsocksrr/breakwa11.github.io/master/ssr/ss_gfw.pac";

private static string PAC_FILE = PACServer.PAC_FILE;

@@ -182,6 +182,10 @@ public void UpdatePACFromGFWList(Configuration config)
{
lastConfig = config;
WebClient http = new WebClient();
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);
WebProxy proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort);
if (!string.IsNullOrEmpty(config.authPass))
{
@@ -194,6 +198,10 @@ public void UpdatePACFromGFWList(Configuration config)
else
{
WebClient http = new WebClient();
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);
WebProxy proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort);
if (!string.IsNullOrEmpty(config.authPass))
{
@@ -209,6 +217,10 @@ public void UpdatePACFromGFWList(Configuration config)
public void UpdatePACFromGFWList(Configuration config, string url)
{
WebClient http = new WebClient();
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);
WebProxy proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort);
if (!string.IsNullOrEmpty(config.authPass))
{
7 changes: 5 additions & 2 deletions shadowsocks-csharp/Controller/Listener.cs
Original file line number Diff line number Diff line change
@@ -260,7 +260,11 @@ public void AcceptCallback(IAsyncResult ar)
conn.Close();
}

if ((_authUser ?? "").Length == 0 && !Util.Utils.isLAN(conn))
int local_port = ((IPEndPoint)conn.LocalEndPoint).Port;

if ((_authUser ?? "").Length == 0 && !Util.Utils.isLAN(conn)
&& !(_config.GetPortMapCache().ContainsKey(local_port)
|| _config.GetPortMapCache()[local_port].type == PortMapType.Forward))
{
conn.Shutdown(SocketShutdown.Both);
conn.Close();
@@ -273,7 +277,6 @@ public void AcceptCallback(IAsyncResult ar)
buf
};

int local_port = ((IPEndPoint)conn.LocalEndPoint).Port;
if (!_config.GetPortMapCache().ContainsKey(local_port) || _config.GetPortMapCache()[local_port].type != PortMapType.Forward)
{
conn.BeginReceive(buf, 0, buf.Length, 0,
89 changes: 69 additions & 20 deletions shadowsocks-csharp/Controller/Local.cs
Original file line number Diff line number Diff line change
@@ -103,14 +103,15 @@ public bool Handle(byte[] firstPacket, int length, Socket socket)
}
}

class HandlerConfig
class HandlerConfig : ICloneable
{
public string targetHost;
public int targetPort;

public Double TTL = 0; // Second
public Double connect_timeout = 0;
public int try_keep_alive = 0;
public string local_dns_servers;
public string dns_servers;
public bool fouce_local_dns_query = false;
// Server proxy
@@ -127,6 +128,31 @@ class HandlerConfig
public int reconnectTimes = 0;
public bool random = false;
public bool forceRandom = false;

public object Clone()
{
HandlerConfig obj = new HandlerConfig();
obj.targetHost = targetHost;
obj.targetPort = targetPort;
obj.TTL = TTL;
obj.connect_timeout = connect_timeout;
obj.try_keep_alive = try_keep_alive;
obj.local_dns_servers = local_dns_servers;
obj.dns_servers = dns_servers;
obj.fouce_local_dns_query = fouce_local_dns_query;
obj.proxyType = proxyType;
obj.socks5RemoteHost = socks5RemoteHost;
obj.socks5RemotePort = socks5RemotePort;
obj.socks5RemoteUsername = socks5RemoteUsername;
obj.socks5RemotePassword = socks5RemotePassword;
obj.proxyUserAgent = proxyUserAgent;
obj.autoSwitchOff = autoSwitchOff;
obj.reconnectTimesRemain = reconnectTimesRemain;
obj.reconnectTimes = reconnectTimes;
obj.random = random;
obj.forceRandom = forceRandom;
return obj;
}
}

class Handler
@@ -230,7 +256,7 @@ private void ResetTimeout(double time, bool reset_keep_alive = true)
}
}
}
else
else if (!closed)
{
if (lastTimerSetTime != null && (DateTime.Now - lastTimerSetTime).TotalMilliseconds > 500)
{
@@ -459,7 +485,7 @@ public bool ReConnect()
handler.select_server = select_server;
handler.connection = connection;
handler.connectionUDP = connectionUDP;
handler.cfg = cfg;
handler.cfg = cfg.Clone() as HandlerConfig;
handler.cfg.reconnectTimesRemain = cfg.reconnectTimesRemain - 1;
handler.cfg.reconnectTimes = cfg.reconnectTimes + 1;

@@ -505,7 +531,15 @@ public void Start(byte[] firstPacket, int length, string rsp_protocol)
connectionSendBufferList.Add(data);
remoteHeaderSendBuffer = data;

Connect();
if (cfg.reconnectTimes > 0)
{
InvokeHandler handler = () => Connect();
handler.BeginInvoke(null, null);
}
else
{
Connect();
}
}
else
{
@@ -704,7 +738,7 @@ public void Close()
Thread.Sleep(200);
CloseSocket(ref remote);
CloseSocket(ref remoteUDP);
if (connection != null && cfg != null)
if (connection != null && cfg != null && connection.GetSocket() != null)
{
Logging.Debug("Close " + cfg.targetHost + ":" + cfg.targetPort.ToString() + " " + connection.GetSocket().Handle.ToString());
}
@@ -745,8 +779,6 @@ public void Close()
}
this.State = ConnectState.END;
}
getCurrentServer = null;
keepCurrentServer = null;
}

if (!reconnect)
@@ -761,19 +793,24 @@ public void Close()
connection = null;
connectionUDP = null;
}

detector = null;
speedTester = null;
random = null;
remoteUDPRecvBuffer = null;

server = null;
select_server = null;
}
catch (Exception e)
{
Logging.LogUsefulException(e);
}

getCurrentServer = null;
keepCurrentServer = null;

detector = null;
speedTester = null;
random = null;
remoteUDPRecvBuffer = null;

server = null;
select_server = null;

cfg = null;
}

private bool ConnectProxyServer(string strRemoteHost, int iRemotePort)
@@ -835,10 +872,10 @@ private void Connect()
}
}
speedTester.server = server.server;
Logging.Info($"Connect {cfg.targetHost}:{cfg.targetPort.ToString()}");
Logging.Info($"Connect {cfg.targetHost}:{cfg.targetPort.ToString()} via {server.server}:{server.server_port}");

ResetTimeout(cfg.TTL);
if (cfg.fouce_local_dns_query && cfg.targetHost != null)
if (cfg.targetHost != null)
{
IPAddress ipAddress;

@@ -858,6 +895,7 @@ private void Connect()
ipAddress = Utils.QueryDns(host, null);
}
}
Logging.Info($"DNS nolock query {host} answer {ipAddress.ToString()}");
if (ipAddress != null)
{
Utils.DnsBuffer.Set(host, new IPAddress(ipAddress.GetAddressBytes()));
@@ -899,18 +937,20 @@ private void Connect()
bool parsed = IPAddress.TryParse(serverHost, out ipAddress);
if (!parsed)
{
if (server.ServerSpeedLog().ErrorContinurousTimes > 10)
server.DnsBuffer().force_expired = true;
if (server.DnsBuffer().isExpired(serverHost))
{
bool dns_ok = false;
{
DnsBuffer buf = server.DnsBuffer();
lock (buf)
if (Monitor.TryEnter(buf, buf.ip != null ? 100 : 1000000))
{
if (buf.isExpired(serverHost))
{
if (serverHost.IndexOf('.') >= 0)
{
ipAddress = Util.Utils.QueryDns(serverHost, cfg.dns_servers);
ipAddress = Util.Utils.QueryDns(serverHost, cfg.local_dns_servers);
}
else
{
@@ -927,6 +967,15 @@ private void Connect()
ipAddress = buf.ip;
dns_ok = true;
}
Monitor.Exit(buf);
}
else
{
if (buf.ip != null)
{
ipAddress = buf.ip;
dns_ok = true;
}
}
}
if (!dns_ok)
@@ -997,8 +1046,8 @@ private void doConnectionTCPRecv()
if (connection != null && connectionTCPIdle)
{
connectionTCPIdle = false;
byte[] buffer = new byte[BufferSize];
int recv_size = remote == null ? RecvSize : remote.TcpMSS - remote.OverHead;
byte[] buffer = new byte[recv_size];
connection.BeginReceive(buffer, recv_size, 0,
new AsyncCallback(PipeConnectionReceiveCallback), null);
}
Loading