@@ -16,10 +16,10 @@ bool AccessValidator::isAllowed(const long &remote_ip, const std::string &url, c
1616 if (accessList.empty ())
1717 return true ;
1818 bool result = false ;
19- for (std::vector <AccessRule>::iterator it = accessList.begin (); it != accessList.end (); ++it)
19+ for (std::list <AccessRule>::iterator it = accessList.begin (); it != accessList.end (); ++it)
2020 {
2121 AccessRule host = *it;
22- if (host.host_ip == remote_ip)
22+ if (( host.hostIp == remote_ip) || (host. isGeneralRule ) )
2323 {
2424 if (!host.allowed ) {
2525 for (std::vector<AccessCommandTable>::iterator it = host.commandList .begin (); it != host.commandList .end (); ++it) {
@@ -68,13 +68,20 @@ void AccessValidator::setWhiteList(FilePath &xmlPath)
6868 pugi::xml_attribute atr = xnode.attribute (" ip" );
6969
7070 AccessRule rule;
71- if (!convertIpString (atr.value (), &rule.host_ip )) {
72- std::string error_descr = " WhiteList: " + std::string (atr.value ()) + " is not a valid ip address" ;
73- GlobalLogger::Log (kWarningLogLevel , error_descr);
74- continue ;
71+ rule.isGeneralRule = false ;
72+ rule.allowed = true ;
73+
74+ if (!convertIpString (atr.value (), &rule.hostIp )) {
75+ if (!strcmp (atr.value (), " *" )) {
76+ rule.isGeneralRule = true ;
77+ } else {
78+ std::string error_descr = " WhiteList: " + std::string (atr.value ()) + " is not a valid ip address" ;
79+ GlobalLogger::Log (kWarningLogLevel , error_descr);
80+ continue ;
81+ }
82+
7583 }
7684
77- rule.allowed = true ;
7885 pugi::xpath_query query_nodes (" ./deny" );
7986 pugi::xpath_node_set deny_nodes = query_nodes.evaluate_node_set (xnode);
8087 if ( (NULL == query_nodes.result ().error ) &&
@@ -110,8 +117,8 @@ void AccessValidator::setWhiteList(FilePath &xmlPath)
110117 }
111118 }
112119 }
113-
114- accessList.push_back (rule);
120+ // if we have wildcard put this rule in the end
121+ rule. isGeneralRule ? accessList.push_back (rule) : accessList. push_front (rule);
115122 }
116123 } else {
117124 std::string error_descr = " WhiteList: Cant evaluate XPath to node set: " ;
0 commit comments