mirror of
https://git.1024x2.xyz/1024x2/vexnc.git
synced 2025-04-12 01:46:31 +02:00
Add client logging
149.1784.2.4209. Look familiar?
This commit is contained in:
parent
55b6e7dbf7
commit
db8548a868
29
vexnc.c
29
vexnc.c
@ -21,6 +21,20 @@ int mkderp(const char *name) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int spewtxt(int fd, const char *fmt, ...) {
|
||||
va_list va;
|
||||
char buf[256] = {0xF0, 0x9F, 0xBF, 0xBF, '\n', 0};
|
||||
|
||||
va_start(va, fmt);
|
||||
vsnprintf(buf + 5, sizeof(buf) - 5, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
size_t len = strlen(buf);
|
||||
buf[len++] = '\n';
|
||||
|
||||
return write(fd, buf, len);
|
||||
}
|
||||
|
||||
int spewchr(int fd, uint16_t chr) {
|
||||
char buf[4];
|
||||
int i = 0;
|
||||
@ -59,6 +73,20 @@ int openlogfile() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void userofflog(rfbClientRec *cl) {
|
||||
if (openlogfile()) return;
|
||||
if (spewtxt(fdlog, "disconnect %s", cl->host) < 0)
|
||||
perror("spewtxt");
|
||||
}
|
||||
|
||||
enum rfbNewClientAction useronlog(rfbClientRec *cl) {
|
||||
cl->clientGoneHook = userofflog;
|
||||
if (openlogfile()) return RFB_CLIENT_ACCEPT;
|
||||
if (spewtxt(fdlog, "connect %s", cl->host) < 0)
|
||||
perror("spewtxt");
|
||||
return RFB_CLIENT_ACCEPT;
|
||||
}
|
||||
|
||||
void keylog(rfbBool down, rfbKeySym keySym, rfbClientRec* cl) {
|
||||
if (!down) return; // only log key downs
|
||||
if (openlogfile()) return; // ensure log file opened
|
||||
@ -97,6 +125,7 @@ int main(int argc, char const *argv[]) {
|
||||
rfbScreen->frameBuffer = (char*)im;
|
||||
rfbScreen->alwaysShared = TRUE;
|
||||
if (logdirenabled) {
|
||||
rfbScreen->newClientHook = useronlog;
|
||||
rfbScreen->kbdAddEvent = keylog;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user