-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetblocks.rb
More file actions
executable file
·36 lines (29 loc) · 799 Bytes
/
setblocks.rb
File metadata and controls
executable file
·36 lines (29 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/ruby
#
# construct the blocklist in memcache for testing
#
# for use with memcache-client 1.5.x
require 'rubygems'
require 'memcache'
@servers = [ 'localhost:11211' ]
@options = {
:prefix_key => '',
:hash => :default,
:distribution => :modula
}
@cache = MemCache.new(@servers,@options)
#
# per robey: marshall must be set to false otherwise we'll feed marshalled data to apache
# and apache doesn't work with marshalled data.
#
@cache.set("mb:b:1",'127.0.0.0-127.0.0.99',0,true)
@cache.set("mb:b:2",'127.0.0.0/24',0,true)
@cache.set("mb:b:3",'127.0.0.1',0,true)
# ipv6
@cache.set("mb:b:4",'::1',0,true)
# whitelisting - takes precendence
# @cache.set("mb:w:4",'::1',0,true)
puts "blocks set:"
for x in 1..4
puts "#{x} = " + @cache.get("mb:b:#{x}",true)
end