1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-04 23:33:14 +02:00

[4246] Add set::link::bind-ip option to set default bind ip for link blocks

This commit is contained in:
Heero
2014-06-03 23:39:30 -07:00
parent cffca2c840
commit e75cb1709d
4 changed files with 46 additions and 3 deletions
+2
View File
@@ -80,6 +80,7 @@ struct zConfiguration {
int host_retries;
char *name_server;
char *dns_bindip;
char *link_bindip;
long throttle_period;
char throttle_count;
char *kline_address;
@@ -186,6 +187,7 @@ extern MODVAR aConfiguration iConf;
#define HOST_RETRIES iConf.host_retries
#define NAME_SERVER iConf.name_server
#define DNS_BINDIP iConf.dns_bindip
#define LINK_BINDIP iConf.link_bindip
#define IDENT_CHECK iConf.ident_check
#define FAILOPER_WARN iConf.fail_oper_warn
#define SHOWCONNECTINFO iConf.show_connect_info
+3
View File
@@ -1285,6 +1285,9 @@ int stats_set(aClient *sptr, char *para)
sptr->name, DNS_BINDIP);
sendto_one(sptr, ":%s %i %s :ban-version-tkl-time: %s", me.name, RPL_TEXT,
sptr->name, pretty_time_val(BAN_VERSION_TKL_TIME));
if (LINK_BINDIP)
sendto_one(sptr, ":%s %i %s :link::bind-ip: %s", me.name, RPL_TEXT,
sptr->name, LINK_BINDIP);
sendto_one(sptr, ":%s %i %s :throttle::period: %s", me.name, RPL_TEXT,
sptr->name, THROTTLING_PERIOD ? pretty_time_val(THROTTLING_PERIOD) : "disabled");
sendto_one(sptr, ":%s %i %s :throttle::connections: %d", me.name, RPL_TEXT,
+10 -3
View File
@@ -1664,6 +1664,7 @@ static struct SOCKADDR *connect_inet(ConfigItem_link *aconf, aClient *cptr, int
{
static struct SOCKADDR_IN server;
struct hostent *hp;
char *bindip;
char buf[BUFSIZE];
/*
@@ -1692,15 +1693,21 @@ static struct SOCKADDR *connect_inet(ConfigItem_link *aconf, aClient *cptr, int
get_sockhost(cptr, aconf->hostname);
if (aconf->bindip && strcmp("*", aconf->bindip))
if (!aconf->bindip && iConf.link_bindip)
bindip = iConf.link_bindip;
else
bindip = aconf->bindip;
if (bindip && strcmp("*", bindip))
{
bzero((char *)&server, sizeof(server));
server.SIN_FAMILY = AFINET;
server.SIN_PORT = 0;
#ifndef INET6
server.SIN_ADDR.S_ADDR = inet_addr(aconf->bindip);
server.SIN_ADDR.S_ADDR = inet_addr(bindip);
#else
inet_pton(AF_INET6, aconf->bindip, server.SIN_ADDR.S_ADDR);
inet_pton(AF_INET6, bindip, server.SIN_ADDR.S_ADDR);
#endif
if (bind(cptr->fd, (struct SOCKADDR *)&server, sizeof(server)) == -1)
{
+31
View File
@@ -6068,6 +6068,7 @@ int _conf_link(ConfigFile *conf, ConfigEntry *ce)
link = (ConfigItem_link *) MyMallocEx(sizeof(ConfigItem_link));
link->servername = strdup(ce->ce_vardata);
/* ugly, but it works. if it fails, we know _test_link failed miserably */
for (cep = ce->ce_entries; cep; cep = cep->ce_next)
{
@@ -6116,6 +6117,7 @@ int _conf_link(ConfigFile *conf, ConfigEntry *ce)
link->ciphers = strdup(cep->ce_vardata);
#endif
}
AddListItem(link, conf_link);
return 0;
}
@@ -7004,6 +7006,13 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
else
ircstrdup(tempiConf.network.x_prefix_quit, cep->ce_vardata);
}
else if (!strcmp(cep->ce_varname, "link")) {
for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
if (!strcmp(cepp->ce_varname, "bind-ip")) {
ircstrdup(tempiConf.link_bindip, cepp->ce_vardata);
}
}
}
else if (!strcmp(cep->ce_varname, "dns")) {
for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
if (!strcmp(cepp->ce_varname, "timeout")) {
@@ -7018,6 +7027,7 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
else if (!strcmp(cepp->ce_varname, "bind-ip")) {
ircstrdup(tempiConf.dns_bindip, cepp->ce_vardata);
}
}
}
else if (!strcmp(cep->ce_varname, "throttle")) {
@@ -7657,6 +7667,27 @@ int _test_set(ConfigFile *conf, ConfigEntry *ce)
CheckDuplicate(cep, new_linking_protocol, "new-linking-protocol");
CheckNull(cep);
}
else if (!strcmp(cep->ce_varname, "link")) {
for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
CheckNull(cepp);
if (!strcmp(cepp->ce_varname, "bind-ip")) {
struct in_addr in;
CheckDuplicate(cepp, dns_bind_ip, "link::bind-ip");
if (strcmp(cepp->ce_vardata, "*"))
{
in.s_addr = inet_addr(cepp->ce_vardata);
if (strcmp((char *)inet_ntoa(in), cepp->ce_vardata))
{
config_error("%s:%i: set::link::bind-ip (%s) is not a valid IP",
cepp->ce_fileptr->cf_filename, cepp->ce_varlinenum,
cepp->ce_vardata);
errors++;
continue;
}
}
}
}
}
else if (!strcmp(cep->ce_varname, "dns")) {
for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
CheckNull(cepp);