return true;
}
+bool isAllWildcard(const string& address, bool checkfordots)
+{
+ bool allwildcard = true;
+ for (string::size_type pos = 0; pos < address.size(); pos++)
+ {
+ if ((address[pos] == '*') || (address[pos] == '?'))
+ {
+ continue;
+ }
+ else if ((checkfordots) && (address[pos] == '.'))
+ {
+ continue;
+ }
+ else
+ {
+ allwildcard = false;
+ break;
+ }
+ }
+ return allwildcard;
+}
+
unsigned char fixToCIDR64(string& strIP)
{
irc_in_addr ip;
//Check if we have !at least! a *@hostip format
bool isUserHost( const string& );
+bool isAllWildcard(const string&, bool checkfordots = false);
+
/* Truncate a > /64 IPv6 address to a /64 cidr address
* or creates a between /32 - /64 valid cidr address
*/
if (ipmask_len < 120) //(120 = 128 - 8)
retMe |= gline::HUH_NO_HOST; //Its too wide
+ if (isAllWildcard(Hostname, true))
+ retMe |= gline::HUH_NO_HOST;
+
if (ipmask_len < 128)
IsWildcard = true;
if (Affected > gline::MFGLINE_USERS)
retMe |= gline::FU_NEEDED_USERS; //This gline must be set with -fu flag
- if(Len > gline::MFGLINE_TIME)
+ if (Len > gline::MFGLINE_TIME)
retMe |= gline::FU_NEEDED_TIME;
- if(Len > gline::MGLINE_TIME)
+ if (Len > gline::MGLINE_TIME)
retMe |= gline::FORCE_NEEDED_TIME;
+
if (IsWildcard) //we have a 'wildcard' gline
{ //Need to check the Ident now
- bool hasId = false;
- for(string::size_type pos = 0; pos < Ident.size();++pos)
- {
- if((Ident[pos] == '*') || (Ident[pos] == '?'))
- {
- continue;
- }
- else
- { //Its not */? so we have a legal ident
- hasId = true;
- break;
- }
- }
- if((hasId & (Len > gline::MGLINE_WILD_TIME))
- || (!hasId & (Len > gline::MGLINE_WILD_NOID_TIME)))
+ bool hasId = !isAllWildcard(Ident);
+ if ((hasId & (Len > gline::MGLINE_WILD_TIME))
+ || (!hasId & (Len > gline::MGLINE_WILD_NOID_TIME)))
{
retMe |= gline::FORCE_NEEDED_WILDTIME;
}
+ if (hasId)
+ retMe |= gline::HUH_NO_HOST;
}
if (getExceptions("*@" + Hostname) > 0)