Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
287ee6e4
Commit
287ee6e4
authored
4 years ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
When a callback event is handled, get remote_addr
Prevents weird issues with getting remote address.
parent
4391ca75
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Pipeline
#1874
passed
4 years ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/js_internal.c
+8
-0
8 additions, 0 deletions
src/sbbs3/js_internal.c
src/sbbs3/js_socket.c
+4
-0
4 additions, 0 deletions
src/sbbs3/js_socket.c
with
12 additions
and
0 deletions
src/sbbs3/js_internal.c
+
8
−
0
View file @
287ee6e4
...
@@ -1120,6 +1120,8 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
...
@@ -1120,6 +1120,8 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
jsrefcount
rc
;
jsrefcount
rc
;
JSBool
ret
=
JS_TRUE
;
JSBool
ret
=
JS_TRUE
;
BOOL
input_locked
=
FALSE
;
BOOL
input_locked
=
FALSE
;
js_socket_private_t
*
jssp
;
socklen_t
slen
;
#ifdef PREFER_POLL
#ifdef PREFER_POLL
struct
pollfd
*
fds
;
struct
pollfd
*
fds
;
nfds_t
sc
;
nfds_t
sc
;
...
@@ -1372,6 +1374,12 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
...
@@ -1372,6 +1374,12 @@ js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated)
if
(
input_locked
)
if
(
input_locked
)
js_do_lock_input
(
cx
,
FALSE
);
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
);
ret
=
JS_CallFunction
(
cx
,
ev
->
cx
,
ev
->
cb
,
0
,
NULL
,
&
rval
);
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/js_socket.c
+
4
−
0
View file @
287ee6e4
...
@@ -2091,6 +2091,10 @@ js_install_event(JSContext *cx, uintN argc, jsval *arglist, BOOL once)
...
@@ -2091,6 +2091,10 @@ js_install_event(JSContext *cx, uintN argc, jsval *arglist, BOOL once)
return
(
JS_FALSE
);
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
)
{
if
(
argc
!=
2
)
{
JS_ReportError
(
cx
,
"js.on() and js.once() require exactly two parameters"
);
JS_ReportError
(
cx
,
"js.on() and js.once() require exactly two parameters"
);
return
JS_FALSE
;
return
JS_FALSE
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment