summaryrefslogtreecommitdiff
path: root/provider_base/files
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-02-27 23:46:58 -0800
committerelijah <elijah@riseup.net>2013-02-27 23:46:58 -0800
commitffb88e54c5e4e30fa61ea1009f3eee62f98ab17c (patch)
tree0d28846e9de15d7580b3b232aac16e2f4e8cb6e4 /provider_base/files
parent5f8b63892ec9d08471a43ac642ed8f291d27c4f5 (diff)
openvpn -- added support for optional "free" rate-limited service via special client certificates with the FREE prefix in the common name.
Diffstat (limited to 'provider_base/files')
-rw-r--r--provider_base/files/service-definitions/eip-service.json.erb33
1 files changed, 23 insertions, 10 deletions
diff --git a/provider_base/files/service-definitions/eip-service.json.erb b/provider_base/files/service-definitions/eip-service.json.erb
index 8dc7211d..09b65bbb 100644
--- a/provider_base/files/service-definitions/eip-service.json.erb
+++ b/provider_base/files/service-definitions/eip-service.json.erb
@@ -6,21 +6,34 @@
words
end
+ def gateway_definition(node)
+ gateway = {}
+ gateway["capabilities"] = node.openvpn.pick(:ports, :protocols, :user_ips, :adblock, :filter_dns)
+ gateway["capabilities"]["transport"] = ["openvpn"]
+ gateway["host"] = node.domain.full
+ gateway["cluster"] = underscore(node.openvpn.location)
+ gateway
+ end
+
hsh = {}
hsh["serial"] = 1
hsh["version"] = 1
clusters = {}
gateways = []
- global.services['openvpn'].node_list.each_node do |node|
- next if node.vagrant?
- gateway = {}
- gateway["capabilities"] = node.openvpn.pick(
- :ports, :protocols, :user_ips, :adblock, :filter_dns)
- gateway["capabilities"]["transport"] = ["openvpn"]
- gateway["ip_address"] = node.openvpn.gateway_address
- gateway["host"] = node.domain.full
- gateway["cluster"] = underscore(node.openvpn.location)
- gateways << gateway
+ nodes_like_me[:services => 'openvpn'].each_node do |node|
+ if node.openvpn.gateway_address
+ gateway = gateway_definition(node)
+ gateway["ip_address"] = node.openvpn.gateway_address
+ gateway["capabilities"]["free"] = false
+ gateways << gateway
+ end
+ if node.openvpn.free_gateway_address && node.openvpn.free_gateway_address != "REQUIRED"
+ gateway = gateway_definition(node)
+ gateway["ip_address"] = node.openvpn.free_gateway_address
+ gateway["capabilities"]["free"] = true
+ gateway["capabilities"]["rate_limit"] = node.openvpn.free_rate_limit
+ gateways << gateway
+ end
clusters[gateway["cluster"]] ||= {
"name" => gateway["cluster"],
"label" => {"en" => node.openvpn.location}