aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-09-09 20:42:13 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2021-09-10 21:31:54 +0000
commit1f205c247995afc82e2d779238505cd8d3f5ac17 (patch)
tree8534469e36f2e6b0fb4e5716d55ada75fedff1b8
parentversion: bump (diff)
downloadwireguard-nt-1f205c247995afc82e2d779238505cd8d3f5ac17.tar.xz
wireguard-nt-1f205c247995afc82e2d779238505cd8d3f5ac17.zip
example: disable dad for faster startup
And set address after routes so that loopback works. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--example/example.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/example/example.c b/example/example.c
index 92015c4..360d4e8 100644
--- a/example/example.c
+++ b/example/example.c
@@ -344,6 +344,7 @@ int __cdecl main(void)
InitializeUnicastIpAddressEntry(&AddressRow);
AddressRow.Address.Ipv4.sin_family = AF_INET;
AddressRow.OnLinkPrefixLength = 24; /* This is a /24 network */
+ AddressRow.DadState = IpDadStatePreferred;
Bytes = sizeof(Config.DemoServer.PublicKey);
if (strcmp(ServerResponse, "OK") || InetPtonA(AF_INET, Colon3 + 1, &AddressRow.Address.Ipv4.sin_addr) != 1 ||
!CryptStringToBinaryA(Colon1 + 1, 0, CRYPT_STRING_BASE64, Config.DemoServer.PublicKey, &Bytes, NULL, NULL))
@@ -392,12 +393,6 @@ int __cdecl main(void)
Log(WIREGUARD_LOG_INFO, L"WireGuardNT v%u.%u loaded", (Version >> 16) & 0xff, (Version >> 0) & 0xff);
WireGuardGetAdapterLUID(Adapter, &AddressRow.InterfaceLuid);
- LastError = CreateUnicastIpAddressEntry(&AddressRow);
- if (LastError != ERROR_SUCCESS && LastError != ERROR_OBJECT_ALREADY_EXISTS)
- {
- LogError(L"Failed to set IP address", LastError);
- goto cleanupAdapter;
- }
MIB_IPFORWARD_ROW2 DefaultRoute = { 0 };
InitializeIpForwardEntry(&DefaultRoute);
DefaultRoute.InterfaceLuid = AddressRow.InterfaceLuid;
@@ -410,6 +405,12 @@ int __cdecl main(void)
LogError(L"Failed to set default route", LastError);
goto cleanupAdapter;
}
+ LastError = CreateUnicastIpAddressEntry(&AddressRow);
+ if (LastError != ERROR_SUCCESS && LastError != ERROR_OBJECT_ALREADY_EXISTS)
+ {
+ LogError(L"Failed to set IP address", LastError);
+ goto cleanupAdapter;
+ }
MIB_IPINTERFACE_ROW IpInterface = { 0 };
InitializeIpInterfaceEntry(&IpInterface);
IpInterface.InterfaceLuid = AddressRow.InterfaceLuid;