<%# Opennet Firmware Copyright 2010 Rene Ejury Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -%> <% local uci = require "luci.model.uci" local cursor = uci.cursor() local SYSROOT = os.getenv("LUCI_SYSROOT") if not SYSROOT then SYSROOT = "" end -- SYSROOT is only used for local testing (make runhttpd in luci tree) local on_keycrt_exists = nixio.fs.access(SYSROOT.."/etc/openvpn/opennet_user/on_aps.key") and nixio.fs.access(SYSROOT.."/etc/openvpn/opennet_user/on_aps.crt") %> <%+header%>

<%:Opennet OpenVPN Gateways%>

<%:Here you can configure the IP-Addresses of your choosen Gateways.%> <% if show_more_info then %>

<% print(luci.i18n.string([[If you like to find more Information about the Gateways in Opennet, have a look in the Opennet-Wiki. Usually the first found Gateway in your list is the one you are going to use. The Gateway will be changed without your action, if the current Gateway does not work for around 6 minutes. Any Change of your Gateway will drop all your Internet Connections.
If non of the Gateways in your list are reachable or working (of if your list is empty), OpenVPN is deactivated.
Automated Gateway Search: The Gateways will be detected by an internal algorithm and ordered by their distance. In special cases this might nit be the best solution.

Additional Information about the column-values.
If any Gateway is active, then the test-connection to the OpenVPN-Service of this server was successfull. If this information is missing, the test was not done before]])) else %>
<% end %>

<%:Gateway-List%>

<%:automated gateway-search%> <% local autosearch = (cursor:get("on-openvpn", "gateways", "autosearch") == "on") if autosearch then %> <%:activated%> <% else %> <%:deactivated%> <% end %>

<% if autosearch then local sort_by_etx = (cursor:get("on-openvpn", "gateways", "vpn_sort_criteria") == "etx") %>

Sortierung nach <% if sort_by_etx then %> <% print(luci.i18n.string([[ETX (rounded)]])) %> <% else %> <%:Distance%> <% end %>

<% end %>
<% if on_keycrt_exists then %> <% end %> <% local name local count = 1 local number_of_gateways = 0 os.execute("echo '/route' | nc localhost 2006 > /tmp/olsrd_txtinfo.txt") os.execute("on_vpngateway_check check_blacklisting >/dev/null") cursor:unload("on-openvpn") cursor:foreach ("on-openvpn", "gateway", function() number_of_gateways = number_of_gateways + 1 end) while count <= number_of_gateways do local v = cursor:get_all("on-openvpn", "gate_"..count) if v and v[".type"] == "gateway" then if v.name then name = v.name else name = "..." end local active if v.ipaddr == cursor:get("openvpn", "opennet_user", "remote") then if (nixio.fs.access("/tmp/openvpn_msg.txt")) then active="y" else active="n" end end %> <% if on_keycrt_exists then %> <% end %> <% if not autosearch then %> <% end %> <% end count = count + 1 end nixio.fs.remove("/tmp/olsrd_txtinfo.txt") %> <% if on_keycrt_exists then %> <% end %> <% if not autosearch then %> <% end %>
<%:active%> <% print(luci.i18n.string([[IP-Address]])) %> <%:Name%> <% print(luci.i18n.string([[Distance / ETX]])) %><%:VPN-Status%> <%:Test-Age%>
<%=count%>
 

<%=name%>
<% local output=luci.sys.exec("awk 'BEGIN {FS=\"[/\\x09]+\"} \$1==\""..v.ipaddr.."\" {print \$4\" / \"\$5}' /tmp/olsrd_txtinfo.txt") %><%=output%>
 
<%=v.age%>
<% if count ~= 1 then %> <% end %> <% if count ~= number_of_gateways then %> <% end %>
<% local better_gw=cursor:get("on-openvpn", "gateways", "better_gw") if ( better_gw and better_gw ~= "0") then print(luci.i18n.stringf([[The first reachable and not blocked Gateway is not the current active one. The Tunnel will be restarted and the Gateway will be changed in about %s minutes. The changes will be shown after a reload of this page.]], 6-better_gw)) end %>

<%:Gateway-Blacklist%>

<% name = "" for k, v in pairs(cursor:get_all("on-openvpn")) do if v[".type"] == "blacklist_gateway" then %> <% end end %>
<%:IP Address%> <%:Name%>

<%=v.ipaddr%>

<%=v.name%>
<%+footer%>