+2004-09-10 Michael Poole <mdpoole@troilus.org>
+
+ * include/s_conf.h (struct ConfItem): Add origin and origin_name
+ fields.
+
+ * ircd/ircd_parser.y: Add new global variable "origin." Add a new
+ "connectionvhost" production that accepts vhost = "IP" inside a
+ Connect block and assigns the IP to origin_name.
+
+ * ircd/s_bsd (connect_inet): If aconf has a valid origin, use it
+ as the local address. Otherwise, fall back to the old logic (if
+ VIRTUAL_HOST="TRUE", use the virtual host setting).
+
+ * ircd/s_conf.c (lookup_confhost): If the ConfItem has an
+ origin_name, try to parse it as an IP address.
+
2004-04-17 Isomer <isomer@undernet.org>
* ircd/parse.c: Don't rate limit /gline messages
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
unsigned int clients; /* Number of *LOCAL* clients using this */
struct ConnectionClass *conn_class; /* Class of connection */
+ struct irc_sockaddr origin; /* local address */
struct irc_sockaddr address; /* ip and port */
char *host;
+ char *origin_name;
char *passwd;
char *name;
time_t hold; /* Hold until this time (calendar time) */
/* Now all the globals we need :/... */
int tping, tconn, maxlinks, sendq, port, invert;
int stringno;
- char *name, *pass, *host;
+ char *name, *pass, *host, *origin;
char *stringlist[MAX_STRINGS];
struct ConnectionClass *c_class;
struct ConfItem *aconf;
connectblock: CONNECT
{
- name = pass = host = NULL;
+ name = pass = host = origin = NULL;
c_class = NULL;
port = 0;
} '{' connectitems '}'
aconf = make_conf();
aconf->status = CONF_SERVER;
aconf->name = name;
+ aconf->origin_name = origin;
aconf->passwd = pass;
aconf->conn_class = c_class;
aconf->address.port = port;
MyFree(name);
MyFree(pass);
MyFree(host);
- name = pass = host = NULL;
+ MyFree(origin);
parse_error("Bad connect block");
}
+ name = pass = host = origin = NULL;
}';';
connectitems: connectitem connectitems | connectitem;
connectitem: connectname | connectpass | connectclass | connecthost
- | connectport | error;
+ | connectport | connectvhost | error;
connectname: NAME '=' QSTRING ';'
{
MyFree(name);
{
port = $3;
};
+connectvhost: VHOST '=' QSTRING ';'
+{
+ MyFree(origin);
+ DupString(origin, $3);
+};
serverblock: SERVER
{
*/
static int connect_inet(struct ConfItem* aconf, struct Client* cptr)
{
+ const struct irc_sockaddr *local;
IOResult result;
assert(0 != aconf);
assert(0 != cptr);
* Might as well get sockhost from here, the connection is attempted
* with it so if it fails its useless.
*/
- cli_fd(cptr) = os_socket((feature_bool(FEAT_VIRTUAL_HOST) ? &VirtualHost : NULL), SOCK_STREAM, cli_name(cptr));
+ if (irc_in_addr_valid(&aconf->origin.addr))
+ local = &aconf->origin;
+ else if (feature_bool(FEAT_VIRTUAL_HOST))
+ local = &VirtualHost;
+ else
+ local = NULL;
+ cli_fd(cptr) = os_socket(local, SOCK_STREAM, cli_name(cptr));
if (cli_fd(cptr) < 0)
return 0;
aconf->host, aconf->name));
return;
}
+ if (aconf->origin_name
+ && !ircd_aton(&aconf->origin.addr, aconf->origin_name)) {
+ Debug((DEBUG_ERROR, "Origin name error: (%s) (%s)",
+ aconf->origin_name, aconf->name));
+ }
/*
* Do name lookup now on hostnames given and store the
* ip numbers in conf structure.