Skip to content

Commit

Permalink
Improve logging of pull request.
Browse files Browse the repository at this point in the history
Improve handling of invalid combinations of listener address and bind
interface configurations. Closes #2081.
  • Loading branch information
ralight committed Mar 11, 2021
1 parent 095d6e1 commit f4d088b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Expand Up @@ -20,6 +20,8 @@ Broker:
- Fix QoS 0 messages not being delivered when max_queued_bytes was configured.
Closes #2123.
- Fix bridge increasing backoff calculation.
- Improve handling of invalid combinations of listener address and bind
interface configurations. Closes #2081.

Client library:
- Fix encrypted connections incorrectly connecting when the CA file passed to
Expand Down
12 changes: 9 additions & 3 deletions src/net.c
Expand Up @@ -628,7 +628,10 @@ static int net__bind_interface(struct mosquitto__listener *listener, struct addr
memcmp(&((struct sockaddr_in *)rp->ai_addr)->sin_addr,
&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr,
sizeof(struct in_addr))){
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Interface address does not match specified listener host.");

log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Interface address for %s does not match specified listener address (%s).",
listener->bind_interface, listener->host);
return MOSQ_ERR_INVAL;
}else{
memcpy(&((struct sockaddr_in *)rp->ai_addr)->sin_addr,
&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr,
Expand All @@ -642,7 +645,10 @@ static int net__bind_interface(struct mosquitto__listener *listener, struct addr
memcmp(&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr,
&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr,
sizeof(struct in6_addr))){
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Interface address does not match specified listener host.");

log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Interface address for %s does not match specified listener address (%s).",
listener->bind_interface, listener->host);
return MOSQ_ERR_INVAL;
}else{
memcpy(&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr,
&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr,
Expand All @@ -655,7 +661,7 @@ static int net__bind_interface(struct mosquitto__listener *listener, struct addr
}
freeifaddrs(ifaddr);
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Interface %s does not support %s configuration.",
listener->bind_interface, rp->ai_addr->sa_family == AF_INET ? "ipv4" : "ipv6");
listener->bind_interface, rp->ai_addr->sa_family == AF_INET ? "IPv4" : "IPv6");
return MOSQ_ERR_NOT_FOUND;
}
#endif
Expand Down

0 comments on commit f4d088b

Please sign in to comment.