Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 287ee6e4 authored by Deucе's avatar Deucе 👌🏾

When a callback event is handled, get remote_addr

Prevents weird issues with getting remote address.
parent 4391ca75
Pipeline #1874 passed with stage
in 8 minutes and 43 seconds
......@@ -1120,6 +1120,8 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
jsrefcount rc;
JSBool ret = JS_TRUE;
BOOL input_locked = FALSE;
js_socket_private_t* jssp;
socklen_t slen;
#ifdef PREFER_POLL
struct pollfd *fds;
nfds_t sc;
......@@ -1372,6 +1374,12 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
if (input_locked)
js_do_lock_input(cx, FALSE);
}
if (ev->type == JS_EVENT_SOCKET_CONNECT) {
if ((jssp = (js_socket_private_t*)JS_GetPrivate(cx, ev->cx)) != NULL) {
slen=sizeof(ev->data.connect.sock);
getpeername(ev->data.connect.sock, &jssp->remote_addr.addr, &slen);
}
}
ret = JS_CallFunction(cx, ev->cx, ev->cb, 0, NULL, &rval);
......
......@@ -2091,6 +2091,10 @@ js_install_event(JSContext *cx, uintN argc, jsval *arglist, BOOL once)
return(JS_FALSE);
}
/*
* NOTE: If you allow a thisObj here, you'll need to deal with js_GetClassPrivate
* in js_internal.c where the object is assumed to be a socket.
*/
if (argc != 2) {
JS_ReportError(cx, "js.on() and js.once() require exactly two parameters");
return JS_FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment