Can bind to specific IP
FossilOrigin-Name: 680179a5bda1f25d5acd84edb25026e6896cd5675afa0d26157bad4802c7853d
This commit is contained in:
parent
c6e06e4953
commit
138bd501d0
@ -223,6 +223,19 @@ static int cw_run_discovery(struct conn *conn, const char *acaddr)
|
||||
sock_set_dontfrag(sockfd, 0);
|
||||
|
||||
sock_copyaddr(&conn->addr, res->ai_addr);
|
||||
|
||||
|
||||
if (conf_ip){
|
||||
struct sockaddr bind_address;
|
||||
sock_strtoaddr(conf_ip,&bind_address);
|
||||
int brc = bind(sockfd,&bind_address,sock_addrlen(&bind_address));
|
||||
if (brc<0) {
|
||||
cw_log(LOG_ERR,"Can't bind to %s",sock_addr2str(&bind_address));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
conn->sock = sockfd;
|
||||
conn->readfrom = conn_recvfrom_packet;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user