Skip to content

OpenVPN: Use OpenVPN's official p2p mode, consistent with standard OpenVPN behavior #8604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/opnsense/mvc/app/models/OPNsense/OpenVPN/OpenVPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,8 @@ public function generateInstanceConfig($uuid = null)
$masklong = ip2long($mask);
$ip1 = long2ip32((ip2long32($parts[0]) & $masklong) + ($masklong == 0xfffffffe ? 0 : 1));
$ip2 = long2ip32((ip2long32($parts[0]) & $masklong) + ($masklong == 0xfffffffe ? 1 : 2));
$ip3 = long2ip32((ip2long32($parts[0]) & $masklong) + ($masklong == 0xfffffffe ? 2 : 3));
$options['mode'] = 'server';
$options['tls-server'] = null;
$options['ifconfig'] = "{$ip1} {$ip2}";
$options['ifconfig-pool'] = "{$ip2} {$ip3}";
} else {
$options['server'] = $parts[0] . " " . $mask;
}
Expand All @@ -611,16 +608,20 @@ public function generateInstanceConfig($uuid = null)
if (!empty((string)$node->username_as_common_name)) {
$options['username-as-common-name'] = null;
}
$options['client-config-dir'] = "/var/etc/openvpn-csc/{$node->vpnid}";
if (!(string)$node->topology == 'p2p') {
$options['client-config-dir'] = "/var/etc/openvpn-csc/{$node->vpnid}";
}
// hook event handlers
if (!empty((string)$node->authmode)) {
$options['auth-user-pass-verify'] = "\"{$event_script} --defer '{$node_uuid}'\" via-env";
$options['learn-address'] = "\"{$event_script} '{$node->vpnid}'\"";
} else {
} else if (!(string)$node->topology == 'p2p') {
// client specific profiles are being deployed using the connect event when no auth is used
$options['client-connect'] = "\"{$event_script} '{$node_uuid}'\"";
}
$options['client-disconnect'] = "\"{$event_script} '{$node_uuid}'\"";
if (!(string)$node->topology == 'p2p') {
$options['client-disconnect'] = "\"{$event_script} '{$node_uuid}'\"";
}
$options['tls-verify'] = "\"{$event_script} '{$node_uuid}'\"";

if (!empty((string)$node->maxclients)) {
Expand Down