Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. Pass options to SIP003 plug-in through the Agruments property; 2. … #1684

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion shadowsocks-csharp/Controller/Service/Sip003Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private Sip003Plugin(string plugin, string pluginOpts, string serverAddress, int
StartInfo = new ProcessStartInfo
{
FileName = plugin,
Arguments = pluginOpts,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To whom also reviewing this PR:
as mentioned in shadowsocks/shadowsocks-org#28

  1. Passing arguments to a plugin
    A plugin accepts arguments through environment variables.

Standard SIP003 implementation not only take care on Windows, Linux or Mac, but also need to provide maximum compatibility to embedded system such as routers, or cellphones. That's why it chooses environment variables.

UseShellExecute = false,
CreateNoWindow = true,
ErrorDialog = false,
Expand Down Expand Up @@ -86,7 +87,7 @@ public bool StartIfNeeded()
return false;
}

var localPort = GetNextFreeTcpPort();
var localPort = int.Parse(_pluginProcess.StartInfo.Environment["SS_REMOTE_PORT"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SS_LOCAL_HOST SS_LOCAL_PORT: the plugin listens SS native connection.
SS_REMOTE_HOST SS_REMOTE_PORT: the plugin then connect to the remote server.

SS ===> to plugin's LOCAL HOST/PORT ===> plug-in data processing ===> send to REMOTE HOST/PORT

LocalEndPoint = new IPEndPoint(IPAddress.Loopback, localPort);

_pluginProcess.StartInfo.Environment["SS_LOCAL_HOST"] = LocalEndPoint.Address.ToString();
Expand Down