Skip to content
Permalink
Browse files

Fix SSL server connections

- Revert previous fix that overwrites servername
- Re-add SSL-enabling check
- Re-add ifdef for IPv6
  • Loading branch information...
vanosg committed Oct 6, 2019
1 parent 449bbf6 commit 645884d3fb8835d944eb488d132994e91c566236
Showing with 19 additions and 20 deletions.
  1. +10 −9 src/mod/server.mod/cmdsserv.c
  2. +9 −11 src/mod/server.mod/servmsg.c
@@ -27,7 +27,7 @@ static void cmd_servers(struct userrec *u, int idx, char *par)
struct server_list *x = serverlist;
time_t t;
struct tm *currtm;
int i, len;
int i, len = 0;
#ifdef IPV6
char buf[sizeof(struct in6_addr)];
#endif
@@ -41,19 +41,20 @@ static void cmd_servers(struct userrec *u, int idx, char *par)
dprintf(idx, "Server list:\n");
i = 0;
for (; x; x = x->next) {
len = 0;
/* Build server display line, section by section */
#ifdef IPV6
if (inet_pton(AF_INET6, x->name, buf) == 1) {
len = egg_snprintf(s, sizeof s, " [%s]:", x->name);
len += egg_snprintf(s, sizeof s, " [%s]:", x->name);
} else {
#endif
len = egg_snprintf(s, sizeof s, " %s:", x->name);
len += egg_snprintf(s, sizeof s, " %s:", x->name);
#ifdef IPV6
}
#endif

#ifdef TLS
len += egg_snprintf(s + len, sizeof s - len, "%s", x->ssl ? "+" : "");
len += egg_snprintf(s+len, sizeof s - len, "%s", x->ssl ? "+" : "");
#endif
if (x->pass) {
t = time(NULL);
@@ -67,12 +68,12 @@ static void cmd_servers(struct userrec *u, int idx, char *par)
strlcpy(setpass, "", sizeof setpass);
}
if ((i == curserv) && realservername) {
egg_snprintf(s + len, sizeof s - len, "%d (%s) <- I am here",
x->port ? x->port : default_port, setpass, realservername);
len += egg_snprintf(s+len, sizeof s - len, "%d (%s) <- I am here",
x->port ? x->port : default_port, setpass, realservername);
} else {
egg_snprintf(s + len, sizeof s - len, "%d %s",
x->port ? x->port : default_port, setpass,
(i == curserv) ? "<- I am here" : "");
len += egg_snprintf(s+len, sizeof s - len, "%d %s",
x->port ? x->port : default_port, setpass,
(i == curserv) ? "<- I am here" : "");
}
dprintf(idx, "%s\n", s);
i++;
@@ -1536,18 +1536,15 @@ static void server_resolve_failure(int);
*/
static void connect_server(void)
{
char pass[121], botserver[UHOSTLEN], s[1024];
#ifdef IPV6
char buf[sizeof(struct in6_addr)];
#endif
char pass[121], botserver[UHOSTLEN], buf[16], s[1024];
int servidx, len = 0;
unsigned int botserverport = 0;

lastpingcheck = 0;
trying_server = now;
empty_msgq();
if (newserverport) { /* Jump to specified server */
curserv = -1; /* Reset server list */
if (newserverport) { /* Jump to specified server */
curserv = -1; /* Reset server list */
strcpy(botserver, newserver);
botserverport = newserverport;
strcpy(pass, newserverpass);
@@ -1583,19 +1580,20 @@ static void connect_server(void)

#ifdef IPV6
if (inet_pton(AF_INET6, botserver, buf)) {
egg_snprintf(s, sizeof s, "%s [%s]", IRC_SERVERTRY, botserver);
len += egg_snprintf(s, sizeof s, "%s [%s]", IRC_SERVERTRY, botserver);
} else {
#endif
egg_snprintf(s, sizeof s, "%s %s", IRC_SERVERTRY, botserver);
len += egg_snprintf(s, sizeof s, "%s %s", IRC_SERVERTRY, botserver);
#ifdef IPV6
}
#endif

#ifdef TLS
egg_snprintf(s + len, sizeof s - len, ":%s%d",
use_ssl ? "+" : "", botserverport);
len += egg_snprintf(s + len, sizeof s - len, ":%s%d",
use_ssl ? "+" : "", botserverport);
dcc[servidx].ssl = use_ssl;
#else
egg_snprintf(s + len, sizeof s - len, ":%d", botserverport);
len += egg_snprintf(s + len, sizeof s - len, ":%d", botserverport);
#endif
putlog(LOG_SERV, "*", "%s", s);
dcc[servidx].port = botserverport;

0 comments on commit 645884d

Please sign in to comment.
You can’t perform that action at this time.