Skip to content

Commit

Permalink
Enhance log
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Jul 3, 2024
1 parent 5ddb7cf commit 7e5ef67
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/tcldcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,37 +1107,39 @@ static int setlisten(Tcl_Interp *irp, char *ip, char *portp, char *type, char *m
/* Check if IP is specific, but the already-bound IP is all-interfaces */
if (ipv4) {
if ((ipaddr4.s_addr != 0) && (dcc[idx].sockname.addr.s4.sin_addr.s_addr == 0)) {
Tcl_AppendResult(irp, "this port is already bound to 0.0.0.0 on this "
"machine, remove it before trying to bind to this IP", NULL);
Tcl_AppendResult(irp, "This port is already bound to 0.0.0.0 on this "
"machine, remove it (using listen [ip] <port> off) before "
"trying to bind to this IP.", NULL);
return TCL_ERROR;
}
}
#ifdef IPV6
else if ((!IN6_IS_ADDR_UNSPECIFIED(&ipaddr6)) &&
(IN6_IS_ADDR_UNSPECIFIED(&dcc[idx].sockname.addr.s6.sin6_addr))) {
Tcl_AppendResult(irp, "this port is already bound to :: on this "
"machine, remove it before trying to bind to this IP", NULL);
Tcl_AppendResult(irp, "This port is already bound to :: on this "
"machine, remove it (using listen [ip] <port> off) before "
"trying to bind to this IP.", NULL);
return TCL_ERROR;
}
#endif

/* Check if IP is all-interfaces, but the already-bound IP is specific */
if (ipv4) {
if ((ipaddr4.s_addr == 0) && (dcc[idx].sockname.addr.s4.sin_addr.s_addr != 0)) {
Tcl_AppendResult(irp, "this port is already bound to specific IP ",
Tcl_AppendResult(irp, "This port is already bound to specific IP ",
inet_ntop(AF_INET, &dcc[idx].sockname.addr.s4.sin_addr, newip, sizeof newip),
" on this machine, remove it before trying to bind to all "
"interfaces", NULL);
" on this machine, remove it (using listen [ip] <port> off) "
"before trying to bind to all interfaces.", NULL);
return TCL_ERROR;
}
}
#ifdef IPV6
else if (IN6_IS_ADDR_UNSPECIFIED(&ipaddr6) &&
(!IN6_IS_ADDR_UNSPECIFIED(&dcc[idx].sockname.addr.s6.sin6_addr))) {
Tcl_AppendResult(irp, "this port is already bound to specific IP ",
Tcl_AppendResult(irp, "This port is already bound to specific IP ",
inet_ntop(AF_INET6, &dcc[idx].sockname.addr.s6.sin6_addr, newip, sizeof newip),
" on this machine, remove it before trying to bind to all "
"interfaces", NULL);
" on this machine, remove it (using listen [ip] <port> off) "
"before trying to bind to all interfaces", NULL);
return TCL_ERROR;
}
#endif
Expand All @@ -1153,7 +1155,7 @@ static int setlisten(Tcl_Interp *irp, char *ip, char *portp, char *type, char *m
}
/* Remove */
if (idx < 0) {
Tcl_AppendResult(irp, "no such listen port is open", NULL);
Tcl_AppendResult(irp, "no such listen ip/port is open", NULL);
return TCL_ERROR;
}
killsock(dcc[idx].sock);
Expand Down

0 comments on commit 7e5ef67

Please sign in to comment.