X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fipaddressacl.cpp;h=64ca979081ec090e08a2065d920d175f9fc27078;hb=76805933f794915a72b7f0a21b12af6654759f4f;hp=0516c1d67c422f843786cfea8b5186f0a52a61b3;hpb=047cea32f848d605c549ec123c12c1c400dd7ec1;p=fms.git diff --git a/src/ipaddressacl.cpp b/src/ipaddressacl.cpp index 0516c1d..64ca979 100644 --- a/src/ipaddressacl.cpp +++ b/src/ipaddressacl.cpp @@ -64,9 +64,11 @@ const bool IPAddressACL::Add(const std::string &aclentry) const std::string IPAddressACL::CreateMask(const int maskbits) { int bitsleft=maskbits; - int parts[4]={255,255,255,255}; + //int parts[4]={255,255,255,255}; + int parts[4]={0,0,0,0}; std::ostringstream ipstr; + /* for(int i=3; i>=0; i--) { for(int b=0; b<8 && bitsleft>0; b++) @@ -75,6 +77,15 @@ const std::string IPAddressACL::CreateMask(const int maskbits) bitsleft--; } } + */ + for(int i=0; i<4; i++) + { + for(int b=7; b>=0 && bitsleft>0; b--) + { + parts[i]+=pow((float)2,b); + bitsleft--; + } + } ipstr << parts[0] << "." << parts[1] << "." << parts[2] << "." << parts[3]; @@ -86,7 +97,7 @@ const bool IPAddressACL::IsAllowed(const Poco::Net::IPAddress &addr) bool found=false; bool rval=m_allowbydefault; - for(std::vector::iterator i=m_entries.begin(); i!=m_entries.end() && found==false; i++) + for(std::vector::reverse_iterator i=m_entries.rbegin(); i!=m_entries.rend() && found==false; i++) { Poco::Net::IPAddress ip1=addr; Poco::Net::IPAddress ip2=(*i).m_addr;