Skip to content

Commit

Permalink
Added the masquerade configuration to the postconnect.d scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tombatossals committed Apr 14, 2013
1 parent 716df05 commit b8a9d66
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/Packages
@@ -0,0 +1,10 @@
Package: luci-app-vpnc
Version: 0.1
Architecture: all
Maintainer: David Rubert <david.rubert@gmail.com>
Depends: vpnc
Section: luci
Priority: optional
Description: LuCI GUI to the VPNC program
Filename: luci-app-vpnc_0.1_all.ipk
Source: luci-app-vpnc
Binary file added packages/luci-app-vpnc_0.1_all.ipk
Binary file not shown.
3 changes: 3 additions & 0 deletions src/etc/vpnc/post-connect.d/masquerade
@@ -0,0 +1,3 @@
iptables -A forwarding_rule -o tun0 -j ACCEPT
iptables -A forwarding_rule -i tun0 -j ACCEPT
iptables -t nat -A postrouting_rule -o tun0 -j MASQUERADE
11 changes: 8 additions & 3 deletions src/usr/lib/lua/luci/model/cbi/vpnc.lua
Expand Up @@ -29,6 +29,7 @@ pw = s:taboption("vpnc", Value, "password", translate("Password"))
pw.password = true

local pid = luci.util.exec("/usr/bin/pgrep vpnc")
local message = luci.http.formvalue("message")

function vpnc_process_status()
local status = "VPNC is not running now and "
Expand All @@ -43,7 +44,7 @@ function vpnc_process_status()
status = status .. "it's disabled on the startup"
end

local status = { status=status }
local status = { status=status, message=message }
local table = { pid=status }
return table
end
Expand All @@ -53,14 +54,18 @@ t.anonymous = true

t:option(DummyValue, "status", translate("VPNC status"))

if message then
t:option(DummyValue, "message", translate("VPNC start message"))
end

if pid == "" then
start = t:option(Button, "_start", translate("Start"))
start.inputstyle = "apply"
function start.write(self, section)
luci.util.exec("/etc/init.d/vpnc start")
message = luci.util.exec("/etc/init.d/vpnc start 2>&1")
luci.util.exec("sleep 4")
luci.http.redirect(
luci.dispatcher.build_url("admin", "services", "vpnc")
luci.dispatcher.build_url("admin", "services", "vpnc") .. "?message=" .. message
)
end
else
Expand Down

0 comments on commit b8a9d66

Please sign in to comment.