Skip to content

Commit 4bb7c06

Browse files
committed
add parameter to provide local listening port.
1 parent f3c1ba5 commit 4bb7c06

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/WireGuard-ESP32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class WireGuard
2727
const IPAddress& localIP,
2828
// Subnet of the WireGuard network
2929
const IPAddress& Subnet,
30+
// Port that the interface will try to bind to
31+
const uint16_t localPort,
3032
// Gateway of the WireGuard network
3133
const IPAddress& Gateway,
3234
// Our private key

src/WireGuard.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static esp_err_t netif_set_default_in_lwip_ctx(void *ctx) {
5656

5757
bool WireGuard::begin(const IPAddress& localIP,
5858
const IPAddress& Subnet,
59+
const uint16_t localPort,
5960
const IPAddress& Gateway,
6061
const char* privateKey,
6162
const char* remotePeerAddress,
@@ -80,7 +81,7 @@ bool WireGuard::begin(const IPAddress& localIP,
8081

8182
// Setup the WireGuard device structure
8283
wg.private_key = privateKey;
83-
wg.listen_port = remotePeerPort;
84+
wg.listen_port = localPort;
8485

8586
wg.bind_netif = NULL;
8687

0 commit comments

Comments
 (0)