mirror of
https://github.com/matrix-construct/construct
synced 2024-08-20 00:24:44 +02:00
show_capabilities cleanup and now show whether we are TS or TS6 and SSL link
This commit is contained in:
parent
bbe968ca0c
commit
f4a759c560
135
src/s_serv.c
135
src/s_serv.c
|
@ -238,8 +238,8 @@ try_connections(void *unused)
|
|||
if(ServerConfIllegal(tmp_p) || !ServerConfAutoconn(tmp_p))
|
||||
continue;
|
||||
|
||||
/* don't allow ssl connections if ssl isn't setup */
|
||||
if(ServerConfSSL(tmp_p) && (!ssl_ok || !get_ssld_count()))
|
||||
/* don't allow ssl connections if ssl isn't setup */
|
||||
if(ServerConfSSL(tmp_p) && (!ssl_ok || !get_ssld_count()))
|
||||
continue;
|
||||
|
||||
cltmp = tmp_p->class;
|
||||
|
@ -369,9 +369,9 @@ check_server(const char *name, struct Client *client_p)
|
|||
if(server_p == NULL)
|
||||
return error;
|
||||
|
||||
if(ServerConfSSL(server_p) && client_p->localClient->ssl_ctl == NULL)
|
||||
{
|
||||
return -5;
|
||||
if(ServerConfSSL(server_p) && client_p->localClient->ssl_ctl == NULL)
|
||||
{
|
||||
return -5;
|
||||
}
|
||||
|
||||
attach_server_conf(client_p, server_p);
|
||||
|
@ -838,32 +838,25 @@ show_capabilities(struct Client *target_p)
|
|||
{
|
||||
static char msgbuf[BUFSIZE];
|
||||
struct Capability *cap;
|
||||
char *t;
|
||||
int tl;
|
||||
|
||||
t = msgbuf;
|
||||
tl = rb_sprintf(msgbuf, "TS ");
|
||||
t += tl;
|
||||
if(has_id(target_p))
|
||||
rb_strlcpy(msgbuf, " TS6", sizeof(msgbuf));
|
||||
else
|
||||
rb_strlcpy(msgbuf, " TS", sizeof(msgbuf));
|
||||
|
||||
if(IsSSL(target_p))
|
||||
rb_strlcat(msgbuf, " SSL", sizeof(msgbuf));
|
||||
|
||||
if(!IsServer(target_p) || !target_p->serv->caps) /* short circuit if no caps */
|
||||
{
|
||||
msgbuf[2] = '\0';
|
||||
return msgbuf;
|
||||
}
|
||||
return msgbuf + 1;
|
||||
|
||||
for (cap = captab; cap->cap; ++cap)
|
||||
{
|
||||
if(cap->cap & target_p->serv->caps)
|
||||
{
|
||||
tl = rb_sprintf(t, "%s ", cap->name);
|
||||
t += tl;
|
||||
}
|
||||
rb_snprintf_append(msgbuf, sizeof(msgbuf), " %s", cap->name);
|
||||
}
|
||||
|
||||
t--;
|
||||
*t = '\0';
|
||||
|
||||
return msgbuf;
|
||||
return msgbuf + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -950,10 +943,10 @@ server_estab(struct Client *client_p)
|
|||
ilog_error("rb_set_buffers failed for server");
|
||||
|
||||
/* Enable compression now */
|
||||
if(IsCapable(client_p, CAP_ZIP))
|
||||
{
|
||||
start_zlib_session(client_p);
|
||||
}
|
||||
if(IsCapable(client_p, CAP_ZIP))
|
||||
{
|
||||
start_zlib_session(client_p);
|
||||
}
|
||||
sendto_one(client_p, "SVINFO %d %d 0 :%ld", TS_CURRENT, TS_MIN, rb_current_time());
|
||||
|
||||
client_p->servptr = &me;
|
||||
|
@ -1009,7 +1002,7 @@ server_estab(struct Client *client_p)
|
|||
hdata.target = client_p;
|
||||
call_hook(h_server_introduced, &hdata);
|
||||
|
||||
rb_snprintf(note, sizeof(note), "Server: %s", client_p->name);
|
||||
rb_snprintf(note, sizeof(note), "Server: %s", client_p->name);
|
||||
rb_note(client_p->localClient->F, note);
|
||||
|
||||
/*
|
||||
|
@ -1103,7 +1096,7 @@ server_estab(struct Client *client_p)
|
|||
|
||||
free_pre_client(client_p);
|
||||
|
||||
if (!IsCapable(client_p, CAP_ZIP))
|
||||
if (!IsCapable(client_p, CAP_ZIP))
|
||||
send_pop_queue(client_p);
|
||||
|
||||
return 0;
|
||||
|
@ -1171,15 +1164,15 @@ serv_connect_resolved(struct Client *client_p)
|
|||
#endif
|
||||
(server_p->aftype == AF_INET ? "IPv4" : "?"));
|
||||
|
||||
if(ServerConfSSL(server_p))
|
||||
{
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
NULL, 0, serv_connect_ssl_callback,
|
||||
client_p, ConfigFileEntry.connect_timeout);
|
||||
}
|
||||
else
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
NULL, 0, serv_connect_callback,
|
||||
if(ServerConfSSL(server_p))
|
||||
{
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
NULL, 0, serv_connect_ssl_callback,
|
||||
client_p, ConfigFileEntry.connect_timeout);
|
||||
}
|
||||
else
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
NULL, 0, serv_connect_callback,
|
||||
client_p, ConfigFileEntry.connect_timeout);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1193,15 +1186,15 @@ serv_connect_resolved(struct Client *client_p)
|
|||
(server_p->aftype == AF_INET ? "IPv4" : "?"), vhoststr);
|
||||
|
||||
|
||||
if(ServerConfSSL(server_p))
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
(struct sockaddr *) &myipnum,
|
||||
GET_SS_LEN(&myipnum), serv_connect_ssl_callback, client_p,
|
||||
ConfigFileEntry.connect_timeout);
|
||||
else
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
(struct sockaddr *) &myipnum,
|
||||
GET_SS_LEN(&myipnum), serv_connect_callback, client_p,
|
||||
if(ServerConfSSL(server_p))
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
(struct sockaddr *) &myipnum,
|
||||
GET_SS_LEN(&myipnum), serv_connect_ssl_callback, client_p,
|
||||
ConfigFileEntry.connect_timeout);
|
||||
else
|
||||
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
|
||||
(struct sockaddr *) &myipnum,
|
||||
GET_SS_LEN(&myipnum), serv_connect_callback, client_p,
|
||||
ConfigFileEntry.connect_timeout);
|
||||
|
||||
return 1;
|
||||
|
@ -1386,32 +1379,32 @@ serv_connect(struct server_conf *server_p, struct Client *by)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
serv_connect_ev(void *data)
|
||||
{
|
||||
struct Client *client_p = data;
|
||||
serv_connect_callback(client_p->localClient->F, RB_OK, client_p);
|
||||
static void
|
||||
serv_connect_ev(void *data)
|
||||
{
|
||||
struct Client *client_p = data;
|
||||
serv_connect_callback(client_p->localClient->F, RB_OK, client_p);
|
||||
}
|
||||
|
||||
static void
|
||||
serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
|
||||
{
|
||||
struct Client *client_p = data;
|
||||
rb_fde_t *xF[2];
|
||||
if(status != RB_OK)
|
||||
{
|
||||
/* XXX deal with failure */
|
||||
return;
|
||||
}
|
||||
rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
|
||||
rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Outgoing ssld connection");
|
||||
del_from_cli_fd_hash(client_p);
|
||||
client_p->localClient->F = xF[0];
|
||||
add_to_cli_fd_hash(client_p);
|
||||
|
||||
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0]));
|
||||
SetSSL(client_p);
|
||||
rb_event_addonce("serv_connect_ev", serv_connect_ev, client_p, 1);
|
||||
static void
|
||||
serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
|
||||
{
|
||||
struct Client *client_p = data;
|
||||
rb_fde_t *xF[2];
|
||||
if(status != RB_OK)
|
||||
{
|
||||
/* XXX deal with failure */
|
||||
return;
|
||||
}
|
||||
rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
|
||||
rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Outgoing ssld connection");
|
||||
del_from_cli_fd_hash(client_p);
|
||||
client_p->localClient->F = xF[0];
|
||||
add_to_cli_fd_hash(client_p);
|
||||
|
||||
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0]));
|
||||
SetSSL(client_p);
|
||||
rb_event_addonce("serv_connect_ev", serv_connect_ev, client_p, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1446,7 +1439,7 @@ serv_connect_callback(rb_fde_t *F, int status, void *data)
|
|||
return;
|
||||
}
|
||||
|
||||
if(client_p->localClient->ssl_ctl == NULL)
|
||||
if(client_p->localClient->ssl_ctl == NULL)
|
||||
rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
|
||||
|
||||
/* Check the status */
|
||||
|
|
Loading…
Reference in a new issue