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
379b5d27
Commit
379b5d27
authored
23 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
This update actually works like a real finger service.
parent
77baef84
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/fingerservice.js
+66
-10
66 additions, 10 deletions
exec/fingerservice.js
with
66 additions
and
10 deletions
exec/fingerservice.js
+
66
−
10
View file @
379b5d27
// fingerservice.js
// Synchronet Service for the Finger protocol (RFC 1288)
load
(
"
nodedefs.js
"
);
// This is just an example of how you access command-line args
for
(
i
=
0
;
i
<
argc
;
i
++
)
log
(
format
(
"
argv[%d]=%s
"
,
i
,
argv
[
i
]));
// End of example :-)
// Write a string to the client socket
function
write
(
str
)
{
client
.
socket
.
send
(
str
);
}
var
user
=
new
User
(
1
);
for
(
n
=
0
;
n
<
system
.
node_list
.
length
;
n
++
)
{
write
(
format
(
"
Node %2d
"
,
n
+
1
));
if
(
system
.
node_list
[
n
].
status
==
NODE_INUSE
)
{
// Get Finger Request
request
=
client
.
socket
.
recvline
(
128
/*maxlen*/
,
3
/*timeout*/
);
if
(
request
==
null
)
{
log
(
"
!TIMEOUT waiting for request
"
);
exit
();
}
if
(
request
==
""
)
{
/* no specific user requested, give list of active users */
log
(
"
client requested active user list
"
);
write
(
format
(
"
%-25.25s %-40.40s Node Age Sex
\r\n
"
,
"
Name
"
,
"
Action
"
));
write
(
"
-------------------------------------------------------------------------------
\r\n
"
);
var
user
=
new
User
(
1
);
for
(
n
=
0
;
n
<
system
.
node_list
.
length
;
n
++
)
{
if
(
system
.
node_list
[
n
].
status
!=
NODE_INUSE
)
continue
;
user
.
number
=
system
.
node_list
[
n
].
useron
;
write
(
format
(
"
%s (%u %s)
"
,
user
.
alias
,
user
.
age
,
user
.
gender
));
write
(
format
(
NodeAction
[
system
.
node_list
[
n
].
action
],
system
.
node_list
[
n
].
aux
));
}
else
write
(
format
(
NodeStatus
[
system
.
node_list
[
n
].
status
],
system
.
node_list
[
n
].
aux
));
var
action
=
format
(
NodeAction
[
system
.
node_list
[
n
].
action
],
system
.
node_list
[
n
].
aux
);
write
(
format
(
"
%-25.25s %-40.40s %4d %3d %3s
\r\n
"
,
user
.
alias
,
action
,
n
+
1
,
user
.
age
,
user
.
gender
));
}
exit
();
}
log
(
format
(
"
client request: '%s'
"
,
request
));
var
usernum
=
Number
(
request
);
if
(
!
usernum
)
{
var
at
=
request
.
indexOf
(
'
@
'
);
if
(
at
>
0
)
request
=
request
.
substr
(
0
,
at
-
1
);
usernum
=
system
.
matchuser
(
request
);
if
(
!
usernum
)
{
log
(
"
!UNKNOWN USER:
"
+
request
);
exit
();
}
}
var
user
=
new
User
(
usernum
);
if
(
user
==
null
)
{
log
(
format
(
"
!INVALID USER NUMBER: %d
"
,
usernum
));
exit
();
}
write
(
format
(
"
Site: %s
\r\n
"
,
system
.
inetaddr
));
write
(
format
(
"
Login name: %-30s In real life: %s
\r\n
"
,
user
.
alias
,
user
.
name
));
write
(
format
(
"
Shell: %s
\r\n
"
,
user
.
command_shell
));
write
(
format
(
"
Last login %s via %s from %s [%s]
\r\n
"
,
system
.
timestr
()
,
user
.
connection
,
user
.
host_name
,
user
.
ip_address
));
write
(
"
\r\n
"
);
}
\ No newline at end of file
/* End of fingerservice.js */
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