+ if (Client_Type(Client) != CLIENT_SERVER
+ && !Client_HasMode(Client, 'o'))
+ return Op_NoPrivileges(Client, Req);
+
+ from = Client;
+ target = Client_ThisServer();
+
+ if (Req->argc == 3 || Req->argc == 6) {
+ /* This CONNECT has a target parameter */
+ if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
+ from = Client_Search(Req->prefix);
+ if (! from)
+ return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
+ Client_ID(Client), Req->prefix);
+
+ target = (Req->argc == 3) ? Client_Search(Req->argv[2])
+ : Client_Search(Req->argv[5]);
+ if (! target || Client_Type(target) != CLIENT_SERVER)
+ return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
+ Client_ID(from), Req->argv[0]);
+ }
+
+ if (target != Client_ThisServer()) {
+ /* Forward CONNECT command ... */
+ if (Req->argc == 3)
+ IRC_WriteStrClientPrefix(target, from,
+ "CONNECT %s %s :%s", Req->argv[0],
+ Req->argv[1], Req->argv[2]);
+ else
+ IRC_WriteStrClientPrefix(target, from,
+ "CONNECT %s %s %s %s %s :%s", Req->argv[0],
+ Req->argv[1], Req->argv[2], Req->argv[3],
+ Req->argv[4], Req->argv[5]);
+ return CONNECTED;
+ }
+
+ if (!Op_Check(from, Req))
+ return Op_NoPrivileges(Client, Req);