1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 09:50:29 +00:00

IRC_SERVER(): Code cleanup

This commit is contained in:
Alexander Barton 2013-08-07 00:13:08 +02:00
parent 904c8a4375
commit 298158501d

View File

@ -188,30 +188,47 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
/* check for existing server with same ID */ /* check for existing server with same ID */
if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED; if (!Client_CheckID(Client, Req->argv[0]))
return DISCONNECTED;
from = Client_Search( Req->prefix ); from = Client_Search( Req->prefix );
if( ! from ) if (! from) {
{
/* Uh, Server, that introduced the new server is unknown?! */ /* Uh, Server, that introduced the new server is unknown?! */
Log( LOG_ALERT, "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)", Req->prefix, Client_Conn( Client )); Log(LOG_ALERT,
Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", true); "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)",
Req->prefix, Client_Conn(Client));
Conn_Close(Client_Conn(Client), NULL,
"Unknown ID in prefix of SERVER", true);
return DISCONNECTED; return DISCONNECTED;
} }
c = Client_NewRemoteServer(Client, Req->argv[0], from, atoi(Req->argv[1]), atoi(Req->argv[2]), Req->argv[3], true); c = Client_NewRemoteServer(Client, Req->argv[0], from,
atoi(Req->argv[1]), atoi(Req->argv[2]),
Req->argv[3], true);
if (!c) { if (!c) {
Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client )); Log(LOG_ALERT,
Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", true); "Can't create client structure for server! (on connection %d)",
Client_Conn(Client));
Conn_Close(Client_Conn(Client), NULL,
"Can't allocate client structure for remote server",
true);
return DISCONNECTED; return DISCONNECTED;
} }
if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) snprintf( str, sizeof( str ), "connected to %s, ", Client_ID( from )); if (Client_Hops(c) > 1 && Req->prefix[0])
else strcpy( str, "" ); snprintf(str, sizeof(str), "connected to %s, ",
Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" ); Client_ID(from));
else
strcpy(str, "");
Log(LOG_NOTICE|LOG_snotice,
"Server \"%s\" registered (via %s, %s%d hop%s).",
Client_ID(c), Client_ID(Client), str, Client_Hops(c),
Client_Hops(c) > 1 ? "s": "" );
/* notify other servers */ /* notify other servers */
IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c )); IRC_WriteStrServersPrefix(Client, from, "SERVER %s %d %d :%s",
Client_ID(c), Client_Hops(c) + 1,
Client_MyToken(c), Client_Info(c));
return CONNECTED; return CONNECTED;
} else } else