]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/auth/AclMaxUserIp.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / auth / AclMaxUserIp.cc
index 0a7072dd0427aa3aeaa6453078706fc6b1703efe..03560dd1a01705097b6b1383a35469a646b0309a 100644 (file)
@@ -1,8 +1,13 @@
 /*
- * DEBUG: section 28    Access Control
- * AUTHOR: Duane Wessels
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
+/* DEBUG: section 28    Access Control */
+
 #include "squid.h"
 #include "acl/FilledChecklist.h"
 #include "auth/Acl.h"
 #include "Parsing.h"
 #include "wordlist.h"
 
-ACL *
-ACLMaxUserIP::clone() const
-{
-    return new ACLMaxUserIP(*this);
-}
+ACLFlag ACLMaxUserIP::SupportedFlags[] = {ACL_F_STRICT, ACL_F_END};
 
-ACLMaxUserIP::ACLMaxUserIP (char const *theClass) : class_ (theClass), maximum(0)
+ACLMaxUserIP::ACLMaxUserIP(char const *theClass) :
+    ACL(SupportedFlags),
+    class_(theClass),
+    maximum(0)
 {}
 
-ACLMaxUserIP::ACLMaxUserIP (ACLMaxUserIP const & old) :class_ (old.class_), maximum (old.maximum), flags (old.flags)
-{}
+ACLMaxUserIP::ACLMaxUserIP(ACLMaxUserIP const &old) :
+    class_(old.class_),
+    maximum(old.maximum)
+{
+    flags = old.flags;
+}
 
 ACLMaxUserIP::~ACLMaxUserIP()
 {}
 
+ACL *
+ACLMaxUserIP::clone() const
+{
+    return new ACLMaxUserIP(*this);
+}
+
 char const *
 ACLMaxUserIP::typeString() const
 {
@@ -35,13 +49,13 @@ ACLMaxUserIP::typeString() const
 }
 
 bool
-ACLMaxUserIP::empty () const
+ACLMaxUserIP::empty() const
 {
     return false;
 }
 
 bool
-ACLMaxUserIP::valid () const
+ACLMaxUserIP::valid() const
 {
     return maximum > 0;
 }
@@ -61,15 +75,6 @@ ACLMaxUserIP::parse()
 
     debugs(28, 5, "aclParseUserMaxIP: First token is " << t);
 
-    if (strcmp("-s", t) == 0) {
-        debugs(28, 5, "aclParseUserMaxIP: Going strict");
-        flags.strict = true;
-        t = ConfigParser::strtokFile();
-    }
-
-    if (!t)
-        return;
-
     maximum = xatoi(t);
 
     debugs(28, 5, "aclParseUserMaxIP: Max IP address's " << maximum);
@@ -97,7 +102,7 @@ ACLMaxUserIP::match(Auth::UserRequest::Pointer auth_user_request, Ip::Address co
     debugs(28, DBG_IMPORTANT, "aclMatchUserMaxIP: user '" << auth_user_request->username() << "' tries to use too many IP addresses (max " << maximum << " allowed)!");
 
     /* this is a match */
-    if (flags.strict) {
+    if (flags.isSet(ACL_F_STRICT)) {
         /*
          * simply deny access - the user name is already associated with
          * the request
@@ -146,22 +151,15 @@ ACLMaxUserIP::match(ACLChecklist *cl)
     }
 }
 
-wordlist *
+SBufList
 ACLMaxUserIP::dump() const
 {
+    SBufList sl;
     if (!maximum)
-        return NULL;
-
-    wordlist *W = NULL;
-
-    if (flags.strict)
-        wordlistAdd(&W, "-s");
-
-    char buf[128];
-
-    snprintf(buf, sizeof(buf), "%lu", (unsigned long int) maximum);
-
-    wordlistAdd(&W, buf);
-
-    return W;
+        return sl;
+    SBuf s;
+    s.Printf("%d", maximum);
+    sl.push_back(s);
+    return sl;
 }
+