summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--bounce.c4
-rw-r--r--bounce.h2
-rw-r--r--listen.c15
3 files changed, 11 insertions, 10 deletions
diff --git a/bounce.c b/bounce.c
index 1907584..ad346a0 100644
--- a/bounce.c
+++ b/bounce.c
@@ -137,8 +137,8 @@ int main(int argc, char *argv[]) {
 		for (size_t i = 0; i < event.len; ++i) {
 			if (!event.fds[i].revents) continue;
 			if (i < binds) {
-				struct tls *tls;
-				int fd = listenAccept(&tls, event.fds[i].fd);
+				int fd;
+				struct tls *tls = listenAccept(&fd, event.fds[i].fd);
 				eventAdd(fd, clientAlloc(tls));
 				continue;
 			}
diff --git a/bounce.h b/bounce.h
index 3c95f70..3307bac 100644
--- a/bounce.h
+++ b/bounce.h
@@ -60,7 +60,7 @@ const char *ringConsume(time_t *time, size_t consumer);
 
 void listenConfig(const char *cert, const char *priv);
 size_t listenBind(int fds[], size_t cap, const char *host, const char *port);
-int listenAccept(struct tls **client, int fd);
+struct tls *listenAccept(int *fd, int bind);
 
 int serverConnect(const char *host, const char *port);
 void serverLogin(
diff --git a/listen.c b/listen.c
index 1179a8b..d6e561f 100644
--- a/listen.c
+++ b/listen.c
@@ -27,6 +27,7 @@
 
 static struct tls *server;
 
+// TODO: Make this callable more than once to reload certificates?
 void listenConfig(const char *cert, const char *priv) {
 	struct tls_config *config = tls_config_new();
 	if (!config) errx(EX_SOFTWARE, "tls_config_new");
@@ -77,16 +78,16 @@ size_t listenBind(int fds[], size_t cap, const char *host, const char *port) {
 	return len;
 }
 
-int listenAccept(struct tls **client, int fd) {
-	int sock = accept(fd, NULL, NULL);
-	if (sock < 0) err(EX_IOERR, "accept");
+struct tls *listenAccept(int *fd, int bind) {
+	*fd = accept(bind, NULL, NULL);
+	if (*fd < 0) err(EX_IOERR, "accept");
 
 	int yes = 1;
-	int error = setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes));
+	int error = setsockopt(*fd, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes));
 	if (error) err(EX_OSERR, "setsockopt");
 
-	error = tls_accept_socket(server, client, sock);
+	struct tls *client;
+	error = tls_accept_socket(server, &client, *fd);
 	if (error) errx(EX_SOFTWARE, "tls_accept_socket: %s", tls_error(server));
-
-	return sock;
+	return client;
 }
2020-08-27contrib/palaver: Fix database search and creationJune McEnroe 2020-08-27contrib/palaver: Use pounce's XDG directoryJune McEnroe 2020-08-27contrib/palaver: Only allow HTTPSJune McEnroe 2020-08-25Support the pounce_env rc variableJune McEnroe 2020-08-25Remove deprecated option namesJune McEnroe 2020-08-25Document configuration and data file searchJune McEnroe 2020-08-24Use dataOpen for save fileJune McEnroe 2020-08-24Use configOpen to load localCAJune McEnroe 2020-08-24Use configPath to load client cert/privJune McEnroe 2020-08-24Use configOpen in getopt_configJune McEnroe 2020-08-24Import xdg.c from catgirlJune McEnroe 2020-08-23Replace “RAND_bytes” by “getentropy”Issam E. Maghni 2020-08-16contrib/palaver: Add no message preview flagsJune McEnroe 2020-08-13contrib/palaver: Don't set channel for PMsJune McEnroe 2020-08-13Fix unintended interception of NICK after registrationJune McEnroe 2020-08-12Add Additional Components section to READMEJune McEnroe 2020-08-12Document -L / palaver optionJune McEnroe 2020-08-11contrib/palaver: Document service configurationJune McEnroe 2020-08-11contrib/palaver: Add install target and rc scriptJune McEnroe 2020-08-11contrib/palaver: Implement command and notificationsJune McEnroe