From c8bb7f1527a99c69784ab6c01d9050adcde6a8a0 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sat, 22 Sep 2012 23:23:58 +0200 Subject: [PATCH 1/3] Allow for changing OpenVPN TUN to TAP device mode without reboot. --- etc/inc/openvpn.inc | 7 ++++++- usr/local/www/vpn_openvpn_server.php | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index bddb5c8642..84162646ec 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -710,7 +710,12 @@ function openvpn_delete($mode, & $settings) { $vpnid = $settings['vpnid']; $mode_id = $mode.$vpnid; - $tunname = "tun{$vpnid}"; + if (isset($settings['dev_mode'])) + $tunname = "{$settings['dev_mode']}{$vpnid}"; + else { /* defaults to tun */ + $tunname = "tun{$vpnid}"; + } + if ($mode == "server") $devname = "ovpns{$vpnid}"; else diff --git a/usr/local/www/vpn_openvpn_server.php b/usr/local/www/vpn_openvpn_server.php index 02d530df86..d098f434d5 100644 --- a/usr/local/www/vpn_openvpn_server.php +++ b/usr/local/www/vpn_openvpn_server.php @@ -202,6 +202,9 @@ if ($_POST) { unset($input_errors); $pconfig = $_POST; + if ($pconfig['dev_mode'] <> $a_server[$id]['dev_mode']) + openvpn_delete('server', $a_server[$id]);// delete(rename) interface so a new TUN or TAP interface can be created. + if (isset($id) && $a_server[$id]) $vpnid = $a_server[$id]['vpnid']; else From b1aa38049665c6e5df85f5b0b8634e95a8584355 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sat, 22 Sep 2012 23:26:35 +0200 Subject: [PATCH 2/3] changed "Firewall: Virtual IP Address: Edit" page to always have the same options available (if applicable) for IPalias/CARP/ProxyArp/other --- usr/local/www/firewall_virtual_ip_edit.php | 161 +++++++++------------ 1 file changed, 67 insertions(+), 94 deletions(-) diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php index f91fa79447..6b7d6ef941 100755 --- a/usr/local/www/firewall_virtual_ip_edit.php +++ b/usr/local/www/firewall_virtual_ip_edit.php @@ -276,97 +276,71 @@ function get_radio_value(obj) } return null; } -function enable_change(enable_over) { - var note = document.getElementById("typenote"); - var carpnote = document.createTextNode(""); - var proxyarpnote = document.createTextNode(""); - var ipaliasnote = document.createTextNode(""); - if ((get_radio_value(document.iform.mode) == "carp") || enable_over) { - document.iform.vhid.disabled = 0; - document.iform.password.disabled = 0; - document.iform.advskew.disabled = 0; - document.iform.advbase.disabled = 0; - document.iform.type.disabled = 1; - document.iform.subnet_bits.disabled = 0; - document.iform.subnet.disabled = 0; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - if (note.firstChild == null) { - note.appendChild(carpnote); - } else { - note.removeChild(note.firstChild); - note.appendChild(carpnote); - } - } else { - document.iform.vhid.disabled = 1; - document.iform.password.disabled = 1; - document.iform.advskew.disabled = 1; - document.iform.advbase.disabled = 1; - document.iform.type.disabled = 0; - document.iform.subnet_bits.disabled = 1; - document.iform.subnet.disabled = 0; - document.iform.noexpand.disabled = 0; - jQuery('#noexpandrow').css('display',''); - if (note.firstChild == null) { - note.appendChild(proxyarpnote); - } else { - note.removeChild(note.firstChild); - note.appendChild(proxyarpnote); - } - } - if (get_radio_value(document.iform.mode) == "other") { - document.iform.type.disabled = 1; - if (note.firstChild != null) { - note.removeChild(note.firstChild); - } - document.iform.subnet.disabled = 0; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - } - if (get_radio_value(document.iform.mode) == "ipalias") { - document.iform.type.disabled = 1; +function set_note(noteMessage){ + var note = document.getElementById("typenote"); + if (note.firstChild != null) note.removeChild(note.firstChild); - note.appendChild(ipaliasnote); - document.iform.subnet_bits.disabled = 0; - document.iform.subnet.disabled = 0; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); + if (noteMessage) + note.appendChild(noteMessage); +} +function enable_change() { + var carpnote = document.createTextNode(""); + var proxyarpnote = document.createTextNode(""); + var ipaliasnote = document.createTextNode(""); + + $mode = get_radio_value(document.iform.mode); + + document.iform.password.disabled = $mode != "carp"; + document.iform.vhid.disabled = $mode != "carp"; + document.iform.advskew.disabled = $mode != "carp"; + document.iform.advbase.disabled = $mode != "carp"; + document.iform.type.disabled = $mode in {"carp":1,"ipalias":1}; + + if ($mode in {"carp":1,"ipalias":1}) + document.iform.type.selectedIndex = 0;// single-adress + switch($mode) + { + case "carp" : set_note(carpnote); break; + case "ipalias" : set_note(ipaliasnote); break; + case "proxyarp": set_note(proxyarpnote); break; + default: set_note(undefined); } typesel_change(); } + function typesel_change() { - switch (document.iform.type.selectedIndex) { - case 0: // single - document.iform.subnet.disabled = 0; - if((get_radio_value(document.iform.mode) == "proxyarp")) document.iform.subnet_bits.disabled = 1; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - break; - case 1: // network - document.iform.subnet.disabled = 0; - document.iform.subnet_bits.disabled = 0; - document.iform.noexpand.disabled = 0; - jQuery('#noexpandrow').css('display',''); - //document.iform.range_from.disabled = 1; - //document.iform.range_to.disabled = 1; - break; - case 2: // range - document.iform.subnet.disabled = 1; - document.iform.subnet_bits.disabled = 1; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - //document.iform.range_from.disabled = 0; - //document.iform.range_to.disabled = 0; - break; + switch (document.iform.type.selectedIndex) { + case 0: // single + document.iform.subnet.disabled = 0; + document.iform.subnet_bits.disabled = (get_radio_value(document.iform.mode) == "proxyarp") || (get_radio_value(document.iform.mode) == "other"); + document.iform.noexpand.disabled = 1; + jQuery('#noexpandrow').css('display','none'); + break; + case 1: // network + document.iform.subnet.disabled = 0; + document.iform.subnet_bits.disabled = 0; + document.iform.noexpand.disabled = 0; + jQuery('#noexpandrow').css('display',''); + //document.iform.range_from.disabled = 1; + //document.iform.range_to.disabled = 1; + break; + case 2: // range + document.iform.subnet.disabled = 1; + document.iform.subnet_bits.disabled = 1; + document.iform.noexpand.disabled = 1; + jQuery('#noexpandrow').css('display','none'); + //document.iform.range_from.disabled = 0; + //document.iform.range_to.disabled = 0; + break; case 3: // IP alias - document.iform.subnet.disabled = 1; - document.iform.subnet_bits.disabled = 0; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - //document.iform.range_from.disabled = 0; - //document.iform.range_to.disabled = 0; - break; - } + document.iform.subnet.disabled = 1; + document.iform.subnet_bits.disabled = 0; + document.iform.noexpand.disabled = 1; + jQuery('#noexpandrow').css('display','none'); + //document.iform.range_from.disabled = 0; + //document.iform.range_to.disabled = 0; + break; + } } //--> @@ -380,14 +354,14 @@ function typesel_change() { - > - > - > - > + > + > + > @@ -526,8 +500,7 @@ function typesel_change() { From d41bb44745966a668f55d14e9bb53ebd22c4d91e Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sun, 23 Sep 2012 00:44:52 +0200 Subject: [PATCH 3/3] Add a "Sockets listening" page to the Diagnostics menu. This for easy viewing of what services are bound to which interface and port. ( based on the file diag_sockets.php from forum member 'bardelot' http://forum.pfsense.org/index.php/topic,53070.msg284360.html#msg284360 ) --- usr/local/www/diag_sockets.php | 115 +++++++++++++++++++++++++++++++++ usr/local/www/fbegin.inc | 1 + 2 files changed, 116 insertions(+) create mode 100644 usr/local/www/diag_sockets.php diff --git a/usr/local/www/diag_sockets.php b/usr/local/www/diag_sockets.php new file mode 100644 index 0000000000..3c81fc72a4 --- /dev/null +++ b/usr/local/www/diag_sockets.php @@ -0,0 +1,115 @@ + + + + +
+ + + + + + + + + + + +
Socket information explanation
+This page show the output for the commands: "sockstat -4lL" and "sockstat -6lL".
+The information listed for each socket is:
USER The user who owns the socket.
COMMAND The command which holds the socket.
PID The process ID of the command which holds the socket.
FD The file descriptor number of the socket.
PROTO The transport protocol associated with the socket for Internet sockets, or the type of socket (stream or data-gram) for UNIX sockets.
ADDRESS (UNIX sockets only) For bound sockets, this is the file-name of the socket. For other sockets, it is the name, PID and file descriptor number of the peer, or ``(none)'' if the socket is neither bound nor connected.
LOCAL ADDRESS (Internet sockets only) The address the local end of the socket is bound to (see getsockname(2)).
FOREIGN ADDRESS (Internet sockets only) The address the foreign end of the socket is bound to (see getpeername(2)).
+ $table) { + $elements = ($tabindex == 0 ? 7 : 7); + $name = ($tabindex == 0 ? 'IPv4' : 'IPv6'); +?> +
+ + +
+ + $line) { + if ($i == 0) + $class = 'listhdrr'; + else + $class = 'listlr'; + + if (trim($line) == "") + continue; + print("\n"); + $j = 0; + foreach (explode(' ', $line) as $entry) { + if ($entry == '' || $entry == "ADDRESS") continue; + if ($i == 0) + print("\n"); + else + print("\n"); + if ($i > 0) + $class = 'listr'; + $j++; + } + print("\n"); + }?> +
$entry$entry
+
+ + + +
+ + diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc index bb118693ef..17c3185746 100755 --- a/usr/local/www/fbegin.inc +++ b/usr/local/www/fbegin.inc @@ -229,6 +229,7 @@ $diagnostics_menu[] = array(gettext("pfTop"), "/diag_system_pftop.php"); $diagnostics_menu[] = array(gettext("Reboot"), "/reboot.php"); $diagnostics_menu[] = array(gettext("Routes"), "/diag_routes.php"); $diagnostics_menu[] = array(gettext("SMART Status"), "/diag_smart.php"); +$diagnostics_menu[] = array(gettext("Sockets listening"), "/diag_sockets.php" ); $diagnostics_menu[] = array(gettext("States"), "/diag_dump_states.php"); $diagnostics_menu[] = array(gettext("States Summary"), "/diag_states_summary.php"); $diagnostics_menu[] = array(gettext("System Activity"), "/diag_system_activity.php");