unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
netinfo.c (4422B)
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_netinfo); 26 27 #define MSG_NETINFO "NETINFO" 28 29 ModuleHeader MOD_HEADER 30 = { 31 "netinfo", 32 "5.0", 33 "command /netinfo", 34 "UnrealIRCd Team", 35 "unrealircd-6", 36 }; 37 38 MOD_INIT() 39 { 40 CommandAdd(modinfo->handle, MSG_NETINFO, cmd_netinfo, MAXPARA, CMD_SERVER); 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 /** NETINFO: Share configuration settings with directly linked server. 56 * Originally written by Stskeeps 57 * 58 * Technical documentation: 59 * https://www.unrealircd.org/docs/Server_protocol:NETINFO_command 60 * 61 * parv[1] = max global count 62 * parv[2] = time of end sync 63 * parv[3] = unreal protocol using (numeric) 64 * parv[4] = cloak key check (> u2302) 65 * parv[5] = free(**) 66 * parv[6] = free(**) 67 * parv[7] = free(**) 68 * parv[8] = network name 69 */ 70 CMD_FUNC(cmd_netinfo) 71 { 72 long lmax; 73 long endsync, protocol; 74 char buf[512]; 75 76 if (parc < 9) 77 return; 78 79 /* Only allow from directly connected servers */ 80 if (!MyConnect(client)) 81 return; 82 83 if (IsNetInfo(client)) 84 { 85 unreal_log(ULOG_WARNING, "link", "NETINFO_ALREADY_RECEIVED", client, 86 "Got NETINFO from server $client, but we already received it earlier!"); 87 return; 88 } 89 90 /* is a long therefore not ATOI */ 91 lmax = atol(parv[1]); 92 endsync = atol(parv[2]); 93 protocol = atol(parv[3]); 94 95 /* max global count != max_global_count --sts */ 96 if (lmax > irccounts.global_max) 97 { 98 irccounts.global_max = lmax; 99 unreal_log(ULOG_INFO, "link", "NEW_GLOBAL_RECORD", client, 100 "Record global users is now $record_global_users (set by server $client)", 101 log_data_integer("record_global_users", lmax)); 102 } 103 104 unreal_log(ULOG_INFO, "link", "SERVER_SYNCED", client, 105 "Link $client -> $me is now synced " 106 "[secs: $synced_after_seconds, recv: $received_bytes, sent: $sent_bytes]", 107 log_data_client("me", &me), 108 log_data_integer("synced_after_seconds", TStime() - endsync), 109 log_data_integer("received_bytes", client->local->traffic.bytes_received), 110 log_data_integer("sent_bytes", client->local->traffic.bytes_sent)); 111 112 if (!(strcmp(NETWORK_NAME, parv[8]) == 0)) 113 { 114 unreal_log(ULOG_WARNING, "link", "NETWORK_NAME_MISMATCH", client, 115 "Network name mismatch: server $client has '$their_network_name', " 116 "server $me has '$our_network_name'.", 117 log_data_client("me", &me), 118 log_data_string("their_network_name", parv[8]), 119 log_data_string("our_network_name", NETWORK_NAME)); 120 } 121 122 if ((protocol != UnrealProtocol) && (protocol != 0)) 123 { 124 unreal_log(ULOG_INFO, "link", "LINK_PROTOCOL_MISMATCH", client, 125 "Server $client is running UnrealProtocol $their_link_protocol, " 126 "server $me uses $our_link_protocol.", 127 log_data_client("me", &me), 128 log_data_integer("their_link_protocol", protocol), 129 log_data_integer("our_link_protocol", UnrealProtocol)); 130 } 131 strlcpy(buf, CLOAK_KEY_CHECKSUM, sizeof(buf)); 132 if (*parv[4] != '*' && strcmp(buf, parv[4])) 133 { 134 unreal_log(ULOG_WARNING, "link", "CLOAK_KEY_MISMATCH", client, 135 "Server $client has a DIFFERENT CLOAK KEY (OR METHOD)!!! You should fix this ASAP!\n" 136 "When the cloaking configuration is different on servers, this will cause " 137 "channel bans on cloaked hosts/IPs not to work correctly, " 138 "meaning users can bypass channel bans!"); 139 } 140 SetNetInfo(client); 141 }