access config via a pointer, not a hardcoded struct address

this is required so we can elegantly swap out an old config for a
new one in the future and remove lots of boilerplate from config
initialization code.

unfortunately this is a quite intrusive change as the config struct
was accessed in numerous places, but frankly it should have been
done via a pointer right from the start.

right now, we simply point to a static struct in main.c, so there
shouldn't be any noticeable changes in behaviour.
This commit is contained in:
rofl0r committed 2020-01-15 16:09:41 +00:00
1 parent bffa705005
commit c63d5d26b4
11 files changed
+107 -103

No files matched your search

+3 -3
View File
@@ -134,8 +134,8 @@ int opensock (const char *host, int port, const char *bind_to)
close (sockfd);
continue; /* can't bind, so try again */
}
} else if (config.bind_address) {
if (bind_socket (sockfd, config.bind_address,
} else if (config->bind_address) {
if (bind_socket (sockfd, config->bind_address,
res->ai_family) < 0) {
close (sockfd);
continue; /* can't bind, so try again */
@@ -147,7 +147,7 @@ int opensock (const char *host, int port, const char *bind_to)
int af = res->ai_addr->sa_family;
unsigned dport = ntohs(af == AF_INET ? p->v4.sin_port : p->v6.sin6_port);
socklen_t slen = sizeof u;
if (dport == config.port) {
if (dport == config->port) {
getsockname(sockfd, (void*)&u, &slen);
loop_records_add(&u);
}