summaryrefslogtreecommitdiff
path: root/provider_base/files/service-definitions/v1
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2013-04-26 12:30:46 +0200
committervarac <varacanero@zeromail.org>2013-04-26 12:30:46 +0200
commit334e4242a55f36c8ba3bbaa8b5e1c44664402450 (patch)
tree80c0b8734b434c654eab7c86c89d009f11535c87 /provider_base/files/service-definitions/v1
parent1c61472a0c0c14351993574f2673a6a3a3c75371 (diff)
parent27cb083212a74c94ed069ce9ef3dfc7593e85524 (diff)
Merge branch 'develop' of ssh://code.leap.se/leap_platform into develop
Diffstat (limited to 'provider_base/files/service-definitions/v1')
-rw-r--r--provider_base/files/service-definitions/v1/eip-service.json.erb48
1 files changed, 48 insertions, 0 deletions
diff --git a/provider_base/files/service-definitions/v1/eip-service.json.erb b/provider_base/files/service-definitions/v1/eip-service.json.erb
new file mode 100644
index 00000000..ca42bef5
--- /dev/null
+++ b/provider_base/files/service-definitions/v1/eip-service.json.erb
@@ -0,0 +1,48 @@
+<%=
+ def underscore(words)
+ words = words.to_s.dup
+ words.downcase!
+ words.gsub! /[^a-z]/, '_'
+ words
+ end
+
+ def add_gateway(node, locations, options={})
+ return nil if options[:ip] == 'REQUIRED'
+ gateway = {}
+ gateway["capabilities"] = node.openvpn.pick(:ports, :protocols, :user_ips, :adblock, :filter_dns)
+ gateway["capabilities"]["transport"] = ["openvpn"]
+ gateway["host"] = node.domain.full
+ gateway["ip_address"] = options[:ip]
+ gateway["capabilities"]["limited"] = options[:limited]
+ if node.location
+ location_name = underscore(node.location.name)
+ gateway["location"] = location_name
+ locations[location_name] ||= node.location
+ end
+ gateway
+ end
+
+ hsh = {}
+ hsh["serial"] = 1
+ hsh["version"] = 1
+ locations = {}
+ gateways = []
+ nodes_like_me[:services => 'openvpn'].each_node do |node|
+ if node.openvpn.allow_limited && node.openvpn.allow_unlimited
+ gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => false)
+ gateways << add_gateway(node, locations, :ip => node.openvpn.second_gateway_address, :limited => true)
+ elsif node.openvpn.allow_unlimited
+ gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => false)
+ elsif node.openvpn.allow_limited
+ gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => true)
+ end
+ end
+ hsh["gateways"] = gateways.compact
+ hsh["locations"] = locations
+ hsh["openvpn_configuration"] = {
+ "tls-cipher" => "DHE-RSA-AES128-SHA",
+ "auth" => "SHA1",
+ "cipher" => "AES-128-CBC"
+ }
+ generate_json hsh
+%> \ No newline at end of file