update bird configuration in openvpn script

This commit is contained in:
Jörg Thalheim 2015-01-16 18:47:28 +01:00
parent 50636135e4
commit bb224c163a
1 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env ruby
require_relative "utils"
require_relative "bird"
require "netaddr"
require "optparse"
require "set"
@ -8,12 +9,12 @@ class OpenvpnRegistry < Registry
def initialize
super
@host = data["host"]
@v4_tunnel_ip = @host["v4_tunnel"]
@v4_tunnel_ip = @host["v4_tunnel"] or die("v4_tunnel not set for host")
@start_port = @host["start_port"].to_i
@end_port = @host["end_port"].to_i
@openvpn_path = Pathname.new(File.expand_path("../../openvpn", __FILE__))
die("v4_tunnel not set for host") unless @v4_tunnel_ip
end
def add_peer(name, peer)
@ -71,9 +72,9 @@ class OpenvpnRegistry < Registry
params["lport"] = peer["rport"]
end
params["remote"] = if peer["proto"] == "udp6"
data["host"]["v6_public"]
@host["v6_public"]
else
data["host"]["v4_public"]
@host["v4_public"]
end
params
end
@ -138,6 +139,7 @@ class Application
@registry.save
@registry.update_configurations
BgpRegistry.new.update_configs
end
def add_command(args)
options = {}
@ -176,6 +178,7 @@ class Application
options["proto"] = proto
@registry.add_peer(name, options)
end
def remove_command(args)
parser = OptionParser.new do |opts|
opts.banner = "Usage: openvpn remove NAME"