Merge remote-tracking branch 'origin/topic/johanna/config-framework-fixes'

* origin/topic/johanna/config-framework-fixes:
  Fix test that fails now that options are automatically redefable.
  Make options redef-able by default.
  Ascii formatter: do not complain about port text.
  Make parsing of booleans a little bit more lenient.
This commit is contained in:
Jon Siwek 2018-08-13 10:51:43 -05:00
commit 2d47586473
18 changed files with 131 additions and 30 deletions

View file

@ -227,9 +227,9 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
}
case TYPE_BOOL:
if ( s == "T" )
if ( s == "T" || s == "1" )
val->val.int_val = 1;
else if ( s == "F" )
else if ( s == "F" || s == "0" )
val->val.int_val = 0;
else
{
@ -261,8 +261,10 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
break;
case TYPE_PORT:
{
val->val.port_val.proto = TRANSPORT_UNKNOWN;
pos = s.find('/');
string numberpart;
if ( pos != std::string::npos && s.length() > pos + 1 )
{
auto proto = s.substr(pos+1);
@ -272,10 +274,21 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
val->val.port_val.proto = TRANSPORT_UDP;
else if ( strtolower(proto) == "icmp" )
val->val.port_val.proto = TRANSPORT_ICMP;
else if ( strtolower(proto) == "unknown" )
val->val.port_val.proto = TRANSPORT_UNKNOWN;
else
GetThread()->Warning(GetThread()->Fmt("Port '%s' contained unknown protocol '%s'", s.c_str(), proto.c_str()));
}
if ( pos != std::string::npos && pos > 0 )
{
numberpart = s.substr(0, pos);
start = numberpart.c_str();
}
val->val.port_val.port = strtoull(start, &end, 10);
if ( CheckNumberError(start, end) )
goto parse_error;
}
break;
case TYPE_SUBNET: