Skip to content

Commit f430438

Browse files
authored
Fixes peer endpoint formatting when using default port (#70)
Fixes peer endpoint formatting when using default port
1 parent 063eda2 commit f430438

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/files/usr/local/pkg/wireguard/wg.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,6 @@ function wg_do_peer_post($post) {
277277

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

280-
// Looks like we have a dynamic endpoint, so clear endpoint or port variables before saving
281-
if (isset($post['dynamic']) && $post['dynamic'] == 'yes') {
282-
283-
unset($post['endpoint'], $post['port']);
284-
285-
}
286-
287280
$pconfig['enabled'] = empty($post['enabled']) ? 'no' : 'yes';
288281

289282
$pconfig['tun'] = $post['tun'];
@@ -292,7 +285,7 @@ function wg_do_peer_post($post) {
292285

293286
$pconfig['endpoint'] = $post['endpoint'];
294287

295-
$pconfig['port'] = $post['port'];
288+
$pconfig['port'] = empty($post['port']) ? $wgg['default_port'] : $post['port'];
296289

297290
$pconfig['persistentkeepalive'] = $post['persistentkeepalive'];
298291

@@ -302,6 +295,13 @@ function wg_do_peer_post($post) {
302295

303296
$pconfig['allowedips']['row'] = wg_peer_allowedips($post);
304297

298+
// Looks like we have a dynamic endpoint, so clear endpoint or port variables before saving
299+
if (isset($post['dynamic']) && $post['dynamic'] == 'yes') {
300+
301+
unset($post['endpoint'], $post['port']);
302+
303+
}
304+
305305
$input_errors = wg_validate_peer_post($pconfig, $peer_idx);
306306

307307
if (!$input_errors) {

src/files/usr/local/pkg/wireguard/wg_guiconfig.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function wg_format_endpoint($header = true, $peer = null, $endpoint_key = 'endpo
4040

4141
if (!empty($peer[$endpoint_key])) {
4242

43-
return "{$peer[$endpoint_key]} : {$peer[$port_key]}";
43+
return "{$peer[$endpoint_key]}:{$peer[$port_key]}";
4444

4545
} else {
4646

0 commit comments

Comments
 (0)