@ -75,7 +75,7 @@ namespace bt
Uint32 ipi = toUint32 ( ip , & ok ) ;
if ( ! ok )
return ;
IPKey key ( ipi , 0xFFFFFFFF ) ; //-- you can test ranges here. Just specify your tq mask.
IPKey key ( ipi , 0xFFFFFFFF ) ; //-- you can test ranges here. Just specify your mask.
insertRangeIP ( key , state ) ;
Out ( SYS_IPF | LOG_NOTICE ) < < " IP " < < ip < < " banned. " < < endl ;
}
@ -85,13 +85,13 @@ namespace bt
bool ok ;
int tmp = 0 ;
Uint32 addr = 0 ;
Uint32 tq mask = 0xFFFFFFFF ;
Uint32 mask = 0xFFFFFFFF ;
tmp = ip . section ( ' . ' , 0 , 0 ) . toInt ( & ok ) ;
if ( ! ok )
{
if ( ip . section ( ' . ' , 0 , 0 ) = = " * " )
tq mask & = 0x00FFFFFF ;
mask & = 0x00FFFFFF ;
else return ; //illegal character
}
else
@ -102,7 +102,7 @@ namespace bt
{
addr < < = 8 ;
if ( ip . section ( ' . ' , 1 , 1 ) = = " * " )
tq mask & = 0xFF00FFFF ;
mask & = 0xFF00FFFF ;
else return ; //illegal character
}
else
@ -116,7 +116,7 @@ namespace bt
{
addr < < = 8 ;
if ( ip . section ( ' . ' , 2 , 2 ) = = " * " )
tq mask & = 0xFFFF00FF ;
mask & = 0xFFFF00FF ;
else return ; //illegal character
}
else
@ -130,7 +130,7 @@ namespace bt
{
addr < < = 8 ;
if ( ip . section ( ' . ' , 3 , 3 ) = = " * " )
tq mask & = 0xFFFFFF00 ;
mask & = 0xFFFFFF00 ;
else return ; //illegal character
}
else
@ -139,21 +139,21 @@ namespace bt
addr | = tmp ;
}
IPKey key ( addr , tq mask) ;
IPKey key ( addr , mask) ;
this - > insertRangeIP ( key ) ;
}
void IPBlocklist : : insertRangeIP ( IPKey & key , int state )
{
// Out() << "Blocked range: " << key.m_ip << " - " << key.m_ tq mask << endl;
// Out() << "Blocked range: " << key.m_ip << " - " << key.m_ mask << endl;
TQMap < IPKey , int > : : iterator it ;
if ( ( it = m_peers . find ( key ) ) ! = m_peers . end ( ) )
{
if ( it . key ( ) . m_ tq mask ! = key . m_ tq mask)
if ( it . key ( ) . m_ mask ! = key . m_ mask)
{
int st = it . data ( ) ;
IPKey key1 ( key . m_ip , it . key ( ) . m_ tq mask | key . m_ tq mask) ;
IPKey key1 ( key . m_ip , it . key ( ) . m_ mask | key . m_ mask) ;
m_peers . insert ( key1 , state + st ) ;
return ;
}
@ -168,13 +168,13 @@ namespace bt
bool ok ;
int tmp = 0 ;
Uint32 addr = 0 ;
Uint32 tq mask = 0xFFFFFFFF ;
Uint32 mask = 0xFFFFFFFF ;
tmp = ip . section ( ' . ' , 0 , 0 ) . toInt ( & ok ) ;
if ( ! ok )
{
if ( ip . section ( ' . ' , 0 , 0 ) = = " * " )
tq mask & = 0x00FFFFFF ;
mask & = 0x00FFFFFF ;
else return ; //illegal character
}
else
@ -185,7 +185,7 @@ namespace bt
{
addr < < = 8 ;
if ( ip . section ( ' . ' , 1 , 1 ) = = " * " )
tq mask & = 0xFF00FFFF ;
mask & = 0xFF00FFFF ;
else return ; //illegal character
}
else
@ -199,7 +199,7 @@ namespace bt
{
addr < < = 8 ;
if ( ip . section ( ' . ' , 2 , 2 ) = = " * " )
tq mask & = 0xFFFF00FF ;
mask & = 0xFFFF00FF ;
else return ; //illegal character
}
else
@ -213,7 +213,7 @@ namespace bt
{
addr < < = 8 ;
if ( ip . section ( ' . ' , 3 , 3 ) = = " * " )
tq mask & = 0xFFFFFF00 ;
mask & = 0xFFFFFF00 ;
else return ; //illegal character
}
else
@ -222,7 +222,7 @@ namespace bt
addr | = tmp ;
}
IPKey key ( addr , tq mask) ;
IPKey key ( addr , mask) ;
TQMap < IPKey , int > : : iterator it = m_peers . find ( key ) ;
if ( it = = m_peers . end ( ) )
@ -304,11 +304,11 @@ namespace bt
IPKey : : IPKey ( )
{
m_ip = 0 ;
m_ tq mask = 0xFFFFFFFF ;
m_ mask = 0xFFFFFFFF ;
}
IPKey : : IPKey ( TQString & ip , Uint32 tq mask)
: m_ tq mask( tq mask)
IPKey : : IPKey ( TQString & ip , Uint32 mask)
: m_ mask( mask)
{
bool ok ;
this - > m_ip = toUint32 ( ip , & ok ) ;
@ -317,55 +317,55 @@ namespace bt
IPKey : : IPKey ( const IPKey & ip )
{
m_ip = ip . m_ip ;
m_ tq mask = ip . m_ tq mask;
m_ mask = ip . m_ mask;
}
IPKey : : IPKey ( Uint32 ip , Uint32 tq mask)
: m_ip ( ip ) , m_ tq mask( tq mask)
IPKey : : IPKey ( Uint32 ip , Uint32 mask)
: m_ip ( ip ) , m_ mask( mask)
{ }
TQString IPKey : : toString ( )
{
Uint32 tmp , tmp tq mask;
Uint32 tmp , tmp mask;
Uint32 ip = m_ip ;
Uint32 tq mask = m_ tq mask;
Uint32 mask = m_ mask;
TQString out ;
tmp = ip ;
tmp tq mask = tq mask;
tmp mask = mask;
tmp & = 0x000000FF ;
tmp tq mask & = 0x000000FF ;
if ( tmp tq mask = = 0 )
tmp mask & = 0x000000FF ;
if ( tmp mask = = 0 )
out . prepend ( " * " ) ;
else
out . prepend ( TQString ( " %1 " ) . tqarg ( tmp ) ) ;
ip > > = 8 ;
tq mask > > = 8 ;
mask > > = 8 ;
tmp = ip ;
tmp tq mask = tq mask;
tmp mask = mask;
tmp & = 0x000000FF ;
tmp tq mask & = 0x000000FF ;
if ( tmp tq mask = = 0 )
tmp mask & = 0x000000FF ;
if ( tmp mask = = 0 )
out . prepend ( " *. " ) ;
else
out . prepend ( TQString ( " %1. " ) . tqarg ( tmp ) ) ;
ip > > = 8 ;
tq mask > > = 8 ;
mask > > = 8 ;
tmp = ip ;
tmp tq mask = tq mask;
tmp mask = mask;
tmp & = 0x000000FF ;
tmp tq mask & = 0x000000FF ;
if ( tmp tq mask = = 0 )
tmp mask & = 0x000000FF ;
if ( tmp mask = = 0 )
out . prepend ( " *. " ) ;
else
out . prepend ( TQString ( " %1. " ) . tqarg ( tmp ) ) ;
ip > > = 8 ;
tq mask > > = 8 ;
mask > > = 8 ;
tmp = ip ;
tmp tq mask = tq mask;
tmp mask = mask;
tmp & = 0x000000FF ;
tmp tq mask & = 0x000000FF ;
if ( tmp tq mask = = 0 )
tmp mask & = 0x000000FF ;
if ( tmp mask = = 0 )
out . prepend ( " *. " ) ;
else
out . prepend ( TQString ( " %1. " ) . tqarg ( tmp ) ) ;
@ -375,23 +375,23 @@ namespace bt
bool IPKey : : operator = = ( const IPKey & ip ) const
{
return ( m_ip & m_ tq mask) = = m_ tq mask & ip . m_ip ;
return ( m_ip & m_ mask) = = m_ mask & ip . m_ip ;
}
bool IPKey : : operator ! = ( const IPKey & ip ) const
{
return ( m_ip & m_ tq mask) ! = m_ tq mask & ip . m_ip ;
return ( m_ip & m_ mask) ! = m_ mask & ip . m_ip ;
}
bool IPKey : : operator < ( const IPKey & ip ) const
{
return ( m_ip & m_ tq mask) < ( m_ tq mask & ip . m_ip ) ;
return ( m_ip & m_ mask) < ( m_ mask & ip . m_ip ) ;
}
IPKey & IPKey : : operator = ( const IPKey & ip )
{
m_ip = ip . m_ip ;
m_ tq mask = ip . m_ tq mask;
m_ mask = ip . m_ mask;
return * this ;
}