#include "hostmask.h"
#include "numeric.h"
#include "send.h"
-#include "irc_string.h"
+#include "match.h"
#ifdef RB_IPV6
static unsigned long hash_ipv6(struct sockaddr *, int);
find_conf_by_address(const char *name, const char *sockhost,
const char *orighost,
struct sockaddr *addr, int type, int fam,
- const char *username)
+ const char *username, const char *auth_user)
{
unsigned long hprecv = 0;
struct ConfItem *hprec = NULL;
if(arec->type == (type & ~0x1) &&
arec->masktype == HM_IPV6 &&
comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
- arec->Mask.ipa.bits) && (type & 0x1
- ||
- match(arec->
- username,
- username))
- && arec->precedence > hprecv)
+ arec->Mask.ipa.bits) &&
+ (type & 0x1 || match(arec-> username, username)) &&
+ (type != CONF_CLIENT || !arec->auth_user ||
+ (auth_user && match(arec->auth_user, auth_user))) &&
+ arec->precedence > hprecv)
{
hprecv = arec->precedence;
hprec = arec->aconf;
for (arec = atable[hash_ipv4(addr, b)]; arec; arec = arec->next)
if(arec->type == (type & ~0x1) &&
arec->masktype == HM_IPV4 &&
- arec->precedence > hprecv &&
comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
arec->Mask.ipa.bits) &&
- (type & 0x1 || match(arec->username, username)))
+ (type & 0x1 || match(arec->username, username)) &&
+ (type != CONF_CLIENT || !arec->auth_user ||
+ (auth_user && match(arec->auth_user, auth_user))) &&
+ arec->precedence > hprecv)
{
hprecv = arec->precedence;
hprec = arec->aconf;
(arec->masktype == HM_HOST) &&
arec->precedence > hprecv &&
match(arec->Mask.hostname, orighost) &&
+ (type != CONF_CLIENT || !arec->auth_user ||
+ (auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
arec->precedence > hprecv &&
(match(arec->Mask.hostname, orighost) ||
(sockhost && match(arec->Mask.hostname, sockhost))) &&
+ (type != CONF_CLIENT || !arec->auth_user ||
+ (auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
(arec->masktype == HM_HOST) &&
arec->precedence > hprecv &&
match(arec->Mask.hostname, name) &&
+ (type != CONF_CLIENT || !arec->auth_user ||
+ (auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
arec->precedence > hprecv &&
(match(arec->Mask.hostname, name) ||
(sockhost && match(arec->Mask.hostname, sockhost))) &&
+ (type != CONF_CLIENT || !arec->auth_user ||
+ (auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
*/
struct ConfItem *
find_address_conf(const char *host, const char *sockhost, const char *user,
- const char *notildeuser, struct sockaddr *ip, int aftype)
+ const char *notildeuser, struct sockaddr *ip, int aftype, char *auth_user)
{
struct ConfItem *iconf, *kconf;
const char *vuser;
/* Find the best I-line... If none, return NULL -A1kmm */
- if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user)))
+ if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user, auth_user)))
return NULL;
/* Find what their visible username will be.
* Note that the username without tilde may contain one char more.
return iconf;
/* Find the best K-line... -A1kmm */
- kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, user);
+ kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, user, NULL);
/* If they are K-lined, return the K-line */
if(kconf)
if(p)
{
*p = '\0';
- kconf = find_conf_by_address(p+1, NULL, NULL, ip, CONF_KILL, aftype, iconf->name);
+ kconf = find_conf_by_address(p+1, NULL, NULL, ip, CONF_KILL, aftype, iconf->name, NULL);
*p = '@';
}
else
- kconf = find_conf_by_address(iconf->name, NULL, NULL, ip, CONF_KILL, aftype, vuser);
+ kconf = find_conf_by_address(iconf->name, NULL, NULL, ip, CONF_KILL, aftype, vuser, NULL);
if(kconf)
return kconf;
* -- jilles */
if(user != vuser)
{
- kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, vuser);
+ kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, vuser, NULL);
if(kconf)
return kconf;
}
find_dline(struct sockaddr *addr, int aftype)
{
struct ConfItem *eline;
- eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL);
+ eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL, NULL);
if(eline)
return eline;
- return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL);
+ return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL);
}
/* void find_exact_conf_by_address(const char*, int, const char *)
if(address == NULL)
address = "/NOMATCH!/";
- arec = rb_malloc(sizeof(struct AddressRec));
masktype = parse_netmask(address, (struct sockaddr *)&addr, &bits);
#ifdef RB_IPV6
if(masktype == HM_IPV6)
* Side-effects: Adds this entry to the hash table.
*/
void
-add_conf_by_address(const char *address, int type, const char *username, struct ConfItem *aconf)
+add_conf_by_address(const char *address, int type, const char *username, const char *auth_user, struct ConfItem *aconf)
{
static unsigned long prec_value = 0xFFFFFFFF;
int masktype, bits;
atable[hv] = arec;
}
arec->username = username;
+ arec->auth_user = auth_user;
arec->aconf = aconf;
arec->precedence = prec_value--;
arec->type = type;
get_printable_conf(aconf, &name, &host, &pass, &user, &port,
&classname);
+
+ if(!EmptyString(aconf->spasswd))
+ pass = aconf->spasswd;
sendto_one_numeric(client_p, RPL_STATSILINE,
form_str(RPL_STATSILINE),
- name, show_iline_prefix(client_p, aconf, user),
+ name, pass, show_iline_prefix(client_p, aconf, user),
show_ip_conf(aconf, client_p) ? host : "255.255.255.255",
port, classname);
}