Class: Ji2p::Control::TunnelManager

Inherits:
Object
  • Object
show all
Defined in:
lib/ji2p/control/tunnel_manager.rb

Constant Summary collapse

@@tunnelctrl =
nil

Class Method Summary collapse

Class Method Details

.contextObject



13
14
15
# File 'lib/ji2p/control/tunnel_manager.rb', line 13

def self.context
  I2PAppContext.getGlobalContext
end

.createNewConfig(hash = Hash.new) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ji2p/control/tunnel_manager.rb', line 25

def self.createNewConfig hash = Hash.new
  props = java.util.Properties.new
  dfl = {
    'option.maxPosts'=>'3',
    'option.i2cp.destination.sigType'=>'EdDSA_SHA512_Ed25519',
    'option.i2p.streaming.limitAction'=>'http',
    'description'=>'jruby-tunnel',
    'interface'=>'127.0.0.1',
    'type'=>'httpserver',
    'option.outbound.quantity'=>'4',
    'option.inbound.quantity'=>'4',
    'option.postBanTime'=>'1800',
    'targetPort'=>'8000',
    'option.postTotalBanTime'=>'600',
    'i2cpHost'=>'127.0.0.1',
    'option.postCheckTime'=>'300',
    'option.i2p.streaming.maxConnsPerHour'=>'40',
    'option.shouldBundleReplyInfo'=>'false',
    'option.outbound.length'=>'1',
    'targetHost'=>'127.0.0.1',
    'option.inbound.length'=>'1',
    'i2cpPort'=>'7654',
    'persistentClientKey'=>'true',
    'option.maxTotalPosts'=>'10',
    'option.i2p.streaming.maxConnsPerDay'=>'100',
    'option.i2p.streaming.maxTotalConnsPerMinute'=>'25',
    'option.i2p.streaming.maxConnsPerMinute'=>'15',
    'name'=>'jruby-tunnel',
    'option.i2p.streaming.maxConcurrentStreams'=>'20',
    'privKeyFile'=>'kake.dat',
    'listenPort'=>'8000'
  }
  merged = dfl.merge(hash)
  merged.keys.each { |k| props[k.to_s] = merged[k].to_s }
  props
end

.startTunnelWithConfig(conf, createPrivKey = false) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ji2p/control/tunnel_manager.rb', line 17

def self.startTunnelWithConfig conf, createPrivKey = false
  unless ['client','httpclient','server','httpserver','sockstunnel'].include? conf['type']
    raise ArgumentError, 'Invalid i2p tunnel type!', caller
  end
  tctrl = TunnelController.new conf, '', createPrivKey
  TunnelCtrl.new tctrl, conf
end