forked from shadowsocks/shadowsocks-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77d49cf
commit a8f0f58
Showing
7 changed files
with
172 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Shadowsocks.CLI | ||
{ | ||
public enum Backend | ||
{ | ||
SsRust, | ||
V2Ray, | ||
Legacy, | ||
Pipelines, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Shadowsocks.Models; | ||
using Shadowsocks.Net; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shadowsocks.CLI.Client | ||
{ | ||
public class Legacy | ||
{ | ||
private TCPListener? _tcpListener; | ||
private UDPListener? _udpListener; | ||
|
||
public void Start(string listenSocks, string serverAddress, int serverPort, string method, string password, string? plugin, string? pluginOpts, string? pluginArgs) | ||
{ | ||
var localEP = IPEndPoint.Parse(listenSocks); | ||
var server = new Server() | ||
{ | ||
Host = serverAddress, | ||
Port = serverPort, | ||
Method = method, | ||
Password = password, | ||
Plugin = plugin, | ||
PluginOpts = pluginOpts, | ||
}; | ||
if (!string.IsNullOrEmpty(plugin) && !string.IsNullOrEmpty(pluginArgs)) | ||
{ | ||
var processStartInfo = new ProcessStartInfo(plugin, pluginArgs); | ||
server.PluginArgs = processStartInfo.ArgumentList.ToList(); | ||
} | ||
|
||
var tcpRelay = new TCPRelay(server); | ||
_tcpListener = new TCPListener(localEP, new List<IStreamService>() | ||
{ | ||
tcpRelay, | ||
}); | ||
_tcpListener.Start(); | ||
|
||
var udpRelay = new UDPRelay(server); | ||
_udpListener = new UDPListener(localEP, new List<IDatagramService>() | ||
{ | ||
udpRelay, | ||
}); | ||
_udpListener.Start(); | ||
} | ||
|
||
public void Stop() | ||
{ | ||
_tcpListener?.Stop(); | ||
_udpListener?.Stop(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Shadowsocks.Protocol; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shadowsocks.CLI.Client | ||
{ | ||
public class Pipelines | ||
{ | ||
private TcpPipeListener? _tcpPipeListener; | ||
|
||
public Task Start(string listenSocks, string serverAddress, int serverPort, string method, string? password, string? key, string? plugin, string? pluginOpts, string? pluginArgs) | ||
{ | ||
// TODO | ||
var localEP = IPEndPoint.Parse(listenSocks); | ||
var remoteEp = new DnsEndPoint(serverAddress, serverPort); | ||
byte[]? mainKey = null; | ||
if (!string.IsNullOrEmpty(key)) | ||
mainKey = Encoding.UTF8.GetBytes(key); | ||
_tcpPipeListener = new(localEP); | ||
return _tcpPipeListener.Start(localEP, remoteEp, method, password, mainKey); | ||
} | ||
|
||
public void Stop() => _tcpPipeListener?.Stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters