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