use GIO resolver

change: rename resolve_prefer_ipv6 -> irssiproxy_prefer_ipv6
This commit is contained in:
Ailin Nemui 2025-07-27 20:06:10 +02:00
commit 51f2a4f7fb
18 changed files with 313 additions and 339 deletions

View file

@ -6,6 +6,7 @@
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <irssi/src/common.h>
#ifndef AF_INET6
# ifdef PF_INET6
@ -20,6 +21,13 @@ struct _IPADDR {
struct in6_addr ip;
};
typedef struct {
int refcount;
/* GList<GInetAddress> */
GList *ailist; /* needs to be freed */
GError *error; /* needs to be freed */
} RESOLVED_IP_REC;
/* maxmimum string length of IP address */
#define MAX_IP_LEN INET6_ADDRSTRLEN
@ -29,9 +37,7 @@ extern IPADDR ip4_any;
GIOChannel *i_io_channel_new(int handle);
/* Returns 1 if IPADDRs are the same. */
/* Deprecated since it is unused. It will be deleted in a later release. */
int net_ip_compare(IPADDR *ip1, IPADDR *ip2) G_GNUC_DEPRECATED;
/* OTR */
int i_io_channel_write_block(GIOChannel *channel, void *data, int len);
int i_io_channel_read_block(GIOChannel *channel, void *data, int len);
@ -60,18 +66,9 @@ int net_receive(GIOChannel *handle, char *buf, int len);
/* Transmit data, return number of bytes sent, -1 = error */
int net_transmit(GIOChannel *handle, const char *data, int len);
/* Get IP addresses for host, both IPv4 and IPv6 if possible.
If ip->family is 0, the address wasn't found.
Returns 0 = ok, others = error code for net_gethosterror() */
int net_gethostbyname(const char *addr, IPADDR *ip4, IPADDR *ip6);
/* Get name for host, *name should be g_free()'d unless it's NULL.
Return values are the same as with net_gethostbyname() */
int net_gethostbyaddr(IPADDR *ip, char **name);
/* get error of net_gethostname() */
const char *net_gethosterror(int error);
/* return TRUE if host lookup failed because it didn't exist (ie. not
some error with name server) */
int net_hosterror_notfound(int error);
/* Get the first IP address for host, both IPv4 and IPv6 if possible. */
int net_gethostbyname_first_ips(const char *addr, GResolverNameLookupFlags flags, IPADDR *ip4,
IPADDR *ip6);
/* Get socket address/port */
int net_getsockname(GIOChannel *handle, IPADDR *addr, int *port);
@ -90,4 +87,7 @@ char *net_getservbyport(int port);
int is_ipv4_address(const char *host);
int is_ipv6_address(const char *host);
void resolved_ip_ref(RESOLVED_IP_REC *iprec);
int resolved_ip_unref(RESOLVED_IP_REC *iprec);
#endif