@@ -29,12 +29,12 @@ static uint8_t wireguard_peer_index = WIREGUARDIF_INVALID_INDEX;
29
29
30
30
#define TAG " [WireGuard] "
31
31
32
- bool WireGuard::begin (const IPAddress& localIP, const char * privateKey, const char * remotePeerAddress, const char * remotePeerPublicKey, uint16_t remotePeerPort) {
32
+ bool WireGuard::begin (const IPAddress& localIP, const IPAddress& Subnet, const IPAddress& Gateway, const char * privateKey, const char * remotePeerAddress, const char * remotePeerPublicKey, uint16_t remotePeerPort) {
33
33
struct wireguardif_init_data wg;
34
34
struct wireguardif_peer peer;
35
35
ip_addr_t ipaddr = IPADDR4_INIT (static_cast <uint32_t >(localIP));
36
- ip_addr_t netmask = IPADDR4_INIT_BYTES ( 255 , 255 , 255 , 255 );
37
- ip_addr_t gateway = IPADDR4_INIT_BYTES ( 0 , 0 , 0 , 0 );
36
+ ip_addr_t netmask = IPADDR4_INIT ( static_cast < uint32_t >(Subnet) );
37
+ ip_addr_t gateway = IPADDR4_INIT ( static_cast < uint32_t >(Gateway) );
38
38
39
39
assert (privateKey != NULL );
40
40
assert (remotePeerAddress != NULL );
@@ -119,6 +119,13 @@ bool WireGuard::begin(const IPAddress& localIP, const char* privateKey, const ch
119
119
return true ;
120
120
}
121
121
122
+ bool WireGuard::begin (const IPAddress& localIP, const char * privateKey, const char * remotePeerAddress, const char * remotePeerPublicKey, uint16_t remotePeerPort) {
123
+ // Maintain compatiblity with old begin
124
+ auto subnet = IPAddress (255 ,255 ,255 ,255 );
125
+ auto gateway = IPAddress (0 ,0 ,0 ,0 );
126
+ return WireGuard::begin (localIP, subnet, gateway, privateKey, remotePeerAddress, remotePeerPublicKey, remotePeerPort);
127
+ }
128
+
122
129
void WireGuard::end () {
123
130
if ( !this ->_is_initialized ) return ;
124
131
0 commit comments