Class: Tortard
- Inherits:
-
Object
show all
- Defined in:
- lib/tortard/utils.rb,
lib/tortard.rb,
lib/tortard/map.rb,
lib/tortard/bridge.rb,
lib/tortard/address.rb,
lib/tortard/bridge/client.rb,
lib/tortard/bridge/connection.rb
Overview
–; end
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyleft meh. [meh.doesntexist.org | [email protected]]
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
You just DO WHAT THE FUCK YOU WANT TO.
++
Defined Under Namespace
Classes: Address, Bridge, Map
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Tortard.
27
28
29
|
# File 'lib/tortard.rb', line 27
def initialize
@bridges = []
end
|
Class Method Details
.load(path) ⇒ Object
21
22
23
24
25
|
# File 'lib/tortard.rb', line 21
def self.load (path)
new.tap {|t|
t.load(path)
}
end
|
.log(what) ⇒ Object
14
15
16
|
# File 'lib/tortard/utils.rb', line 14
def self.log (what)
puts "[#{Time.now}] #{what}"
end
|
Instance Method Details
#bridge(from, to) ⇒ Object
Also known as:
map
69
70
71
72
73
74
75
|
# File 'lib/tortard.rb', line 69
def bridge (from, to)
if from.is_a?(Fixnum)
from = "#{@host}:#{from}"
end
@bridges << Bridge.new(@proxy || Address.parse('localhost:9050'), Address.parse(from), Address.parse(to), @ssl)
end
|
#host(host) ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/tortard.rb', line 61
def host (host)
@host, tmp = host, @host
yield
ensure
@host = tmp
end
|
#load(path) ⇒ Object
31
32
33
34
35
|
# File 'lib/tortard.rb', line 31
def load (path)
path = File.expand_path(path)
instance_eval File.read(path), path
end
|
#proxy(host, port = nil) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/tortard.rb', line 45
def proxy (host, port = nil)
@proxy, tmp = port ? Address.new(host, port) : Address.parse(host)
yield
ensure
@proxy = tmp
end
|
#ssl(what) ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/tortard.rb', line 53
def ssl (what)
@ssl, tmp = what, @ssl
yield
ensure
@ssl = tmp
end
|
#start ⇒ Object
37
38
39
|
# File 'lib/tortard.rb', line 37
def start
@bridges.each(&:start)
end
|
#stop ⇒ Object
41
42
43
|
# File 'lib/tortard.rb', line 41
def stop
@bridges.each(&:stop)
end
|