Class: Kawana::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kawana/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(addr, port = 9291) ⇒ Client

addr is a string remote address, e.g. 'localhost' or '127.0.0.1'


10
11
12
13
# File 'lib/kawana/client.rb', line 10

def initialize(addr, port = 9291)
  @addr = addr
  @port = port
end

Instance Method Details

#blacklist(ip) ⇒ Object

Blacklist ip in the Kawana server. ip must be of type IPAddr, e.g. IPAddr.new('127.0.0.1') Raises an exception if an error occurs, otherwise returns nil if successful.


38
39
40
# File 'lib/kawana/client.rb', line 38

def blacklist(ip)
  black_white_cmd(ip, 3)
end

#unblacklist(ip) ⇒ Object

Un-blacklist ip in the Kawana server. ip must be of type IPAddr, e.g. IPAddr.new('127.0.0.1') Raises an exception if an error occurs, otherwise returns nil if successful.


47
48
49
# File 'lib/kawana/client.rb', line 47

def unblacklist(ip)
  black_white_cmd(ip, 4)
end

#unwhitelist(ip) ⇒ Object

Un-whitelist ip in the Kawana server. ip must be of type IPAddr, e.g. IPAddr.new('127.0.0.1') Raises an exception if an error occurs, otherwise returns nil if successful.


29
30
31
# File 'lib/kawana/client.rb', line 29

def unwhitelist(ip)
  black_white_cmd(ip, 2)
end

#whitelist(ip) ⇒ Object

Whitelist ip in the Kawana server. ip must be of type IPAddr, e.g. IPAddr.new('127.0.0.1') Raises an exception if an error occurs, otherwise returns nil if successful.


20
21
22
# File 'lib/kawana/client.rb', line 20

def whitelist(ip)
  black_white_cmd(ip, 1)
end