/*
- * wsockd.c: charybdis websockets helper
+ * wsockd.c: solanum websockets helper
* Copyright (C) 2007 Aaron Sethman <androsyn@ratbox.org>
* Copyright (C) 2007 ircd-ratbox development team
- * Copyright (C) 2016 William Pitcock <nenolod@dereferenced.org>
+ * Copyright (C) 2016 Ariadne Conill <ariadne@dereferenced.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
uint8_t payload_length_mask; // payload_length: 7, mask: 1
} ws_frame_hdr_t;
+#define WEBSOCKET_FRAME_HDR_INIT ((ws_frame_hdr_t) { 0, 0 })
+
typedef struct {
ws_frame_hdr_t header;
uint8_t payload_data[WEBSOCKET_MAX_UNEXTENDED_PAYLOAD_DATA_LENGTH];
uint16_t payload_length_extended;
} ws_frame_ext_t;
+#define WEBSOCKET_FRAME_EXT_INIT ((ws_frame_ext_t) { WEBSOCKET_FRAME_HDR_INIT, 0 })
+
typedef struct {
ws_frame_hdr_t header;
uint64_t payload_length_extended;
static void conn_plain_read_shutdown_cb(rb_fde_t *fd, void *data);
-#ifndef _WIN32
static void
dummy_handler(int sig)
{
return;
}
-#endif
static void
setup_signals()
{
-#ifndef _WIN32
struct sigaction act;
act.sa_flags = 0;
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
-#endif
}
static int
maxconn(void)
{
-#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
struct rlimit limit;
if(!getrlimit(RLIMIT_NOFILE, &limit))
{
return limit.rlim_cur;
}
-#endif /* RLIMIT_FD_MAX */
return MAXCONNECTIONS;
}
static void
conn_mod_write_short_frame(conn_t * conn, void *data, int len)
{
- ws_frame_hdr_t hdr;
+ ws_frame_hdr_t hdr = WEBSOCKET_FRAME_HDR_INIT;
ws_frame_set_opcode(&hdr, WEBSOCKET_OPCODE_TEXT_FRAME);
ws_frame_set_fin(&hdr, 1);
static void
conn_mod_write_long_frame(conn_t * conn, void *data, int len)
{
- ws_frame_ext_t hdr;
+ ws_frame_ext_t hdr = WEBSOCKET_FRAME_EXT_INIT;
ws_frame_set_opcode(&hdr.header, WEBSOCKET_OPCODE_TEXT_FRAME);
ws_frame_set_fin(&hdr.header, 1);
main(int argc, char **argv)
{
const char *s_ctlfd, *s_pipe, *s_pid;
- int ctlfd, pipefd, x, maxfd;
+ int ctlfd, pipefd, maxfd, x;
maxfd = maxconn();
s_ctlfd = getenv("CTL_FD");
if(s_ctlfd == NULL || s_pipe == NULL || s_pid == NULL)
{
fprintf(stderr,
- "This is the charybdis wsockd for internal ircd use.\n");
+ "This is the solanum wsockd for internal ircd use.\n");
fprintf(stderr,
"You aren't supposed to run me directly. Exiting.\n");
exit(1);
ctlfd = atoi(s_ctlfd);
pipefd = atoi(s_pipe);
ppid = atoi(s_pid);
- x = 0;
-#ifndef _WIN32
+
for(x = 0; x < maxfd; x++)
{
if(x != ctlfd && x != pipefd && x > 2)
if(x > 2)
close(x);
}
-#endif
+
setup_signals();
rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096);
rb_linebuf_init(4096);