1 local readmeURL = "https://github.com/openwrt/packages/blob/master/net/vpnbypass/files/README.md"
3 m = Map("vpnbypass", translate("VPN Bypass Settings"))
5 h = m:section(NamedSection, "config", "vpnbypass", translate("Service Status"))
6 local packageName = "vpnbypass"
7 local uci = require "luci.model.uci".cursor()
8 local sys = require "luci.sys"
9 local http = require "luci.http"
10 local dispatcher = require "luci.dispatcher"
11 en = h:option(Button, "__toggle")
12 if enabledFlag ~= "1" then
13 en.title = translate("Service is disabled/stopped")
14 en.inputtitle = translate("Enable/Start")
15 en.inputstyle = "apply important"
17 en.title = translate("Service is enabled/started")
18 en.inputtitle = translate("Stop/Disable")
19 en.inputstyle = "reset important"
22 enabledFlag = enabledFlag == "1" and "0" or "1"
23 uci:set(packageName, "config", "enabled", enabledFlag)
25 uci:commit(packageName)
26 if enabledFlag == "0" then
27 sys.init.stop(packageName)
28 sys.init.disable(packageName)
30 sys.init.enable(packageName)
31 sys.init.start(packageName)
33 http.redirect(dispatcher.build_url("admin/services/" .. packageName))
36 s = m:section(NamedSection, "config", "vpnbypass", translate("VPN Bypass Rules"))
39 p1 = s:option(DynamicList, "localport", translate("Local Ports to Bypass"), translate("Local ports to trigger VPN Bypass"))
40 p1.datatype = "portrange"
41 -- p1.placeholder = "0-65535"
46 p2 = s:option(DynamicList, "remoteport", translate("Remote Ports to Bypass"), translate("Remote ports to trigger VPN Bypass"))
47 p2.datatype = "portrange"
48 -- p2.placeholder = "0-65535"
53 r1 = s:option(DynamicList, "localsubnet", translate("Local IP Addresses to Bypass"), translate("Local IP addresses or subnets with direct internet access (outside of the VPN tunnel)"))
54 r1.datatype = "ip4addr"
55 -- r1.placeholder = ip.new(m.uci:get("network", "lan", "ipaddr"), m.uci:get("network", "lan", "netmask"))
60 r2 = s:option(DynamicList, "remotesubnet", translate("Remote IP Addresses to Bypass"), translate("Remote IP addresses or subnets which will be accessed directly (outside of the VPN tunnel)"))
61 r2.datatype = "ip4addr"
62 -- r2.placeholder = "0.0.0.0/0"
68 s4 = d:section(TypedSection, "dnsmasq")
70 di = s4:option(DynamicList, "ipset", translate("Domains to Bypass"),
71 translate("Domains to be accessed directly (outside of the VPN tunnel), see ")
72 .. [[<a href="]] .. readmeURL .. [[#bypass-domains-formatsyntax" target="_blank">]]
73 .. translate("README") .. [[</a> ]] .. translate("for syntax"))
74 function d.on_after_commit(map)
75 sys.init.restart("dnsmasq")