Skip to content

Commit

Permalink
v0.1.2_1 (#101)
Browse files Browse the repository at this point in the history
* back merge main onto devel (#94)

* Update main to latest (#77)

* Updated pkg-plist

* Makefile fix

* Experimenting with wireguard service

* Update README.md

Co-authored-by: vajonam <152501+vajonam@users.noreply.github.com>
Co-authored-by: Manojav Sridhar <manojav@manojav.com>

* docs: add theonemcdonald as a contributor (#84)

* docs: update README.md [skip ci]

* docs: create .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* Update README.md

* Update README.md

* Update .all-contributorsrc

* Update .all-contributorsrc

* Update README.md

* Update README.md

* Update Makefile

* Cleanup

* Cleanup

* Clean upload of v0.1.2

* Create FUNDING.yml

* Add files via upload

Co-authored-by: vajonam <152501+vajonam@users.noreply.github.com>
Co-authored-by: Manojav Sridhar <manojav@manojav.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* Clean ups

* Syntax

* Updated README

* Improve input error clarity

* Syntax

* More syntax

* Fix missing address, allowedip fields after tunnel or peer input errors

* Reorganized peer post validation

* Reorder all input errors to be consistent with UI order

* Fix input being flushed on peer validation error

* Fix

* Test

* Fix #98

* Also Fix #98

* v0.1.3 will be reserved for the next PR with Netgate

* Further fixes #98

* More fixes for #98...

* Removed exit() while working on #98

* Refactor wg_generate_tunnel_address_popover_link for readability

* Working on guiconfig cleaning

* Should fix #99

* Fix variable #99

* Fix re-saving unchanged tunnel or peer

* Fix broke status icon

* Back out some boiler plate code

* Relocate pf reload trigger on tunnel sync

Co-authored-by: vajonam <152501+vajonam@users.noreply.github.com>
Co-authored-by: Manojav Sridhar <manojav@manojav.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jun 4, 2021
1 parent e85c3eb commit 7a5948b
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 176 deletions.
3 changes: 2 additions & 1 deletion net/pfSense-pkg-WireGuard/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PORTNAME= pfSense-pkg-WireGuard
PORTVERSION= 0.1.3
PORTVERSION= 0.1.2
PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
40 changes: 19 additions & 21 deletions net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function wg_toggle_tunnel($tunnel_name) {

if ($enabled && is_wg_tunnel_assigned($tunnel['name'])) {

$input_errors[] = gettext('Cannot disable a WireGuard tunnel while it is assigned as an interface.');
$wg_pfsense_if = wg_get_pfsense_interface_info($tunnel['name']);

$input_errors[] = "Cannot disable {$tunnel['name']} while it is assigned to {$wg_pfsense_if['descr']} ({$wg_pfsense_if['name']})";

}

Expand Down Expand Up @@ -213,7 +215,9 @@ function wg_delete_tunnel($tunnel_name) {
// We can't delete assigned tunnels
if (is_wg_tunnel_assigned($tunnel['name'])) {

$input_errors[] = gettext('Cannot delete a WireGuard tunnel assigned to a pfSense interface.');
$wg_pfsense_if = wg_get_pfsense_interface_info($tunnel['name']);

$input_errors[] = "Cannot delete {$tunnel['name']} while it is assigned to {$wg_pfsense_if['descr']} ({$wg_pfsense_if['name']})";

}

Expand Down Expand Up @@ -245,7 +249,7 @@ function wg_delete_tunnel($tunnel_name) {
function wg_peer_allowedips($post) {

// Convert the post into proper arrays
$allowedips = wg_parse_post_repeatables($post, array('address', 'address_subnet', 'address_descr', 'address_route'));
$allowedips = wg_parse_post_repeatables($post, array('address', 'address_subnet', 'address_descr'));

$ret_array = array();

Expand All @@ -260,13 +264,13 @@ function wg_peer_allowedips($post) {
$ret_array[] = array(
'address' => $row['address'],
'mask' => $row['address_subnet'],
'descr' => $row['address_descr'],
'route' => $row['address_route']);
'descr' => $row['address_descr']);

}

}

// Consumers expect an array
return $ret_array;

}
Expand Down Expand Up @@ -298,6 +302,7 @@ function wg_tunnel_addresses($post) {

}

// Consumers expect an array
return $ret_array;

}
Expand Down Expand Up @@ -346,11 +351,11 @@ function wg_do_peer_post($post) {

$peer_idx = $post['index'];

wg_init_config_arr($wgg['peers'][$peer_idx], array('allowedips', 'row'));

// We need to save the "old config" to compare against later...
$pconfig = $old_config = $wgg['peers'][$peer_idx];

wg_init_config_arr($pconfig, array('allowedips', 'row'));

$pconfig['enabled'] = empty($post['enabled']) ? 'no' : $post['enabled'];

$old_tun = $pconfig['tun'];
Expand Down Expand Up @@ -398,7 +403,6 @@ function wg_do_peer_post($post) {
// We've got meaningful changes...
$changes = true;

// Add peer's tunnel to the list to apply
wg_apply_list_add($pconfig['tun'], 'tunnels');

// Now try the old_config tunnel...
Expand All @@ -407,14 +411,8 @@ function wg_do_peer_post($post) {
// We've got meaningful changes...
$changes = true;

// Add peer's tunnel to the list to apply
wg_apply_list_add($old_config['tun'], 'tunnels');

// Looks like we are just resaving an unassigned peer...
} else {

$changes = false;

}

}
Expand All @@ -440,11 +438,11 @@ function wg_do_tunnel_post($post) {

$tun_idx = $post['index'];

wg_init_config_arr($wgg['tunnels'][$tun_idx], array('addresses', 'row'));

// We need to save the "old config" to compare against later...
$pconfig = $old_config = $wgg['tunnels'][$tun_idx];

wg_init_config_arr($pconfig, array('addresses', 'row'));

$pconfig['name'] = empty($pconfig['name']) ? next_wg_if() : $pconfig['name'];

$pconfig['enabled'] = empty($post['enabled']) ? 'no' : $post['enabled'];
Expand Down Expand Up @@ -593,6 +591,9 @@ function wg_tunnel_sync($tunnel_names = null) {
'config' => $tun_sync_status['config']);

}

// Reload the filter
filter_configure();

}

Expand Down Expand Up @@ -709,15 +710,12 @@ function wg_resync() {
// Reinstall earlyshellcmd in case it was accidently deleted
wg_earlyshellcmd_install();

// Reinstall interface group in case it was accidently deleted
// Recreate interface group in case it was accidently deleted
wg_ifgroup_install();

// Update by re-installing the Unbound ACL
// Update Unbound ACL by recreating it
wg_unbound_acl_install();

// Reinstall service in case it was accidently deleted
wg_service_install();

// We don't want active tunnels when the service isn't running
if (is_module_loaded($wgg['kmod']) && !wg_is_service_running()) {

Expand Down
Loading

0 comments on commit 7a5948b

Please sign in to comment.