nts: follow bind*device settings for NTS-KE sockets

Bind the server and client NTS-KE sockets to the specified device.
This commit is contained in:
Miroslav Lichvar
2020-07-13 14:16:42 +02:00
parent 55a90c3735
commit c10b66b579
2 changed files with 7 additions and 4 deletions

View File

@@ -256,19 +256,21 @@ static int
open_socket(int family, int port)
{
IPSockAddr local_addr;
char *iface;
int sock_fd;
if (!SCK_IsIpFamilyEnabled(family))
return INVALID_SOCK_FD;
CNF_GetBindAddress(family, &local_addr.ip_addr);
iface = CNF_GetBindNtpInterface();
if (local_addr.ip_addr.family != family)
SCK_GetAnyLocalIPAddress(family, &local_addr.ip_addr);
local_addr.port = port;
sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, NULL, 0);
sock_fd = SCK_OpenTcpSocket(NULL, &local_addr, iface, 0);
if (sock_fd < 0) {
LOG(LOGS_ERR, "Could not open NTS-KE socket on %s", UTI_IPSockAddrToString(&local_addr));
return INVALID_SOCK_FD;