Browse Source

- remove openvpn-setup plugin

master
vanhofen 8 years ago
parent
commit
874b9712e0
  1. 47
      archive-sources/openvpn-setup/etc/init.d/ovpn
  2. 5
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup.cfg
  3. 66
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup.lua
  4. 58
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/deutsch.lua
  5. 58
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/english.lua
  6. 379
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/functions.lua
  7. 24
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/init.lua
  8. 141
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/main_menu.lua
  9. 67
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/setup_menu_client.lua
  10. 69
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/setup_menu_server.lua
  11. 60
      archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/variables.lua

47
archive-sources/openvpn-setup/etc/init.d/ovpn

@ -1,47 +0,0 @@
#!/bin/sh
. /etc/init.d/globals
ip_forwarding() {
v=${1:-0}
echo ${v} > /proc/sys/net/ipv4/ip_forward
}
sbin_base=/sbin
if [ -x /var/sbin/openvpn ]; then
sbin_base=/var/sbin
fi
case "$1" in
start)
if [ -e /var/etc/.openvpn ]; then
read mode < /var/etc/.openvpn
mode=${mode:-client}
if [ ! -e /var/etc/openvpn/${mode}.conf ]; then
SHOWINFO "/var/etc/openvpn/${mode}.conf not found."
exit 1
fi
ip_forwarding 1
${sbin_base}/openvpn \
--config /var/etc/openvpn/${mode}.conf \
--log /tmp/openvpn_${mode}.log \
--daemon \
--script-security 2 \
--up /var/etc/openvpn/up.sh
fi
;;
stop)
killall -TERM openvpn
sleep 3
ip_forwarding 0
;;
restart)
$0 stop
$0 start
;;
*)
echo "[${BASENAME}] Usage: $0 {start|restart|stop}"
;;
esac

5
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup.cfg

@ -1,5 +0,0 @@
type=4
name=OpenVPN setup
desc=OpenVPN settings and startup options
name.deutsch=OpenVPN Einstellungen
desc.deutsch=OpenVPN Einstellungen und Start-Optionen

66
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup.lua

@ -1,66 +0,0 @@
--[[
OpenVPN settings and startup options
Copyright (C) 2017 Sven Hoefer <svenhoefer@svenhoefer.com>
Copyright (C) 2015 defans <defans@bluepeercrew.us>
License: WTFPLv2
]]
-- Plugin Version
version = "v0.11"
LUA_API_VERSION_MAJOR = 1
LUA_API_VERSION_MINOR = 30
n = neutrino()
neutrino_conf = configfile.new()
neutrino_conf:loadConfig("/var/tuxbox/config/neutrino.conf")
-- if Version Lua API ok
local v = n:checkVersion(LUA_API_VERSION_MAJOR, LUA_API_VERSION_MINOR)
if (v == 0) then do
return
end
end
-- define global paths
helpers = require "n_helpers"
pluginScriptPath = helpers.scriptPath() .. "/" .. helpers.scriptBase();
-- include lua files
dofile(pluginScriptPath .. "/variables.lua");
dofile(pluginScriptPath .. "/init.lua");
dofile(pluginScriptPath .. "/functions.lua");
dofile(pluginScriptPath .. "/setup_menu_server.lua");
dofile(pluginScriptPath .. "/setup_menu_client.lua");
dofile(pluginScriptPath .. "/main_menu.lua");
-- set locale
locale = {}
local lang_default = "english"
local lang = neutrino_conf:getString("language", lang_default)
if lang == nil or (helpers.fileExist(pluginScriptPath .. "/" .. lang .. ".lua") == false) then
lang = lang_default
end
dofile(pluginScriptPath .. "/" .. lang .. ".lua");
if not helpers.fileExist(sbin_base .. "/openvpn") then
local h = hintbox.new{caption=locale.caption, text=locale.daemon_not_found}
h:paint()
repeat
msg, data = n:GetInput(500)
until msg == RC.ok or msg == RC.home
h:hide()
return
end
-- run init
init()
-- run mainmenu
mainmenu()
if restart_on_exit then
action(cmd.init_d.restart, locale.daemon)
end

58
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/deutsch.lua

@ -1,58 +0,0 @@
locale.caption = "OpenVPN Einstellungen"
--locale.yes = "ja"
--locale.no = "nein"
locale.off = "aus"
locale.server = "Server"
locale.client = "Client"
locale.ext = "Extern"
locale.startup = "Startmodus"
locale.startup_hint = "Definieren Sie, in welchem Modus OpenVPN gestartet werden soll"
locale.daemon = "Dienstprogramm"
locale.daemon_not_found = locale.daemon .. " nicht gefunden. Abbruch."
locale.daemon_start = "Starten"
locale.daemon_start_hint = "Startet das OpenVPN-Dienstprogramm (neu)"
locale.daemon_stop = "Stoppen"
locale.daemon_stop_hint = "Stoppt das OpenVPN-Dienstprogramm"
locale.secret = "Schlüsseldatei"
locale.secret_new = "Erstellen"
locale.secret_new_hint = "Erzeugt eine neue Schlüsseldatei"
locale.secret_new_ask = "Soll eine neue OpenVPN-Schlüsseldatei erstellt werden?"
locale.secret_push = "Weitergeben"
locale.secret_push_hint = "Kopiert den eigenen Schlüssel zum Transport auf einen Datenträger"
locale.secret_pull = "Einlesen"
locale.secret_pull_hint = "Liest den Schlüssel einer Gegenstelle ein"
locale.setup = "Konfiguration"
locale.setup_proto = "Protokoll"
locale.setup_proto_hint = "Stellen Sie das Verbindungsprotokoll ein"
locale.setup_ifconfig = "Interfaces"
locale.setup_ifconfig_hint = "Stellen Sie die Interfaces ein"
locale.setup_remote = "Entfernte Domain"
locale.setup_remote_hint = "Definieren Sie die entfernte Domain"
locale.setup_port = "Port"
locale.setup_port_hint = "Definieren Sie die den verwendeten Port"
locale.setup_server_hint = "Konfigurieren Sie OpenVPN für den Server-Modus"
locale.setup_client_hint = "Konfigurieren Sie OpenVPN für den Client-Modus"
locale.setup_keepalive = "Überwachung"
locale.setup_keepalive_hint = "Überwachungszeit in Sekunden, online offline."
locale.setup_lzo = "Kompression"
locale.setup_lzo_hint = "Schaltet die Kompression an oder aus. Standard ist adaptiv."
locale.setup_secret = "Schlüsseldatei"
locale.setup_secret_hint = "Schlüsseldatei auswählen"
locale.routing = "Routing" --TODO
locale.routing_hint = "Route eintragen die benutzt werden soll oder leer lassen" --TODO
locale.routing_help = "Beispiel: " --TODO
locale.routing_help2 = "ip route add 192.168.1.0/24 via 10.8.0.2" --TODO
locale.logging = "Protokollierung"
locale.logging_hint = "Protokolldatei anzeigen"
locale.extern = "Externe Konfiguration"
locale.extern_import = "Importieren"
locale.extern_hint = "Externe Konfiguration importieren"
locale.wait = "Bitte warten ..."

58
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/english.lua

@ -1,58 +0,0 @@
locale.caption = "OpenVPN setup"
--locale.yes = "yes"
--locale.no = "no"
locale.off = "off"
locale.server = "Server"
locale.client = "Client"
locale.ext = "Extern"
locale.startup = "Startup mode"
locale.startup_hint = "Define the OpenVPN startup mode"
locale.daemon = "Daemon"
locale.daemon_not_found = locale.daemon .. " not found. Aborting."
locale.daemon_start = "Start"
locale.daemon_start_hint = "Start the OpenVPN daemon"
locale.daemon_stop = "Stop"
locale.daemon_stop_hint = "Stop the OpenVPN daemon"
locale.secret = "Secret file"
locale.secret_new = "Create"
locale.secret_new_hint = "Create a new secretfile"
locale.secret_new_ask = "Create a new OpenVPN secretfile?"
locale.secret_push = "Pass along"
locale.secret_push_hint = "" --TODO
locale.secret_pull = "Read in"
locale.secret_pull_hint = "" --TODO
locale.setup = "Configuration"
locale.setup_proto = "Protocol"
locale.setup_proto_hint = "Configure protocol for connections"
locale.setup_ifconfig = "Interfaces"
locale.setup_ifconfig_hint = "Configure the interfaces"
locale.setup_remote = "Remote domain"
locale.setup_remote_hint = "Configure your remote domain"
locale.setup_port = "Port"
locale.setup_port_hint = "Configure your remote port"
locale.setup_server_hint = "Configure OpenVPN for server mode"
locale.setup_client_hint = "Configure OpenVPN for client mode"
locale.setup_keepalive = "Keepalive"
locale.setup_keepalive_hint = "Ping every X seconds, assume that remote peer is down if no ping received during a Y second time period."
locale.setup_lzo = "compression"
locale.setup_lzo_hint = "Turns compression on or off, default is adaptive"
locale.setup_secret = "Secret file"
locale.setup_secret_hint = "Choose a secret file"
locale.routing = "Routing" --TODO
locale.routing_hint = "Route eintragen die benutzt werden soll oder leer lassen." --TODO
locale.routing_help = "Beispiel:" --TODO
locale.routing_help2 = "ip route add 192.168.1.0/24 via 10.8.0.2" --TODO
locale.logging = "Logging"
locale.logging_hint = "View log file"
locale.extern = "External Configuration"
locale.extern_import = "Import"
locale.extern_hint = "Import External configuration"
locale.wait = "Please wait ..."

379
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/functions.lua

@ -1,379 +0,0 @@
function startup()
startup_options={
locale.off,
locale.server,
locale.client,
locale.ext
}
end
function split(s)
-- split s at first space
if not s then
return nil
end
local space = s:find("%s") or (#s + 1)
return s:sub(1, space-1), s:sub(space+1)
end
function get_filename(s)
-- split s at last /
if not s then
return nil
end
local slash = s:find("/[^/]*$")
return s:sub(slash+1)
end
function get_pathname(s)
-- split s at last /
if not s then
return nil
end
local slash = s:find("/[^/]*$")
return s:sub(1, slash-1)
end
function load(config, T)
if not helpers.fileExist(config) then
save(config, T)
end
local f = io.open(config, "r")
if f then
for line in f:lines() do
local key, val = split(line:match("^([^=#]+)([^\n]*)"))
if key then
if val == nil then
val = ""
end
T[helpers.trim(key)] = helpers.trim(val)
end
end
f:close()
end
end
function save(config, T)
restart_on_exit = true
local f = io.open(config, "w")
if f then
f:write("# Created by OpenVPN-Setup - Don't change this file manually.\n")
for k, v in pairs(T) do
if (k == "comp-lzo" and v == "n/a") then
goto continue
end
f:write(k .. " " .. v .. "\n")
::continue::
end
f:close()
end
end
function key_home(a)
return MENU_RETURN.EXIT
end
function key_setup(a)
return MENU_RETURN.EXIT_ALL
end
function get_upscript()
local f = nil
local cmd = "#!/bin/sh\n"
route = "" -- "ip route add 192.168.1.0/24 via 10.8.0.2"
if not helpers.fileExist(scriptup) then
f = io.open(scriptup, "w")
f:write(string.lower(cmd))
f:close()
os.execute("chmod +x " .. scriptup)
return
end
local f = io.open(scriptup, "r")
if f then
for line in f:lines() do
if string.find(line, "#") then
goto continue
elseif string.find(line, scriptup_cmd) then
route = line
f:close()
break
end
::continue::
end
end
end
function set_upscript(id, value)
local cmd = "#!/bin/sh\n"
if value ~= "" and value ~= " " then
cmd = cmd .. " " .. value .. "\n"
end
--print(cmd)
local f = io.open(scriptup, "w")
if f then
f:write(string.lower(cmd))
f:close()
end
end
function get_startup()
local f = io.open(flagfile, "r")
if f then
local c = f:read()
f:close()
if c == nil then
c = ""
end
for k, v in ipairs(startup_options) do
if string.lower(v) == c then
return v
end
end
end
return locale.off
end
function set_startup(id, value)
activate_items(value)
restart_on_exit = true
if value == locale.off then
os.remove(flagfile)
return
end
local f = io.open(flagfile, "w")
if f then
f:write(string.lower(value))
f:close()
end
return
end
function activate_items(item)
setup_server_active = false
setup_client_active = false
setup_server_client_active = false
if item == locale.server then
setup_server_active = true
elseif item == locale.client then
setup_client_active = true
end
if item ~= locale.off then
setup_server_client_active = true
end
if m then
m:setActive{item=m_ss, activ=setup_server_active}
m:setActive{item=m_sc, activ=setup_client_active}
m:setActive{item=m_sr, activ=setup_server_client_active}
end
end
function set_string_server(k, v)
S[k] = v
end
function set_string_client(k, v)
C[k] = v
end
function action(cmd, caption)
local caption = caption or locale.caption
local h = hintbox.new{caption=caption, text=locale.wait}
h:paint()
print("action: " .. cmd)
os.execute(cmd)
local i = 0
repeat
i = i + 1
msg, data = n:GetInput(500)
until msg == RC.ok or msg == RC.home or i == 2
h:hide()
end
function secret_file_create(cmd, firstrun)
--print(firstrun)
if (((not helpers.fileExist(secret_file)) and (firstrun == true)) or ((firstrun == nil) and helpers.fileExist(secret_file))) then
local ret = messagebox.exec{ title=locale.secret, text=locale.secret_new_ask , buttons={ "yes", "no" } };
if ret == "yes" then
action(cmd, locale.secret)
end
end
end
function secret_file_push(k, v)
if not v then
v = k
end
secret_dest = v
action("cp -f " .. secret_file .. " " .. secret_dest, locale.secret_push)
if (not helpers.fileExist(secret_dest .. secret_file)) then
--TODO hintbox Fehler
else
--TODO hintbox Erfolg
end
end
function secret_file_pull(k, v)
if not v then
v = k
end
action("cp -f " .. v .. " ".. secret_file, locale.secret_pull)
if (not helpers.fileExist(secret_file)) then
--TODO hintbox Fehler
else
--TODO hintbox Erfolg
end
end
function logging()
m:hide()
local fact = 0.8 --80%
local scr_x = SCREEN['X_RES']
local scr_y = SCREEN['Y_RES']
local dx = scr_x*fact
local x = (scr_x-dx)/2
local dy = scr_y*fact
local y = (scr_y-dy)/2
local offset = n:scale2Res(10)
local scroll = true
w = cwindow.new{x=x, y=y, dx=dx, dy=dy, title=locale.logging, icon="hint_network", has_shadow=true, show_footer=false }
local tmp_h = w:headerHeight()
local log=readlog()
ct = ctext.new{parent=w, x=offset, y=offset, dx=dx-offset, dy=dy-tmp_h-offset, text=log, mode = "ALIGN_TOP | ALIGN_SCROLL"}
ct:scroll{dir="down", pages=-1}
w:paint{do_save_bg=true};
local i = 0
repeat
i = i + 1
msg, data = n:GetInput(500)
if i==20 then
log=readlog()
ct:setText{text=log}
if scroll == true then
ct:scroll{dir="down", pages=-1}
end
ct:paint()
i = 0
end
if (msg == RC['up'] or msg == RC['page_up']) then
scroll = false
ct:scroll{dir="up"}
elseif (msg == RC['down'] or msg == RC['page_down']) then
ct:scroll{dir="down"}
scroll = true
end
until msg == RC.ok or msg == RC.home
w:hide{no_restore=true}
end
function readlog()
local ret="no log available"
local logfile
local mode=string.lower(get_startup())
if (mode == "server" or mode == "client" or mode == "extern") then
logfile="/tmp/openvpn_" .. mode.. ".log"
local f = io.open(logfile, "r")
if f then
ret = f:read("*a")
f:close()
end
end
return ret
end
function search_conf(directory)
if not directory then
return nil
end
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
if filename:find(".conf") or filename:find(".ovpn") then
return filename
end
end
end
function write_path(s)
if not helpers.fileExist(s) then
print("file not found")
end
local cd = "cd%s"
local dir = get_pathname(s)
print(dir)
local f = io.open(s, "r+")
if f then
for line in f:lines() do
print(line)
if line:find(cd) then
print("FOUND")
return
end
end
f:write("\n", "cd " .. dir, "\n")
f:close()
end
end
function get_extern(k, v)
if not v then
v = k
end
if not v then
return
end
local E = {"*.crt", "*.key", "*.conf", "*.ovpn"}
local dir = get_filename(v)
local destdir = conf_base .. "/" .. dir
os.execute("mkdir -p " .. destdir)
for i, ext in pairs(E) do
os.execute("cp -pf " .. v .. "/" .. ext .. " " .. destdir)
end
local cfg = search_conf(destdir)
if not cfg then
os.execute("rm -rf " .. destdir)
print("config not found")
return
end
local destpath = destdir .. "/" .. cfg
os.execute("ln -s " .. destpath .. " " .. conf_base .. "/extern.conf")
write_path(destpath)
end

24
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/init.lua

@ -1,24 +0,0 @@
function init()
startup()
os.execute("mkdir -p " .. conf_base)
if not helpers.fileExist(init_links.start) then
os.execute("cd " .. init_base .. " && ln -sf " .. init_script .. " " .. init_links.start)
end
if not helpers.fileExist(init_links.stop) then
os.execute("cd " .. init_base .. " && ln -sf " .. init_script .. " " .. init_links.stop)
end
-- run helpers
secret_file_create(cmd.secret_file.create, true --[[firstrun]] )
load(conf_server, S)
load(conf_client, C)
chooser_value = get_startup()
activate_items(chooser_value)
get_upscript()
end

141
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/main_menu.lua

@ -1,141 +0,0 @@
function mainmenu()
m = menu.new{name=locale.caption .. " " .. version, icon="settings"}
m:addKey{directkey=RC.home, id="home", action="key_home"}
m:addKey{directkey=RC.setup, id="setup", action="key_setup"}
m:addItem{type="separator"}
m:addItem{type="cancel"}
m:addItem{type="separatorline"}
m:addItem{type="chooser",
action="set_startup",
value=chooser_value,
options=startup_options,
name=locale.startup,
hint_icon="hint_network",
hint=locale.startup_hint,
}
m:addItem{
type="separatorline",
name=locale.daemon
}
m:addItem{type="forwarder",
name=locale.daemon_stop,
action="action",
icon="rot",
directkey=RC.red,
id=cmd.init_d.stop,
hint_icon="hint_network",
hint=locale.daemon_stop_hint
}
m:addItem{type="forwarder",
name=locale.daemon_start,
action="action",
icon="gruen",
directkey=RC.green,
id=cmd.init_d.restart,
hint_icon="hint_network",
hint=locale.daemon_start_hint
}
m:addItem{
type="separatorline",
name=locale.setup
}
m_ss = m:addItem{type="forwarder",
action="setup_menu_server",
value=conf_server:match("([^/]+)$"),
active=setup_server_active,
name=locale.server,
hint_icon="hint_network",
hint=locale.setup_server_hint,
}
m_sc = m:addItem{type="forwarder",
action="setup_menu_client",
value=conf_client:match("([^/]+)$"),
active=setup_client_active,
name=locale.client,
hint_icon="hint_network",
hint=locale.setup_client_hint,
}
m:addItem{
type="separatorline",
name=locale.logging
}
m_sr = m:addItem{type="forwarder",
name=locale.logging,
action="logging",
hint_icon="hint_network",
hint=locale.logging_hint,
icon="gelb",
directkey=RC.yellow,
active=setup_server_client_active,
}
m:addItem{
type="separatorline",
name=locale.routing
}
m:addItem{type="keyboardinput",
name=locale.routing,
action="set_upscript",
value=route,
size="50",
hint_icon="hint_network",
hint=locale.routing_hint,
help=locale.routing_help,
help2=locale.routing_help2,
icon="blau",
directkey=RC.blue,
enabled=false,
}
m:addItem{
type="separatorline",
name=locale.secret
}
m:addItem{type="forwarder",
name=locale.secret_new,
action="secret_file_create",
id=cmd.secret_file.create,
hint_icon="hint_network",
hint=locale.secret_new_hint,
icon="1",
directkey=RC["1"],
}
m:addItem{
type="filebrowser",
dir_mode="1",
name=locale.secret_push,
action="secret_file_push",
enabled=helpers.fileExist(secret_file),
value=secret_dest,
icon="2",
directkey=RC["2"],
hint_icon="hint_network",
hint=locale.secret_push_hint
}
m:addItem{
type="filebrowser",
name=locale.secret_pull,
action="secret_file_pull",
value=secret_dest,
filter={"key"},
icon="3",
directkey=RC["3"],
hint_icon="hint_network",
hint=locale.secret_pull_hint
}
m:addItem{
type="separatorline",
name=locale.extern
}
m:addItem{
type="filebrowser",
dir_mode="1",
name=locale.extern_import,
action="get_extern",
value="/tmp/",
icon="4",
directkey=RC["4"],
hint_icon="hint_network",
hint=locale.extern_hint
}
m:exec()
end

67
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/setup_menu_client.lua

@ -1,67 +0,0 @@
function setup_menu_client()
m:hide()
local c_m = menu.new{name=locale.setup .. " " .. locale.client, icon="settings"}
c_m:addKey{directkey=RC.home, id="home", action="key_home"}
c_m:addKey{directkey=RC.setup, id="setup", action="key_setup"}
c_m:addItem{type="separator"}
c_m:addItem{type="back"}
c_m:addItem{type="separatorline"}
c_m:addItem{type="chooser",
name=locale.setup_proto,
action="set_string_client",
options=proto_options_client,
id="proto",
value=C.proto,
hint_icon="hint_network",
hint=locale.setup_proto_hint,
}
c_m:addItem{type="keyboardinput",
name=locale.setup_ifconfig,
action="set_string_client",
id="ifconfig",
value=C.ifconfig,
hint_icon="hint_network",
hint=locale.setup_ifconfig_hint,
}
c_m:addItem{type="keyboardinput",
name=locale.setup_remote,
action="set_string_client",
id="remote",
value=C.remote,
hint_icon="hint_network",
hint=locale.setup_remote_hint,
}
c_m:addItem{type="stringinput",
name=locale.setup_keepalive,
action="set_string_client",
id="keepalive",
value=C.keepalive,
valid_chars="0123456789 ",
hint_icon="hint_network",
hint=locale.setup_keepalive_hint,
}
c_m:addItem{type="chooser",
name=locale.setup_lzo,
action="set_string_client",
options=lzo_options,
id="comp-lzo",
value=C["comp-lzo"],
hint_icon="hint_network",
hint=locale.setup_lzo_hint,
}
c_m:addItem{type="filebrowser",
name=locale.setup_secret,
action="set_string_client",
value=C.secret,
id="secret",
filter={"key"},
hint_icon="hint_network",
hint=locale.setup_secret_hint
}
c_m:exec()
save(conf_client, C)
end

69
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/setup_menu_server.lua

@ -1,69 +0,0 @@
function setup_menu_server()
m:hide()
local s_m = menu.new{name=locale.setup .. " " .. locale.server, icon="settings"}
s_m:addKey{directkey=RC.home, id="home", action="key_home"}
s_m:addKey{directkey=RC.setup, id="setup", action="key_setup"}
s_m:addItem{type="separator"}
s_m:addItem{type="back"}
s_m:addItem{type="separatorline"}
s_m:addItem{type="chooser",
name=locale.setup_proto,
action="set_string_server",
options=proto_options_server,
id="proto",
value=S.proto,
hint_icon="hint_network",
hint=locale.setup_proto_hint,
}
s_m:addItem{type="keyboardinput",
name=locale.setup_ifconfig,
action="set_string_server",
id="ifconfig",
value=S.ifconfig,
hint_icon="hint_network",
hint=locale.setup_ifconfig_hint,
}
s_m:addItem{type="stringinput",
name=locale.setup_port,
action="set_string_server",
id="port",
value=S.port,
valid_chars="0123456789",
size="5",
hint_icon="hint_network",
hint=locale.setup_port_hint,
}
s_m:addItem{type="stringinput",
name=locale.setup_keepalive,
action="set_string_server",
id="keepalive",
value=S.keepalive,
valid_chars="0123456789 ",
hint_icon="hint_network",
hint=locale.setup_keepalive_hint,
}
s_m:addItem{type="chooser",
name=locale.setup_lzo,
action="set_string_server",
options=lzo_options,
id="comp-lzo",
value=S["comp-lzo"],
hint_icon="hint_network",
hint=locale.setup_lzo_hint,
}
s_m:addItem{type="filebrowser",
name=locale.setup_secret,
action="set_string_server",
value=S.secret,
id="secret",
filter={"key"},
hint_icon="hint_network",
hint=locale.setup_secret_hint
}
s_m:exec()
save(conf_server, S)
end

60
archive-sources/openvpn-setup/lib/tuxbox/plugins/openvpn_setup/variables.lua

@ -1,60 +0,0 @@
-- global variables
flagfile = "/var/etc/.openvpn"
sbin_base = "/sbin"
if helpers.fileExist("/var/sbin/openvpn") then
sbin_base = "/var/sbin"
end
conf_base = "/var/etc/openvpn"
init_base = "/etc/init.d"
init_script = init_base .. "/ovpn"
init_links = {
start = init_base .. "/S99ovpn",
stop = init_base .. "/K01ovpn"
}
conf_server = conf_base .. "/server.conf"
conf_client = conf_base .. "/client.conf"
secret_file = conf_base .. "/static.key"
secret_dest = "/tmp/"
scriptup = conf_base .. "/up.sh"
scriptup_cmd = "ip route add"
cmd = {
init_d = {
start = init_script .. " start",
stop = init_script .. " stop",
restart = init_script .. " restart",
},
secret_file = {
create = sbin_base .. "/openvpn --genkey --secret " .. secret_file,
},
}
-- server config defaults
S = {}
S.secret = secret_file
S.dev = "tun"
S.proto = "udp"
S.ifconfig = "10.8.0.1 10.8.0.2"
S.port = "1194"
S.keepalive = "10 120"
S["comp-lzo"] = "n/a"
-- client config defaults
C = {}
C.secret = secret_file
C.dev = "tun"
C.proto = "udp"
C.ifconfig = "10.8.0.2 10.8.0.1"
C.remote = "myremote.mydomain 1194"
C.keepalive = "10 120"
C["comp-lzo"] = "n/a"
proto_options_server = { "udp", "tcp-server" --[[, "tcp6", "udp6"]] }
proto_options_client = { "udp", "tcp-client" --[[, "tcp6", "udp6"]] }
lzo_options = { "n/a", "adaptive", "no", "yes" }
Loading…
Cancel
Save