aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-07-24 23:48:25 -0400
committerTest_User <hax@andrewyu.org>2024-07-24 23:48:25 -0400
commitd4afb359bc2a41c16cc8ce7baac58a5fad94c468 (patch)
tree71da9038c6721ba351b33cb6098b6d310b961050
parent86344230a6bb79b95880769fbee4d859583c9ac4 (diff)
downloadhaxircd-d4afb359bc2a41c16cc8ce7baac58a5fad94c468.tar.gz
haxircd-d4afb359bc2a41c16cc8ce7baac58a5fad94c468.zip
Toggleable IPv4 support
-rw-r--r--Makefile21
-rw-r--r--general_network.c6
-rw-r--r--protocols/inspircd3.c4
-rw-r--r--server_network.c8
4 files changed, 35 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 6317911..0c8a54f 100644
--- a/Makefile
+++ b/Makefile
@@ -54,6 +54,7 @@ LDFLAGS = -lpthread
printf '%s\n' 'LAST_FUTEX = $(FUTEX)' >> .makeopts
printf '%s\n' 'LAST_MISERABLE_SPINLOCKS = $(MISERABLE_SPINLOCKS)' >> .makeopts
printf '%s\n' 'LAST_ATOMICS = $(ATOMICS)' >> .makeopts
+ printf '%s\n' 'LAST_IPv4 = $(IPv4)' >> .makeopts
printf '%s\n' 'LAST_IPv6 = $(IPv6)' >> .makeopts
printf '%s\n' 'LAST_CFLAGS = $(ORIGINAL_CFLAGS)' >> .makeopts
printf '%s\n' 'LAST_CC = $(CC)' >> .makeopts
@@ -250,6 +251,14 @@ else
ATOMICS := $(LAST_ATOMICS)
endif
+ifneq ($(IPv4),)
+ifneq ($(IPv4),$(LAST_IPv4))
+rebuild = 1
+endif
+else
+IPv4 := $(LAST_IPv4)
+endif
+
ifneq ($(IPv6),)
ifneq ($(IPv6),$(LAST_IPv6))
rebuild = 1
@@ -460,8 +469,20 @@ endif
+IP_ENABLED := 0
+
+ifeq ($(IPv4),1)
+CFLAGS += -DUSE_IPv4
+IP_ENABLED := 1
+endif
+
ifeq ($(IPv6),1)
CFLAGS += -DUSE_IPv6
+IP_ENABLED := 1
+endif
+
+ifneq ($(IP_ENABLED),1)
+$(error I don't know how you intend to use TCP/IP without IP)
endif
diff --git a/general_network.c b/general_network.c
index 452b950..d9e8e75 100644
--- a/general_network.c
+++ b/general_network.c
@@ -206,7 +206,11 @@ int resolve(struct string address, struct string port, struct sockaddr *sockaddr
if (success == 0) {
struct addrinfo *this = info;
while (1) {
- if (this->ai_family == AF_INET
+ if (0
+#ifdef USE_IPv4
+ || this->ai_family == AF_INET
+#endif
+
#ifdef USE_IPv6
|| this->ai_family == AF_INET6
#endif
diff --git a/protocols/inspircd3.c b/protocols/inspircd3.c
index c2f4952..ba93431 100644
--- a/protocols/inspircd3.c
+++ b/protocols/inspircd3.c
@@ -910,7 +910,7 @@ void inspircd3_protocol_handle_unlink_server(struct string from, struct server_i
int inspircd3_protocol_handle_new_user(struct string from, struct user_info *info) {
struct server_info *server = get_table_index(server_list, info->server);
- if (STRING_EQ(server->sid, SID) || server->protocol != INSPIRCD3_PROTOCOL) {
+ if (STRING_EQ(info->server, SID) || server->protocol != INSPIRCD3_PROTOCOL) {
info->protocol_specific[INSPIRCD3_PROTOCOL] = 0;
return 0;
}
@@ -934,7 +934,7 @@ int inspircd3_protocol_handle_rename_user(struct string from, struct user_info *
void inspircd3_protocol_handle_remove_user(struct string from, struct user_info *info, struct string reason, char propagate) {
struct server_info *server = get_table_index(server_list, info->server);
- if (STRING_EQ(server->sid, SID) || server->protocol != INSPIRCD3_PROTOCOL)
+ if (STRING_EQ(info->server, SID) || server->protocol != INSPIRCD3_PROTOCOL)
return;
struct inspircd3_protocol_specific_user *prot_info = info->protocol_specific[INSPIRCD3_PROTOCOL];
diff --git a/server_network.c b/server_network.c
index cbe00a1..77ebd6f 100644
--- a/server_network.c
+++ b/server_network.c
@@ -121,6 +121,7 @@ int start_server_network_threads(size_t net) {
struct server_network_info *type;
for (size_t i = 0; i < NUM_PROTOCOLS; i++) {
if (active_protocols[i] && SERVER_INCOMING[net][i]) {
+#ifdef USE_IPv4
type = malloc(sizeof(*type));
if (!type)
return 1;
@@ -132,6 +133,7 @@ int start_server_network_threads(size_t net) {
free(type);
return 1;
}
+#endif
#ifdef USE_IPv6
type = malloc(sizeof(*type));
@@ -176,8 +178,12 @@ void * server_accept_thread(void *type) {
.ss_family = family,
};
- if (family == AF_INET) {
+ if (0) {
+#ifdef USE_IPv4
+ } else if (family == AF_INET) {
((struct sockaddr_in *)&sockaddr)->sin_port = htons(SERVER_PORTS[net][protocol]);
+#endif
+
#ifdef USE_IPv6
} else if (family == AF_INET6) {
int one = 1;