|
|
|
@ -49,7 +49,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
// bool isFTQHN = checkFTQHN( str_input );
|
|
|
|
|
bool isNETWORK = checkNetWork( str_input );
|
|
|
|
|
if ( !isIP && !isNETWORK ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "IP/NETWORK/FTQHN" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "IP/NETWORK/FTQHN" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::HINT );
|
|
|
|
|
return;
|
|
|
|
@ -64,7 +64,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
if ( inp_type == "PORT" ) {
|
|
|
|
|
bool isPORT = checkPORT( str_input );
|
|
|
|
|
if ( !isPORT ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "PORT" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "PORT" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -79,7 +79,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
if ( inp_type == "MULTIPORT" ) {
|
|
|
|
|
bool isMULTIPORT = checkMULTIPORT( str_input );
|
|
|
|
|
if ( !isMULTIPORT ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "MULTIPORT" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "MULTIPORT" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -95,7 +95,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
bool isPORT = checkPORT( str_input );
|
|
|
|
|
bool isPORTRANGE = checkPORTRANGE( str_input );
|
|
|
|
|
if ( !isPORT && !isPORTRANGE ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "PORT" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "PORT" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -110,7 +110,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
if ( inp_type == "FTQHN" ) {
|
|
|
|
|
bool isFTQHN = checkFTQHN( str_input );
|
|
|
|
|
if ( !isFTQHN ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "FTQHN" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "FTQHN" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -125,7 +125,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
if ( inp_type == "IP" ) {
|
|
|
|
|
bool isIP = checkIP( str_input );
|
|
|
|
|
if ( !isIP ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "IP" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "IP" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -141,7 +141,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
if ( inp_type == "CHAINNAME" ) {
|
|
|
|
|
bool isValid = checkChainName( str_input );
|
|
|
|
|
if ( !isValid ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "CHAINNAME" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "CHAINNAME" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -156,7 +156,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
if ( inp_type == "RULENAME" ) {
|
|
|
|
|
bool isValid = checkRuleName( str_input );
|
|
|
|
|
if ( !isValid ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "RULENAME" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "RULENAME" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -171,7 +171,7 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
if ( inp_type == "MAC" ) {
|
|
|
|
|
bool isValid = checkMAC( str_input );
|
|
|
|
|
if ( !isValid ) {
|
|
|
|
|
const TQString msg = *m_msg_dict.tqfind( "MAC" );
|
|
|
|
|
const TQString msg = *m_msg_dict.find( "MAC" );
|
|
|
|
|
err->setErrMsg( msg );
|
|
|
|
|
err->setErrType( KMFError::NORMAL );
|
|
|
|
|
return;
|
|
|
|
@ -192,12 +192,12 @@ void KMFCheckInput::checkInput( const TQString& inp, const TQString& inp_type, K
|
|
|
|
|
bool KMFCheckInput::checkIP( TQString inp ) {
|
|
|
|
|
TQRegExp exp( "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$" );
|
|
|
|
|
// kdDebug() << "RegEx isValid: " << exp.isValid() << endl;
|
|
|
|
|
if ( inp.tqcontains( exp ) ) {
|
|
|
|
|
if ( inp.contains( exp ) ) {
|
|
|
|
|
int pos;
|
|
|
|
|
TQString str_num;
|
|
|
|
|
bool valid = true;
|
|
|
|
|
while ( !inp.isEmpty() ) {
|
|
|
|
|
pos = inp.tqfind( "." );
|
|
|
|
|
pos = inp.find( "." );
|
|
|
|
|
if ( pos > -1 ) {
|
|
|
|
|
str_num = inp.left( pos );
|
|
|
|
|
// kdDebug() << "IP Num Part: " << str_num << endl;
|
|
|
|
@ -229,7 +229,7 @@ bool KMFCheckInput::checkIP( TQString inp ) {
|
|
|
|
|
bool KMFCheckInput::checkNetMask ( TQString inp ) {
|
|
|
|
|
TQRegExp exp( "^[0-9]{1,2}$" );
|
|
|
|
|
// kdDebug() << "RegEx isValid: " << exp.isValid() << endl;
|
|
|
|
|
if ( inp.tqcontains( exp ) ) {
|
|
|
|
|
if ( inp.contains( exp ) ) {
|
|
|
|
|
int val = inp.toInt();
|
|
|
|
|
if ( val < 0 || val > 24 ) {
|
|
|
|
|
kdDebug() << "Mask must not be > 24" << endl;
|
|
|
|
@ -245,7 +245,7 @@ bool KMFCheckInput::checkNetMask ( TQString inp ) {
|
|
|
|
|
bool KMFCheckInput::checkPORT ( TQString inp ) {
|
|
|
|
|
TQRegExp exp( "^[0-9]{1,5}$" );
|
|
|
|
|
// kdDebug() << "RegEx isValid: " << exp.isValid() << endl;
|
|
|
|
|
if ( inp.tqcontains( exp ) ) {
|
|
|
|
|
if ( inp.contains( exp ) ) {
|
|
|
|
|
int val = inp.toInt();
|
|
|
|
|
if ( val < 0 || val > 65535 ) {
|
|
|
|
|
kdDebug() << "Port must not be > 65535" << endl;
|
|
|
|
@ -262,7 +262,7 @@ bool KMFCheckInput::checkMULTIPORT ( TQString inp ) {
|
|
|
|
|
TQString tmp = inp;
|
|
|
|
|
while ( !tmp.isEmpty() ) {
|
|
|
|
|
TQString port = "";
|
|
|
|
|
int pos = tmp.tqfind( "," );
|
|
|
|
|
int pos = tmp.find( "," );
|
|
|
|
|
if ( pos == -1 ) {
|
|
|
|
|
port = tmp;
|
|
|
|
|
port = port.stripWhiteSpace();
|
|
|
|
@ -288,7 +288,7 @@ bool KMFCheckInput::checkPORTRANGE ( TQString inp ) {
|
|
|
|
|
bool valid_1 = false;
|
|
|
|
|
bool valid_2 = false;
|
|
|
|
|
kdDebug() << "Checking for PORTRANGE: " << endl;
|
|
|
|
|
int delimiter = inp.tqfind( ":" );
|
|
|
|
|
int delimiter = inp.find( ":" );
|
|
|
|
|
if ( delimiter == -1 ) {
|
|
|
|
|
kdDebug() << "This is no port range" << endl;
|
|
|
|
|
return false;
|
|
|
|
@ -310,7 +310,7 @@ bool KMFCheckInput::checkNetWork ( TQString inp ) {
|
|
|
|
|
bool valid_address = false;
|
|
|
|
|
bool valid_tqmask = false;
|
|
|
|
|
kdDebug() << "Checking for NETWORK: " << endl;
|
|
|
|
|
int delimiter = inp.tqfind( "/" );
|
|
|
|
|
int delimiter = inp.find( "/" );
|
|
|
|
|
if ( delimiter == -1 ) {
|
|
|
|
|
kdDebug() << "This is no network" << endl;
|
|
|
|
|
return false;
|
|
|
|
@ -345,7 +345,7 @@ bool KMFCheckInput::checkFTQHN( TQString inp ) {
|
|
|
|
|
bool valid = TRUE;
|
|
|
|
|
// TQRegExp exp( "^(\\w{1,256})\\.([a-z]{2,6})$", false );
|
|
|
|
|
TQRegExp exp( "^[0-9a-zA-Z_-\\.]{3,256}$", false );
|
|
|
|
|
if ( !inp.tqcontains( exp ) )
|
|
|
|
|
if ( !inp.contains( exp ) )
|
|
|
|
|
valid = false;
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
|
|
|
@ -353,7 +353,7 @@ bool KMFCheckInput::checkFTQHN( TQString inp ) {
|
|
|
|
|
bool KMFCheckInput::checkMAC( TQString inp ) {
|
|
|
|
|
bool valid = TRUE;
|
|
|
|
|
TQRegExp exp( "^[0-9a-fA-F]{2,2}\\:[0-9a-fA-F]{2,2}\\:[0-9a-fA-F]{2,2}\\:[0-9a-fA-F]{2,2}\\:[0-9a-fA-F]{2,2}\\:[0-9a-fA-F]{2,2}$", false );
|
|
|
|
|
if ( !inp.tqcontains( exp ) )
|
|
|
|
|
if ( !inp.contains( exp ) )
|
|
|
|
|
valid = false;
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
|
|
|
@ -361,7 +361,7 @@ bool KMFCheckInput::checkMAC( TQString inp ) {
|
|
|
|
|
bool KMFCheckInput::checkChainName( TQString inp ) {
|
|
|
|
|
bool valid = TRUE;
|
|
|
|
|
TQRegExp exp( "^[a-zA-Z0-9_]{1,29}$", false );
|
|
|
|
|
if ( !inp.tqcontains( exp ) )
|
|
|
|
|
if ( !inp.contains( exp ) )
|
|
|
|
|
valid = false;
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
|
|
|
@ -369,7 +369,7 @@ bool KMFCheckInput::checkChainName( TQString inp ) {
|
|
|
|
|
bool KMFCheckInput::checkRuleName( TQString inp ) {
|
|
|
|
|
bool valid = TRUE;
|
|
|
|
|
TQRegExp exp( "^[a-zA-Z0-9_-]{1,20}$", false );
|
|
|
|
|
if ( !inp.tqcontains( exp ) )
|
|
|
|
|
if ( !inp.contains( exp ) )
|
|
|
|
|
valid = false;
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
|
|
|
|