Commit Diff


commit - 69ce65bacb0155be5fb9159a3dfc5c8e3390cc0d
commit + 8e60fac73b791129b69d20c9e5b02ee1e89f6eaa
blob - 37b168ff8d5dac07cb835b86eb37b366da6fcbe3
blob + 73dcfcad107e3ab9be51daef2faf613a334a0151
--- src/ngircd/client.c
+++ src/ngircd/client.c
@@ -1513,9 +1513,6 @@ Destroy_UserOrService(CLIENT *Client, const char *Txt,
 /**
  * Introduce a new user or service client to a remote server.
  *
- * This function differentiates between RFC1459 and RFC2813 server links and
- * generates the appropriate commands to register the new user or service.
- *
  * @param To		The remote server to inform.
  * @param Prefix	Prefix for the generated commands.
  * @param data		CLIENT structure of the new client.
@@ -1524,45 +1521,94 @@ static void
 cb_introduceClient(CLIENT *To, CLIENT *Prefix, void *data)
 {
 	CLIENT *c = (CLIENT *)data;
+
+	(void)Client_Announce(To, Prefix, c);
+
+} /* cb_introduceClient */
+
+
+/**
+ * Announce an user or service to a server.
+ *
+ * This function differentiates between RFC1459 and RFC2813 server links and
+ * generates the appropriate commands to register the user or service.
+ *
+ * @param Client	Server
+ * @param Prefix	Prefix for the generated commands
+ * @param User		User to announce
+ */
+GLOBAL bool
+Client_Announce(CLIENT * Client, CLIENT * Prefix, CLIENT * User)
+{
 	CONN_ID conn;
 	char *modes, *user, *host;
 
-	modes = Client_Modes(c);
-	user = Client_User(c) ? Client_User(c) : "-";
-	host = Client_Hostname(c) ? Client_Hostname(c) : "-";
+	modes = Client_Modes(User);
+	user = Client_User(User) ? Client_User(User) : "-";
+	host = Client_Hostname(User) ? Client_Hostname(User) : "-";
 
-	conn = Client_Conn(To);
+	conn = Client_Conn(Client);
 	if (Conn_Options(conn) & CONN_RFC1459) {
 		/* RFC 1459 mode: separate NICK and USER commands */
-		Conn_WriteStr(conn, "NICK %s :%d", Client_ID(c),
-			      Client_Hops(c) + 1);
-		Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
-			      Client_ID(c), user, host,
-			      Client_ID(Client_Introducer(c)), Client_Info(c));
-		if (modes[0])
-			Conn_WriteStr(conn, ":%s MODE %s +%s",
-				      Client_ID(c), Client_ID(c), modes);
+		if (! Conn_WriteStr(conn, "NICK %s :%d",
+				    Client_ID(User), Client_Hops(User) + 1))
+			return DISCONNECTED;
+		if (! Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
+				     Client_ID(User), user, host,
+				     Client_ID(Client_Introducer(User)),
+				     Client_Info(User)))
+			return DISCONNECTED;
+		if (modes[0]) {
+			if (! Conn_WriteStr(conn, ":%s MODE %s +%s",
+				     Client_ID(User), Client_ID(User),
+				     modes))
+				return DISCONNECTED;
+		}
 	} else {
 		/* RFC 2813 mode: one combined NICK or SERVICE command */
-		if (Client_Type(c) == CLIENT_SERVICE
-		    && strchr(Client_Flags(To), 'S'))
-			IRC_WriteStrClientPrefix(To, Prefix,
-						 "SERVICE %s %d * +%s %d :%s",
-						 Client_Mask(c),
-						 Client_MyToken(Client_Introducer(c)),
-						 Client_Modes(c), Client_Hops(c) + 1,
-						 Client_Info(c));
-		else
-			IRC_WriteStrClientPrefix(To, Prefix,
-						 "NICK %s %d %s %s %d +%s :%s",
-						 Client_ID(c), Client_Hops(c) + 1,
-						 user, host,
-						 Client_MyToken(Client_Introducer(c)),
-						 modes, Client_Info(c));
+		if (Client_Type(User) == CLIENT_SERVICE
+		    && strchr(Client_Flags(Client), 'S')) {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"SERVICE %s %d * +%s %d :%s",
+					Client_Mask(User),
+					Client_MyToken(Client_Introducer(User)),
+					modes, Client_Hops(User) + 1,
+					Client_Info(User)))
+				return DISCONNECTED;
+		} else {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"NICK %s %d %s %s %d +%s :%s",
+					Client_ID(User), Client_Hops(User) + 1,
+					user, host,
+					Client_MyToken(Client_Introducer(User)),
+					modes, Client_Info(User)))
+				return DISCONNECTED;
+		}
 	}
-} /* cb_introduceClient */
 
+	if (strchr(Client_Flags(Client), 'M')) {
+		/* Synchronize metadata */
+		if (Client_HostnameCloaked(User)) {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"METADATA %s cloakhost :%s",
+					Client_ID(User),
+					Client_HostnameCloaked(User)))
+				return DISCONNECTED;
+		}
 
+		if (Conn_GetFingerprint(Client_Conn(User))) {
+			if (!IRC_WriteStrClientPrefix(Client, Prefix,
+					"METADATA %s certfp :%s",
+					Client_ID(User),
+					Conn_GetFingerprint(Client_Conn(User))))
+				return DISCONNECTED;
+		}
+	}
+
+	return CONNECTED;
+} /* Client_Announce */
+
+
 #ifdef DEBUG
 
 GLOBAL void
blob - c248d1ba39756a72a8d7065f6cf1d46349fccdae
blob + 68d411c04f0a1625b9cb714e7d5c6cba5b74dae7
--- src/ngircd/client.h
+++ src/ngircd/client.h
@@ -93,6 +93,8 @@ GLOBAL CLIENT *Client_ThisServer PARAMS(( void ));
 
 GLOBAL CLIENT *Client_GetFromToken PARAMS(( CLIENT *Client, int Token ));
 
+GLOBAL bool Client_Announce PARAMS(( CLIENT *Client, CLIENT *Prefix, CLIENT *User ));
+
 GLOBAL CLIENT *Client_Search PARAMS(( const char *ID ));
 GLOBAL CLIENT *Client_SearchServer PARAMS(( const char *ID ));
 GLOBAL CLIENT *Client_First PARAMS(( void ));
blob - f7f3ac919b8c64e1061896fffacef6056dac3167
blob + 01091edef17272a9bfaf26f67064c709fdc95486
--- src/ngircd/numeric.c
+++ src/ngircd/numeric.c
@@ -148,82 +148,8 @@ Announce_Server(CLIENT * Client, CLIENT * Server)
 		Client_ID(Server), Client_Hops(Server) + 1,
 		Client_MyToken(Server), Client_Info(Server));
 } /* Announce_Server */
-
-
-/**
- * Announce existing user to a new server
- * @param Client New server
- * @param User Existing user in the network
- */
-static bool
-Announce_User(CLIENT * Client, CLIENT * User)
-{
-	CONN_ID conn;
-	char *modes;
-
-	conn = Client_Conn(Client);
-	if (Conn_Options(conn) & CONN_RFC1459) {
-		/* RFC 1459 mode: separate NICK and USER commands */
-		if (! Conn_WriteStr(conn, "NICK %s :%d",
-				    Client_ID(User), Client_Hops(User) + 1))
-			return DISCONNECTED;
-		if (! Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
-				     Client_ID(User), Client_User(User),
-				     Client_Hostname(User),
-				     Client_ID(Client_Introducer(User)),
-				     Client_Info(User)))
-			return DISCONNECTED;
-		modes = Client_Modes(User);
-		if (modes[0]) {
-			return Conn_WriteStr(conn, ":%s MODE %s +%s",
-				     Client_ID(User), Client_ID(User),
-				     modes);
-		}
-	} else {
-		/* RFC 2813 mode: one combined NICK or SERVICE command */
-		if (Client_Type(User) == CLIENT_SERVICE
-		    && strchr(Client_Flags(Client), 'S')) {
-			if (!IRC_WriteStrClient(Client,
-					"SERVICE %s %d * +%s %d :%s",
-					Client_Mask(User),
-					Client_MyToken(Client_Introducer(User)),
-					Client_Modes(User), Client_Hops(User) + 1,
-					Client_Info(User)))
-				return DISCONNECTED;
-		} else {
-			if (!IRC_WriteStrClient(Client,
-					"NICK %s %d %s %s %d +%s :%s",
-					Client_ID(User), Client_Hops(User) + 1,
-					Client_User(User), Client_Hostname(User),
-					Client_MyToken(Client_Introducer(User)),
-					Client_Modes(User), Client_Info(User)))
-				return DISCONNECTED;
-		}
-	}
 
-	if (strchr(Client_Flags(Client), 'M')) {
-		/* Synchronize metadata */
-		if (Client_HostnameCloaked(User)) {
-			if (!IRC_WriteStrClient(Client,
-						"METADATA %s cloakhost :%s",
-						Client_ID(User),
-						Client_HostnameCloaked(User)))
-				return DISCONNECTED;
-		}
-	}
 
-	if (Conn_GetFingerprint(conn)) {
-		if (!IRC_WriteStrClient(Client,
-					"METADATA %s certfp :%s",
-					Client_ID(User),
-					Conn_GetFingerprint(conn)))
-			return DISCONNECTED;
-	}
-
-	return CONNECTED;
-} /* Announce_User */
-
-
 #ifdef IRCPLUS
 
 /**
@@ -380,7 +306,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Re
 	while (c) {
 		if (Client_Type(c) == CLIENT_USER ||
 		    Client_Type(c) == CLIENT_SERVICE) {
-			if (!Announce_User(Client, c))
+			if (!Client_Announce(Client, Client_ThisServer(), c))
 				return DISCONNECTED;
 		}
 		c = Client_Next(c);