Skip to content
Snippets Groups Projects
Commit e6021f4e authored by echicken's avatar echicken :chicken:
Browse files

Write websocket client IP address to temp file.

Scripts running on upstream (terminal) server can find actual
client IP in:

system.temp_path + 'sbbs-ws-' + client.socket.remote_port + '.ip'
parent 8a6efb4d
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -83,6 +83,7 @@ try {
FServerSocket = new Socket();
log(LOG_DEBUG, "Connecting to " + TargetHostname + ":" + TargetPort);
if (FServerSocket.connect(TargetHostname, TargetPort)) {
// Variables we'll use in the loop
var DoYield = true;
var ClientData = [];
......@@ -102,6 +103,12 @@ try {
FServerSocket.send(hapstr);
}
var ipFile = new File (system.temp_path + 'sbbs-ws-' + FServerSocket.local_port + '.ip');
if (ipFile.open('w')) {
ipFile.write(client.ip_address);
ipFile.close();
}
// Loop while we're still connected on both ends
while ((client.socket.is_connected) && (FServerSocket.is_connected)) {
// Should we yield or not (default true, but disable if we had line activity)
......@@ -129,6 +136,7 @@ try {
}
if (!client.socket.is_connected) log(LOG_DEBUG, 'Client socket no longer connected');
if (!FServerSocket.is_connected) log(LOG_DEBUG, 'Server socket no longer connected');
ipFile.remove();
} else {
// FServerSocket.connect() failed
log(LOG_ERR, "Error " + FServerSocket.error + " connecting to server at " + TargetHostname + ":" + TargetPort);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment