summaryrefslogtreecommitdiff
path: root/provider_base/files
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-03-17 13:15:51 -0700
committerelijah <elijah@riseup.net>2013-03-17 13:15:51 -0700
commitad62cfdad04c8f8ed9d6454f716c92e850ac53ba (patch)
treec4321297d2b60edc37ca10501340cb865d95bfa5 /provider_base/files
parent4ec32a1f773918b2c7a42c117fbad110c07df458 (diff)
added support for "limited" service levels (although vpn is not yet actually rate limited).
Diffstat (limited to 'provider_base/files')
-rw-r--r--provider_base/files/service-definitions/eip-service.json.erb40
-rw-r--r--provider_base/files/service-definitions/provider.json.erb2
2 files changed, 20 insertions, 22 deletions
diff --git a/provider_base/files/service-definitions/eip-service.json.erb b/provider_base/files/service-definitions/eip-service.json.erb
index 09b65bbb..ca42bef5 100644
--- a/provider_base/files/service-definitions/eip-service.json.erb
+++ b/provider_base/files/service-definitions/eip-service.json.erb
@@ -6,41 +6,39 @@
words
end
- def gateway_definition(node)
+ 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["cluster"] = underscore(node.openvpn.location)
+ 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
- clusters = {}
+ locations = {}
gateways = []
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
+ 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
- clusters[gateway["cluster"]] ||= {
- "name" => gateway["cluster"],
- "label" => {"en" => node.openvpn.location}
- }
end
- hsh["gateways"] = gateways
- hsh["clusters"] = clusters.values
+ hsh["gateways"] = gateways.compact
+ hsh["locations"] = locations
hsh["openvpn_configuration"] = {
"tls-cipher" => "DHE-RSA-AES128-SHA",
"auth" => "SHA1",
diff --git a/provider_base/files/service-definitions/provider.json.erb b/provider_base/files/service-definitions/provider.json.erb
index 2ca34548..54919898 100644
--- a/provider_base/files/service-definitions/provider.json.erb
+++ b/provider_base/files/service-definitions/provider.json.erb
@@ -4,7 +4,7 @@
# grab some fields from provider.json
hsh = global.provider.pick(
:languages, :description, :name,
- :enrollment_policy, :default_language, :domain
+ :enrollment_policy, :default_language, :domain, :service
)
# advertise services that are 'user services'