Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,15 @@ after_build:
return $text
}

$WorkingFolder = "$env:APPVEYOR_BUILD_FOLDER\working"
$ExeFileName = "Shadowsocks-$env:APPVEYOR_BUILD_VERSION-$env:CONFIGURATION.exe"
$ExeFile = "$WorkingFolder\$ExeFileName"
$ExeHashFile = "$Exefile.hash"

New-Item "$WorkingFolder" -ItemType Directory -Force
Copy-Item "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:PLATFORM\$env:CONFIGURATION\Shadowsocks.exe" "$WorkingFolder\Shadowsocks.exe"
Copy-Item "$WorkingFolder\Shadowsocks.exe" "$ExeFile"

CalculateHash -file "$Exefile" | Out-File -FilePath "$ExeHashFile"

Push-AppveyorArtifact "$ExeFile"
Push-AppveyorArtifact "$ExeHashFile"

# Create and deploy the release zip

$WorkingFolder = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:PLATFORM\$env:CONFIGURATION"
$ReleaseFile = "$WorkingFolder\Shadowsocks.exe"
$ReleaseHashFile = "$ReleaseFile.hash"
$ReleaseLocalizationFiles = "$WorkingFolder\*\"
$ZipFile = "$WorkingFolder\Shadowsocks-$env:APPVEYOR_BUILD_VERSION.zip"
$ZipHashFile = "$ZipFile.hash"

# Calculate exe Hash and archieve both exe and hash to zip
CalculateHash -file "$ReleaseFile" | Out-File -FilePath "$ReleaseHashFile"
7z a "$ZipFile" "$ReleaseFile" "$ReleaseHashFile"
7z a "$ZipFile" "$ReleaseFile" "$ReleaseHashFile" "$ReleaseLocalizationFiles"
Push-AppveyorArtifact "$ZipFile"

# Calculate packed zip Hash
Expand Down
34 changes: 2 additions & 32 deletions shadowsocks-csharp/Controller/Service/GeositeUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public static class GeositeUpdater

private static readonly string DATABASE_PATH = Utils.GetTempPath("dlc.dat");

private static HttpClientHandler httpClientHandler;
private static HttpClient httpClient;
private static readonly string GEOSITE_URL = "https://github.com/v2fly/domain-list-community/raw/release/dlc.dat";
private static readonly string GEOSITE_SHA256SUM_URL = "https://github.com/v2fly/domain-list-community/raw/release/dlc.dat.sha256sum";
private static byte[] geositeDB;
Expand Down Expand Up @@ -82,30 +80,15 @@ public static async Task UpdatePACFromGeosite()
SHA256 mySHA256 = SHA256.Create();
var config = Program.MainController.GetCurrentConfiguration();
bool blacklist = config.geositePreferDirect;

var httpClient = Program.MainController.GetHttpClient();

if (!string.IsNullOrWhiteSpace(config.geositeUrl))
{
logger.Info("Found custom Geosite URL in config file");
geositeUrl = config.geositeUrl;
}
logger.Info($"Checking Geosite from {geositeUrl}");

// use System.Net.Http.HttpClient to download GeoSite db.
// NASTY workaround: new HttpClient every update
// because we can't change proxy on existing socketsHttpHandler instance
httpClientHandler = new HttpClientHandler();
httpClient = new HttpClient(httpClientHandler);
if (!string.IsNullOrWhiteSpace(config.userAgentString))
httpClient.DefaultRequestHeaders.Add("User-Agent", config.userAgentString);
if (config.enabled)
{
httpClientHandler.Proxy = new WebProxy(
config.isIPv6Enabled
? $"[{IPAddress.IPv6Loopback}]"
: IPAddress.Loopback.ToString(),
config.localPort);
}

try
{
// download checksum first
Expand Down Expand Up @@ -154,19 +137,6 @@ public static async Task UpdatePACFromGeosite()
{
Error?.Invoke(null, new ErrorEventArgs(ex));
}
finally
{
if (httpClientHandler != null)
{
httpClientHandler.Dispose();
httpClientHandler = null;
}
if (httpClient != null)
{
httpClient.Dispose();
httpClient = null;
}
}
}

/// <summary>
Expand Down
17 changes: 2 additions & 15 deletions shadowsocks-csharp/Controller/Service/OnlineConfigResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,15 @@ namespace Shadowsocks.Controller.Service
{
public class OnlineConfigResolver
{
public static async Task<List<Server>> GetOnline(string url, string userAgentString, IWebProxy proxy = null)
public static async Task<List<Server>> GetOnline(string url)
{
var httpClientHandler = new HttpClientHandler()
{
Proxy = proxy
};
var httpClient = new HttpClient(httpClientHandler)
{
Timeout = TimeSpan.FromSeconds(15)
};
if (!string.IsNullOrWhiteSpace(userAgentString))
httpClient.DefaultRequestHeaders.Add("User-Agent", userAgentString);

var httpClient = Program.MainController.GetHttpClient();
string server_json = await httpClient.GetStringAsync(url);

var servers = server_json.GetServers();

foreach (var server in servers)
{
server.group = url;
}

return servers.ToList();
}
}
Expand Down
6 changes: 3 additions & 3 deletions shadowsocks-csharp/Controller/Service/TCPRelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public AsyncSession(AsyncSession session, T state) : base(session.Remote)
public DateTime lastActivity;

private readonly ShadowsocksController _controller;
private readonly ProxyConfig _config;
private readonly ForwardProxyConfig _config;
private readonly Socket _connection;

private IEncryptor _encryptor;
Expand Down Expand Up @@ -665,10 +665,10 @@ private void StartConnect()
{
switch (_config.proxyType)
{
case ProxyConfig.PROXY_SOCKS5:
case ForwardProxyConfig.PROXY_SOCKS5:
remote = new Socks5Proxy();
break;
case ProxyConfig.PROXY_HTTP:
case ForwardProxyConfig.PROXY_HTTP:
remote = new HttpProxy();
break;
default:
Expand Down
Loading