Changeset 2176


Ignore:
Timestamp:
Sep 19, 2012, 3:26:28 PM (7 years ago)
Author:
matthijs
Message:

luci-openvpn: Allow changing the protocol and port used.

Thanks to Jon Spriggs for this patch.

Closes: #1188

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/fon/openvpn/files/etc/fonstated/ReconfOpenVPN

    r1679 r2176  
    1616end
    1717uci:commit("firewall")
     18-- Make sure the services config opens up the right port
     19local port = uci:get("openvpn", "openvpn", "port") or 1194
     20local prot = uci:get("openvpn", "openvpn", "proto") or 1194
     21uci:delete("services", "openvpn", "udp_port")
     22uci:delete("services", "openvpn", "tcp_port")
     23local option = (prot == "udp" and "udp_port" or "tcp_port")
     24uci:set_list("services", "openvpn", option, port)
     25uci:commit("services")
     26
    1827local e = require "luci.fon.event"
    1928e.runnow_nowait("RestartOpenVpn")
  • trunk/fon/openvpn/files/etc/openvpn/client.ovpn

    r1143 r2176  
    11client
    22dev tun
    3 proto udp
     3proto %PROTO%
    44remote %IP% %PORT%
    55resolv-retry infinite
  • trunk/fon/openvpn/files/usr/bin/openvpn-client.sh

    r2140 r2176  
    33NAME="FONERA"
    44PORT=`uci get openvpn.openvpn.port`
     5PROTO=`uci get openvpn.openvpn.proto`
    56HOST=`uci get ddns.ddns_scripts.domain`
    67[ "$HOST" = "" ] && HOST=`uci get openvpn.openvpn.public`
    78[ "$HOST" = "" ] && HOST=`uci -P /var/state/ get network.wan.ipaddr`
     9[ "$PROTO" = "tcp-server" ] && PROTO="tcp-client"
    810cd /tmp
    911cp /etc/openvpn/keys/ca.crt ca_$1.crt
    1012cp /etc/openvpn/keys/$1.crt $1.crt
    1113cp /etc/openvpn/keys/$1.key $1.key
    12 cat /etc/openvpn/client.ovpn | sed "s/%IP%/$HOST/g" | sed "s/%PORT%/$PORT/g" | sed "s/%CLIENT%/$1/g" > ${NAME}.ovpn
     14cat /etc/openvpn/client.ovpn | sed "s/%PROTO%/$PROTO/g" | sed "s/%IP%/$HOST/g" | sed "s/%PORT%/$PORT/g" | sed "s/%CLIENT%/$1/g" > ${NAME}.ovpn
    1315rm -f /tmp/$1_ovpn.zip
    1416zip /tmp/$1_ovpn.zip ca_$1.crt $1.crt $1.key ${NAME}.ovpn
  • trunk/luci/applications/luci-openvpn/luasrc/model/cbi/openvpn/firewall.lua

    r2175 r2176  
    2121x.default = require("luci.model.uci").cursor():get("openvpn", "openvpn", "wan") or "0"
    2222
     23local x = s:option(ListValue, "proto", translate("openvpn_proto", "Protocol"))
     24x:value("udp", "UDP")
     25x:value("tcp-server", "TCP")
     26x.default = require("luci.model.uci").cursor():get("openvpn", "openvpn", "proto") or "udp"
     27
     28local x = s:option(Value, "port", translate("openvpn_port", "TCP or UDP port"))
     29x.default = require("luci.model.uci").cursor():get("openvpn", "openvpn", "port") or "1194"
     30
    2331local x = s:option(ListValue, "keepalive", translate("openvpn_keepalive", "Send periodic keepalives"))
    2432x:value("0 0", translate("openvpn_keepalive_never", "Never"))
  • trunk/luci/i18n/english/luasrc/i18n/default.en.lua

    r2174 r2176  
    131131openvpn_new_desc = "Please specify the name of this connection."
    132132openvpn_new_title = "Add a new VPN Clients"
     133openvpn_port = "TCP or UDP port"
     134openvpn_proto = "Protocol"
    133135openvpn_remove = "Do you really want to remove the clients keys ?"
    134136openvpn_safesurf = "Safe Surf"
  • trunk/luci/modules/admin-fon/root/sbin/save-config.sh

    r2175 r2176  
    121121echo "uci import -m openvpn <<EOF"
    122122echo "config 'openvpn' 'openvpn'"
    123 for o in enable lan wan keepalive max_clients; do
     123for o in enable lan wan keepalive max_clients proto port; do
    124124        echo "  option '$o' '$(config_get openvpn $o)'"
    125125done
     
    133133
    134134config_clear
     135
     136# The OpenVPN port settings are duplicated in the services config, so
     137# backup those as well.
     138echo "uci delete services.openvpn.tcp_port"
     139for p in uci get services.openvpn.tcp_port; do
     140        echo "uci add_list 'services.openvpn.tcp_port=$p'"
     141done
     142echo "uci delete services.openvpn.udp_port"
     143for p in uci get services.openvpn.udp_port; do
     144        echo "uci add_list 'services.openvpn.udp_port=$p'"
     145done
     146
    135147
    136148# Save luci language setting
Note: See TracChangeset for help on using the changeset viewer.