unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
connect.c (3229B)
1 /* 2 * IRC - Internet Relay Chat, src/modules/out.c 3 * (C) 2004 The UnrealIRCd Team 4 * 5 * See file AUTHORS in IRC package for additional names of 6 * the programmers. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 1, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 #include "unrealircd.h" 24 25 CMD_FUNC(cmd_connect); 26 27 #define MSG_CONNECT "CONNECT" 28 29 ModuleHeader MOD_HEADER 30 = { 31 "connect", 32 "5.0", 33 "command /connect", 34 "UnrealIRCd Team", 35 "unrealircd-6", 36 }; 37 38 MOD_INIT() 39 { 40 CommandAdd(modinfo->handle, MSG_CONNECT, cmd_connect, MAXPARA, CMD_USER|CMD_SERVER); /* hmm.. server.. really? */ 41 MARK_AS_OFFICIAL_MODULE(modinfo); 42 return MOD_SUCCESS; 43 } 44 45 MOD_LOAD() 46 { 47 return MOD_SUCCESS; 48 } 49 50 MOD_UNLOAD() 51 { 52 return MOD_SUCCESS; 53 } 54 55 /*********************************************************************** 56 * cmd_connect() - Added by Jto 11 Feb 1989 57 ***********************************************************************//* 58 ** cmd_connect 59 ** parv[1] = servername 60 */ 61 CMD_FUNC(cmd_connect) 62 { 63 int retval; 64 ConfigItem_link *aconf; 65 Client *server; 66 const char *str; 67 68 if (!IsServer(client) && MyConnect(client) && !ValidatePermissionsForPath("route:global",client,NULL,NULL,NULL) && parc > 3) 69 { /* Only allow LocOps to make */ 70 /* local CONNECTS --SRB */ 71 sendnumeric(client, ERR_NOPRIVILEGES); 72 return; 73 } 74 if (!IsServer(client) && MyUser(client) && !ValidatePermissionsForPath("route:local",client,NULL,NULL,NULL) && parc <= 3) 75 { 76 sendnumeric(client, ERR_NOPRIVILEGES); 77 return; 78 } 79 if (hunt_server(client, recv_mtags, "CONNECT", 3, parc, parv) != HUNTED_ISME) 80 return; 81 82 if (parc < 2 || *parv[1] == '\0') 83 { 84 sendnumeric(client, ERR_NEEDMOREPARAMS, "CONNECT"); 85 return; 86 } 87 88 if ((server = find_server_quick(parv[1]))) 89 { 90 sendnotice(client, "*** Connect: Server %s already exists from %s.", 91 parv[1], server->direction->name); 92 return; 93 } 94 95 aconf = find_link(parv[1]); 96 if (!aconf) 97 { 98 sendnotice(client, 99 "*** Connect: Server %s is not configured for linking", 100 parv[1]); 101 return; 102 } 103 104 if (!aconf->outgoing.hostname && !aconf->outgoing.file) 105 { 106 sendnotice(client, 107 "*** Connect: Server %s is not configured to be an outgoing link (has a link block, but no link::outgoing::hostname or link::outgoing::file)", 108 parv[1]); 109 return; 110 } 111 112 if ((str = check_deny_link(aconf, 0))) 113 { 114 sendnotice(client, "*** Connect: Disallowed by connection rule: %s", str); 115 return; 116 } 117 118 unreal_log(ULOG_INFO, "link", "LINK_REQUEST", client, 119 "CONNECT: Link to $link_block requested by $client", 120 log_data_link_block(aconf)); 121 122 connect_server(aconf, client, NULL); 123 }