Permalink
Browse files

Connect to IP of the already-active link for userfile xfer. Fixes #21

Found by: Darkreap1, simple
Patch by: Cizzle

A leaf will now use the address of the hub (to which it's already successfully connected) instead of the IP given by the hub which was wrong in certain cases (especially in NAT situations). Backward compatibility is kept, older bots still get the IP given by the hub.
  • Loading branch information...
Cizzle authored and vanosg committed Nov 11, 2017
1 parent 11d431e commit 797cda2d97b63c3449eb5f4318071d246530c56d
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/mod/share.mod/share.c
View
@@ -1166,7 +1166,7 @@ static void share_userfileq(int idx, char *par)
*/
static void share_ufsend(int idx, char *par)
{
char *ip = NULL, *port;
char *port;
char s[1024];
int i, sock;
FILE *f;
@@ -1184,17 +1184,20 @@ static void share_ufsend(int idx, char *par)
putlog(LOG_MISC, "*", "CAN'T WRITE USERFILE DOWNLOAD FILE!");
zapfbot(idx);
} else {
ip = newsplit(&par);
/* Ignore longip and use botaddr, arg kept for backward compat for pre 1.8.3 */
newsplit(&par);
port = newsplit(&par);
i = new_dcc(&DCC_FORK_SEND, sizeof(struct xfer_info));
/* Use same addr we succesfully linked to and change port */
memcpy(&dcc[i].sockname, &dcc[idx].sockname, sizeof dcc[i].sockname);
dcc[i].port = atoi(port);
(void) setsockname(&dcc[i].sockname, ip, dcc[i].port, 0);
setsnport(dcc[i].sockname, dcc[i].port);
/* Don't buffer this -> mark binary. */
sock = getsock(dcc[i].sockname.family, SOCK_BINARY);
#ifdef TLS
if (sock < 0 || (open_telnet_raw(sock, &dcc[i].sockname) < 0) ||
(*port == '+' && ssl_handshake(sock, TLS_CONNECT, tls_vfybots,
LOG_MISC, ip, NULL))) {
LOG_MISC, dcc[i].host, NULL))) {
#else
if (sock < 0 || open_telnet_raw(sock, &dcc[i].sockname) < 0) {
#endif

0 comments on commit 797cda2

Please sign in to comment.