Skip to content
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

Fix Automagic for TCP based OpenVPN and for port aliases #528

Merged
merged 3 commits into from
May 30, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -991,13 +991,9 @@ function openvpn_client_export_find_port_forwards($targetip, $targetport, $targe

foreach ($config['nat']['rule'] as $natent) {
$dest = array();
if (!isset($natent['disabled']) && ($natent['target'] == $targetip) && ($natent['local-port'] == $targetport) && ($natent['protocol'] == $targetproto)) {
$dest['proto'] = $natent['protocol'];

// Could be multiple ports... But we can only use one.
$dports = is_port($natent['destination']['port']) ? array($natent['destination']['port']) : filter_expand_alias_array($natent['destination']['port']);
$dest['port'] = $dports[0];

if (!isset($natent['disabled']) && ($natent['target'] == $targetip) && ($natent['local-port'] == $targetport) && ($natent['protocol'] == strtolower(substr($targetproto, 0, 3)))) {
$dest['proto'] = $targetproto;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the indentation style using hard TABs instead of replacing it by spaces

// Could be network or address ...
$natif = (!$natent['interface']) ? "wan" : $natent['interface'];

Expand Down Expand Up @@ -1033,7 +1029,13 @@ function openvpn_client_export_find_port_forwards($targetip, $targetport, $targe
}
}

$destinations[] = $dest;
$dports = is_port($natent['destination']['port']) ? array($natent['destination']['port']) : filter_expand_alias_array($natent['destination']['port']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, keep TABs


// Could be multiple ports, we add all of them
foreach ($dports as $dport) {
$dest['port'] = $dport;
$destinations[] = $dest;
}
}
}

Expand Down