- Make foreign interface found error numeric to ease condition
detection.
- Update GetInterface() documentation.
- Make tun.CreateTUN() quit when foreign interface found before
attempting to create a Wintun interface with a duplicate name.
Creation is futile.
Signed-off-by: Simon Rozman <simon@rozman.si>
- Make getStringValueRetry() reusable for reading any value type. This
merges code from GetIntegerValueWait().
- expandString() >> toString() and extend to support REG_MULTI_SZ
(to return first value of REG_MULTI_SZ). Furthermore, doing our own
UTF-16 to UTF-8 conversion works around a bug in windows/registry's
GetStringValue() non-zero terminated string handling.
- Provide toInteger() analogous to toString()
- GetStringValueWait() tolerates and reads REG_MULTI_SZ too now. It
returns REG_MULTI_SZ[0], making GetFirstStringValueWait() redundant.
Signed-off-by: Simon Rozman <simon@rozman.si>
The only time we're trying to counteract the race condition is when
we're creating a driver. When we're simply looking up all drivers, it
doesn't make sense to retry.
DIF_INSTALLDEVICE returns almost immediately, while the device
installation continues in the background. It might take a while, before
all registry keys and values are populated.
Previously, wireguard-go waited for HKLM\SYSTEM\CurrentControlSet\
Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\<id> registry key
only.
Followed by a SetInterfaceName() method of Wintun struct which tried to
access HKLM\SYSTEM\CurrentControlSet\Control\Network\
{4D36E972-E325-11CE-BFC1-08002BE10318}\<id>\Connection registry key
might not be available yet.
This commit loops until both registry keys are available before
returning from CreateInterface() function.
Signed-off-by: Simon Rozman <simon@rozman.si>
As querying non-existing registry value and reading non-existing
registry string value both return ERROR_FILE_NOT_FOUND, we can
use later only.
Signed-off-by: Simon Rozman <simon@rozman.si>