1 Commits

Author SHA1 Message Date
97fcf1d5fc Replace legacy IPv4 APIs 2026-06-24 14:24:43 -06:00
5 changed files with 22 additions and 5 deletions

View File

@@ -1483,7 +1483,7 @@ inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data)
{ {
sess->server->dcc_ip = addr.s_addr; sess->server->dcc_ip = addr.s_addr;
EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session, EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session,
inet_ntoa (addr), net_ip (ntohl (addr.s_addr)),
NULL, NULL, NULL, 0, tags_data->timestamp); NULL, NULL, NULL, 0, tags_data->timestamp);
} }
} }

View File

@@ -90,10 +90,26 @@ net_set_socket_options (int sok)
char * char *
net_ip (uint32_t addr) net_ip (uint32_t addr)
{ {
static char buf[INET_ADDRSTRLEN];
struct in_addr ia; struct in_addr ia;
ia.s_addr = htonl (addr); ia.s_addr = htonl (addr);
return inet_ntoa (ia); if (!inet_ntop (AF_INET, &ia, buf, sizeof (buf)))
buf[0] = 0;
return buf;
}
int
net_parse_ipv4 (const char *hostname, uint32_t *addr)
{
struct in_addr ia;
if (inet_pton (AF_INET, hostname, &ia) != 1)
return FALSE;
*addr = ia.s_addr;
return TRUE;
} }
int int

View File

@@ -39,6 +39,7 @@ int net_connect (netstore *ns, int sok4, int sok6, int *sok_return);
char *net_resolve (netstore *ns, char *hostname, int port, char **real_host); char *net_resolve (netstore *ns, char *hostname, int port, char **real_host);
void net_bind (netstore *tobindto, int sok4, int sok6); void net_bind (netstore *tobindto, int sok4, int sok6);
char *net_ip (uint32_t addr); char *net_ip (uint32_t addr);
int net_parse_ipv4 (const char *hostname, uint32_t *addr);
int net_lookup_ipv4 (const char *hostname, uint32_t *addr); int net_lookup_ipv4 (const char *hostname, uint32_t *addr);
void net_sockets (int *sok4, int *sok6); void net_sockets (int *sok4, int *sok6);

View File

@@ -468,7 +468,7 @@ create_mask (session * sess, char *mask, char *mode, char *typestr, int deop)
type = prefs.hex_irc_ban_type; type = prefs.hex_irc_ban_type;
buf[0] = 0; buf[0] = 0;
if (inet_addr (fullhost) != (guint32) -1) /* "fullhost" is really a IP number */ if (net_parse_ipv4 (fullhost, &(guint32){0})) /* "fullhost" is really a IP number */
{ {
lastdot = strrchr (fullhost, '.'); lastdot = strrchr (fullhost, '.');
if (!lastdot) if (!lastdot)

View File

@@ -932,7 +932,7 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
break; break;
case '5': /* prefs ip discovered */ case '5': /* prefs ip discovered */
waitline2 (source, tbuf, sizeof tbuf); waitline2 (source, tbuf, sizeof tbuf);
prefs.local_ip = inet_addr (tbuf); net_parse_ipv4 (tbuf, &prefs.local_ip);
break; break;
case '7': /* prefs.hex_net_bind_host resolve failed */ case '7': /* prefs.hex_net_bind_host resolve failed */
sprintf (outbuf, sprintf (outbuf,
@@ -1106,7 +1106,7 @@ traverse_socks (int print_fd, int sok, char *serverAddr, int port)
sc.version = 4; sc.version = 4;
sc.type = 1; sc.type = 1;
sc.port = htons (port); sc.port = htons (port);
sc.address = inet_addr (serverAddr); net_parse_ipv4 (serverAddr, &sc.address);
g_strlcpy (sc.username, prefs.hex_irc_user_name, sizeof (sc.username)); g_strlcpy (sc.username, prefs.hex_irc_user_name, sizeof (sc.username));
send (sok, (char *) &sc, 8 + strlen (sc.username) + 1, 0); send (sok, (char *) &sc, 8 + strlen (sc.username) + 1, 0);