show_capabilities cleanup and now show whether we are TS or TS6 and SSL link

This commit is contained in:
Valery Yatsko 2008-04-07 20:21:09 +04:00
parent bbe968ca0c
commit f4a759c560

View file

@ -238,8 +238,8 @@ try_connections(void *unused)
if(ServerConfIllegal(tmp_p) || !ServerConfAutoconn(tmp_p)) if(ServerConfIllegal(tmp_p) || !ServerConfAutoconn(tmp_p))
continue; continue;
/* don't allow ssl connections if ssl isn't setup */ /* don't allow ssl connections if ssl isn't setup */
if(ServerConfSSL(tmp_p) && (!ssl_ok || !get_ssld_count())) if(ServerConfSSL(tmp_p) && (!ssl_ok || !get_ssld_count()))
continue; continue;
cltmp = tmp_p->class; cltmp = tmp_p->class;
@ -369,9 +369,9 @@ check_server(const char *name, struct Client *client_p)
if(server_p == NULL) if(server_p == NULL)
return error; return error;
if(ServerConfSSL(server_p) && client_p->localClient->ssl_ctl == NULL) if(ServerConfSSL(server_p) && client_p->localClient->ssl_ctl == NULL)
{ {
return -5; return -5;
} }
attach_server_conf(client_p, server_p); attach_server_conf(client_p, server_p);
@ -838,32 +838,25 @@ show_capabilities(struct Client *target_p)
{ {
static char msgbuf[BUFSIZE]; static char msgbuf[BUFSIZE];
struct Capability *cap; struct Capability *cap;
char *t;
int tl;
t = msgbuf; if(has_id(target_p))
tl = rb_sprintf(msgbuf, "TS "); rb_strlcpy(msgbuf, " TS6", sizeof(msgbuf));
t += tl; 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 */ if(!IsServer(target_p) || !target_p->serv->caps) /* short circuit if no caps */
{ return msgbuf + 1;
msgbuf[2] = '\0';
return msgbuf;
}
for (cap = captab; cap->cap; ++cap) for (cap = captab; cap->cap; ++cap)
{ {
if(cap->cap & target_p->serv->caps) if(cap->cap & target_p->serv->caps)
{ rb_snprintf_append(msgbuf, sizeof(msgbuf), " %s", cap->name);
tl = rb_sprintf(t, "%s ", cap->name);
t += tl;
}
} }
t--; return msgbuf + 1;
*t = '\0';
return msgbuf;
} }
/* /*
@ -950,10 +943,10 @@ server_estab(struct Client *client_p)
ilog_error("rb_set_buffers failed for server"); ilog_error("rb_set_buffers failed for server");
/* Enable compression now */ /* Enable compression now */
if(IsCapable(client_p, CAP_ZIP)) if(IsCapable(client_p, CAP_ZIP))
{ {
start_zlib_session(client_p); start_zlib_session(client_p);
} }
sendto_one(client_p, "SVINFO %d %d 0 :%ld", TS_CURRENT, TS_MIN, rb_current_time()); sendto_one(client_p, "SVINFO %d %d 0 :%ld", TS_CURRENT, TS_MIN, rb_current_time());
client_p->servptr = &me; client_p->servptr = &me;
@ -1009,7 +1002,7 @@ server_estab(struct Client *client_p)
hdata.target = client_p; hdata.target = client_p;
call_hook(h_server_introduced, &hdata); 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); rb_note(client_p->localClient->F, note);
/* /*
@ -1103,7 +1096,7 @@ server_estab(struct Client *client_p)
free_pre_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); send_pop_queue(client_p);
return 0; return 0;
@ -1171,15 +1164,15 @@ serv_connect_resolved(struct Client *client_p)
#endif #endif
(server_p->aftype == AF_INET ? "IPv4" : "?")); (server_p->aftype == AF_INET ? "IPv4" : "?"));
if(ServerConfSSL(server_p)) if(ServerConfSSL(server_p))
{ {
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip, rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
NULL, 0, serv_connect_ssl_callback, NULL, 0, serv_connect_ssl_callback,
client_p, ConfigFileEntry.connect_timeout); client_p, ConfigFileEntry.connect_timeout);
} }
else else
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip, rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
NULL, 0, serv_connect_callback, NULL, 0, serv_connect_callback,
client_p, ConfigFileEntry.connect_timeout); client_p, ConfigFileEntry.connect_timeout);
return 1; return 1;
} }
@ -1193,15 +1186,15 @@ serv_connect_resolved(struct Client *client_p)
(server_p->aftype == AF_INET ? "IPv4" : "?"), vhoststr); (server_p->aftype == AF_INET ? "IPv4" : "?"), vhoststr);
if(ServerConfSSL(server_p)) if(ServerConfSSL(server_p))
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip, rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
(struct sockaddr *) &myipnum, (struct sockaddr *) &myipnum,
GET_SS_LEN(&myipnum), serv_connect_ssl_callback, client_p, GET_SS_LEN(&myipnum), serv_connect_ssl_callback, client_p,
ConfigFileEntry.connect_timeout); ConfigFileEntry.connect_timeout);
else else
rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip, rb_connect_tcp(client_p->localClient->F, (struct sockaddr *)&client_p->localClient->ip,
(struct sockaddr *) &myipnum, (struct sockaddr *) &myipnum,
GET_SS_LEN(&myipnum), serv_connect_callback, client_p, GET_SS_LEN(&myipnum), serv_connect_callback, client_p,
ConfigFileEntry.connect_timeout); ConfigFileEntry.connect_timeout);
return 1; return 1;
@ -1386,32 +1379,32 @@ serv_connect(struct server_conf *server_p, struct Client *by)
} }
} }
static void static void
serv_connect_ev(void *data) serv_connect_ev(void *data)
{ {
struct Client *client_p = data; struct Client *client_p = data;
serv_connect_callback(client_p->localClient->F, RB_OK, client_p); serv_connect_callback(client_p->localClient->F, RB_OK, client_p);
} }
static void static void
serv_connect_ssl_callback(rb_fde_t *F, int status, void *data) serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
{ {
struct Client *client_p = data; struct Client *client_p = data;
rb_fde_t *xF[2]; rb_fde_t *xF[2];
if(status != RB_OK) if(status != RB_OK)
{ {
/* XXX deal with failure */ /* XXX deal with failure */
return; return;
} }
rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip)); 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"); rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Outgoing ssld connection");
del_from_cli_fd_hash(client_p); del_from_cli_fd_hash(client_p);
client_p->localClient->F = xF[0]; client_p->localClient->F = xF[0];
add_to_cli_fd_hash(client_p); add_to_cli_fd_hash(client_p);
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0])); client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0]));
SetSSL(client_p); SetSSL(client_p);
rb_event_addonce("serv_connect_ev", serv_connect_ev, client_p, 1); 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; 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)); rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
/* Check the status */ /* Check the status */