]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/networking/resources/firewall_rule.rb
Enable rate limits
[chef.git] / cookbooks / networking / resources / firewall_rule.rb
index 665c0cb84ee9d279f3e65241e12b7777045e57dd..218a6b5f482a7de4bf3f2ca851067e6702cfaf4a 100644 (file)
@@ -141,15 +141,15 @@ action_class do
       rule << "add @#{set} { #{ip} saddr ct count #{new_resource.connection_limit} }"
     end
 
-    if new_resource.rate_limit =~ %r{^s:(\d+)/sec:(\d+)$}
-    #   set = "#{new_resource.rule}-#{ip}"
-      rate = Regexp.last_match(1)
-      burst = Regexp.last_match(2)
-    #
-      node.default[:networking][:firewall][:sets] << set
-    #
-      rule << "add @#{set} { #{ip} saddr limit rate #{rate}/second burst #{burst} packets }"
-    end
+    if new_resource.rate_limit =~ %r{^s:(\d+)/sec:(\d+)$}
+      set = "ratelimit-#{new_resource.rule}-#{ip}"
+      rate = Regexp.last_match(1)
+      burst = Regexp.last_match(2)
+
+      node.default[:networking][:firewall][:sets] << set
+
+      rule << "add @#{set} { #{ip} saddr limit rate #{rate}/second burst #{burst} packets }"
+    end
 
     rule << case action
             when :accept then "accept"