Class: Construqt::Flavour::Ubuntu::EtcConntrackdConntrackd

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb

Defined Under Namespace

Classes: Other

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ EtcConntrackdConntrackd

Returns a new instance of EtcConntrackdConntrackd.



7
8
9
10
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 7

def initialize(result)
  @result = result
  @others = []
end

Instance Method Details

#add(ifname, my_ip, other_ip) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 16

def add(ifname, my_ip, other_ip)
  other = Other.new
  other.ifname = ifname
  other.my_ip = my_ip
  other.other_ip = other_ip
  @others << other
end

#commitObject



24
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
61
62
63
64
65
66
67
68
69
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 24

def commit
  return '' if @others.empty?
  out = [<<CONNTRACKD]
General {
	HashSize 32768
	HashLimit 524288
	Syslog on
	LockFile /var/lock/conntrackd.lock
	UNIX {
		Path /var/run/conntrackd.sock
		Backlog 20
	}
	SocketBufferSize 262142
	SocketBufferSizeMaxGrown 655355
	Filter {
		Protocol Accept {
			TCP
		}
		Address Ignore {
			IPv4_address 127.0.0.1 # loopback
		}
	}
}
Sync {
	Mode FTFW {
   	DisableExternalCache Off
		CommitTimeout 1800
		PurgeTimeout 5
	}
CONNTRACKD
  @others.each do |other|
    out.push(<<OTHER)
  UDP Default {
  IPv4_address #{other.my_ip}
  IPv4_Destination_Address #{other.other_ip}
  Port 3780
  Interface #{other.ifname}
  SndSocketBuffer 24985600
  RcvSocketBuffer 24985600
  Checksum on
  }
OTHER
  end
  out.push("}")
  out.join("\n")
end