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
d2bfa1e2
Commit
d2bfa1e2
authored
22 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Initial UNIX monitor (Currently just a unix-domain socket spy tool.)
parent
615d491a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/umonitor/GNUmakefile
+2
-0
2 additions, 0 deletions
src/sbbs3/umonitor/GNUmakefile
src/sbbs3/umonitor/umonitor.c
+94
-0
94 additions, 0 deletions
src/sbbs3/umonitor/umonitor.c
with
96 additions
and
0 deletions
src/sbbs3/umonitor/GNUmakefile
0 → 100644
+
2
−
0
View file @
d2bfa1e2
umonitor
:
umonitor.c
gcc umonitor.c
-I
../../xpdev
-o
umonitor
This diff is collapsed.
Click to expand it.
src/sbbs3/umonitor/umonitor.c
0 → 100644
+
94
−
0
View file @
d2bfa1e2
#include
"sockwrap.h"
#include
<poll.h>
#include
<termios.h>
#include
<sys/un.h>
#include
<stdio.h>
void
usage
(
char
*
cmd
)
{
printf
(
"Usage: %s <socket>
\n\n
Where socket is the filename of a unix domain socket
\n\n
"
,
cmd
);
exit
(
0
);
}
void
spyon
(
char
*
sockname
)
{
SOCKET
spy_sock
=
INVALID_SOCKET
;
struct
sockaddr_un
spy_name
;
socklen_t
spy_len
;
char
key
;
char
buf
[
1
];
int
i
;
struct
termios
tio
;
struct
termios
old_tio
;
struct
pollfd
pset
[
2
];
/* ToDo Test for it actually being a socket! */
if
((
spy_sock
=
socket
(
PF_LOCAL
,
SOCK_STREAM
,
0
))
==
INVALID_SOCKET
)
{
printf
(
"ERROR %d creating local spy socket"
,
errno
);
return
;
}
spy_name
.
sun_family
=
AF_LOCAL
;
SAFECOPY
(
spy_name
.
sun_path
,
sockname
);
spy_len
=
SUN_LEN
(
&
spy_name
);
if
(
connect
(
spy_sock
,(
struct
sockaddr
*
)
&
spy_name
,
spy_len
))
{
printf
(
"Could not connect to %s
\n
"
,
spy_name
.
sun_path
);
return
;
}
i
=
1
;
tcgetattr
(
STDIN_FILENO
,
&
old_tio
);
tcgetattr
(
STDIN_FILENO
,
&
tio
);
// cfmakeraw(&tio);
tio
.
c_cc
[
VMIN
]
=
1
;
tio
.
c_cc
[
VTIME
]
=
0
;
tio
.
c_lflag
&=
~
(
ICANON
|
ECHO
);
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
tio
);
pset
[
0
].
fd
=
STDIN_FILENO
;
pset
[
0
].
events
=
POLLIN
;
pset
[
1
].
fd
=
spy_sock
;
pset
[
1
].
events
=
POLLIN
;
while
(
spy_sock
!=
INVALID_SOCKET
)
{
if
((
poll
(
pset
,
2
,
INFTIM
))
<
0
)
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
}
if
(
pset
[
0
].
revents
)
{
if
(
pset
[
0
].
revents
&
(
POLLNVAL
|
POLLHUP
|
POLLERR
))
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
}
else
{
if
(
read
(
STDIN_FILENO
,
&
key
,
1
)
==
1
)
{
write
(
spy_sock
,
&
key
,
1
);
}
else
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
}
}
}
if
(
pset
[
1
].
revents
)
{
if
(
pset
[
1
].
revents
&
(
POLLNVAL
|
POLLHUP
|
POLLERR
))
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
}
else
{
if
(
read
(
spy_sock
,
&
buf
,
1
)
==
1
)
write
(
STDOUT_FILENO
,
buf
,
1
);
else
{
close
(
spy_sock
);
spy_sock
=
INVALID_SOCKET
;
}
}
}
fflush
(
stdout
);
}
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
old_tio
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
1
)
usage
(
argv
[
0
]);
spyon
(
argv
[
1
]);
}
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