| 1 | /* |
| 2 | * Copyright (C) 1999,2000,2001 Ross Combs ([email protected]) |
| 3 | * Copyright (C) 1999 Rob Crittenden ([email protected]) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/ |
| 20 | #include "handle_bot.h"cxx . . $ `<file>/src/bnetd/handle_bot.h`/ |
| 21 | |
| 22 | #include <cstring> |
| 23 | #include <cctype> |
| 24 | |
| 25 | #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/ |
| 26 | #include "common/packet.h"cxx . . $ `<file>/src/common/packet.h`/ |
| 27 | #include "common/bnethash.h"cxx . . $ `<file>/src/common/bnethash.h`/ |
| 28 | #include "common/tag.h"cxx . . $ `<file>/src/common/tag.h`/ |
| 29 | #include "common/xstring.h"cxx . . $ `<file>/src/common/xstring.h`/ |
| 30 | |
| 31 | #include "connection.h"cxx . . $ `<file>/src/bnetd/connection.h`/ |
| 32 | #include "account.h"cxx . . $ `<file>/src/bnetd/account.h`/ |
| 33 | #include "account_wrap.h"cxx . . $ `<file>/src/bnetd/account_wrap.h`/ |
| 34 | #include "message.h"cxx . . $ `<file>/src/bnetd/message.h`/ |
| 35 | #include "channel.h"cxx . . $ `<file>/src/bnetd/channel.h`/ |
| 36 | #include "command.h"cxx . . $ `<file>/src/bnetd/command.h`/ |
| 37 | #ifdef WITH_LUA |
| 38 | #include "luainterface.h" |
| 39 | #endif |
| 40 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 41 | |
| 42 | |
| 43 | namespace pvpgncxx . . $ pvpgn/ |
| 44 | { |
| 45 | |
| 46 | namespace bnetdcxx . . $ pvpgn/bnetd/ |
| 47 | { |
| 48 | |
| 49 | extern int handle_bot_packetcxx . . $ pvpgn/bnetd/handle_bot_packet(8d07eb83d60bed1d).(t_connection * c, t_packetcxx . . $ pvpgn/t_packet# const * const packet) |
| 50 | { |
| 51 | t_packetcxx . . $ pvpgn/t_packet# * rpacket; |
| 52 | |
| 53 | if (!c) |
| 54 | { |
| 55 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] got NULL connection", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 56 | return -1; |
| 57 | } |
| 58 | if (!packet) |
| 59 | { |
| 60 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] got NULL packet", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 61 | return -1; |
| 62 | } |
| 63 | if (packet_get_classcxx . . $ pvpgn/packet_get_class(6361653567fd72e5).(packet) != packet_class_rawcxx . . $ pvpgn/packet_class_raw.) |
| 64 | { |
| 65 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] got bad packet (class {})", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), (int)packet_get_classcxx . . $ pvpgn/packet_get_class(6361653567fd72e5).(packet)); |
| 66 | return -1; |
| 67 | } |
| 68 | |
| 69 | { |
| 70 | char const * const linestr = packet_get_str_constcxx . . $ pvpgn/packet_get_str_const(2621638e840efcc6).(packet, 0, MAX_MESSAGE_LENcxx . . $ MAX_MESSAGE_LEN.); |
| 71 | |
| 72 | if (packet_get_sizecxx . . $ pvpgn/packet_get_size(e4ac9e2b4744cb4b).(packet) < 2) /* empty line */ |
| 73 | return 0; |
| 74 | if (!linestr) |
| 75 | { |
| 76 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn., __FUNCTION__, "[{}] line too long", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | switch (conn_get_statecxx . . $ pvpgn/bnetd/conn_get_state(14586157a79399d4).(c)) |
| 81 | { |
| 82 | case conn_state_connected: |
| 83 | conn_add_flagscxx . . $ pvpgn/bnetd/conn_add_flags(d97ad1b62a895b69).(c, MF_PLUGcxx . . $ `src/common/bnet_protocol.h:2578:9`!); |
| 84 | conn_set_clienttagcxx . . $ pvpgn/bnetd/conn_set_clienttag(d97ad1b62a895b69).(c, CLIENTTAG_BNCHATBOT_UINTcxx . . $ `/build/tmp.prHwK0hYwT/package/src/common/tag.h:85:9`!); |
| 85 | |
| 86 | { |
| 87 | char const * temp = linestr; |
| 88 | |
| 89 | if (temp[0] == '\004') /* FIXME: no echo, ignore for now (we always do no echo) */ |
| 90 | temp = &temp[1]; |
| 91 | |
| 92 | if (temp[0] == '\0') /* empty line */ |
| 93 | { |
| 94 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); /* don't look for ^D or reset tag and flags */ |
| 95 | break; |
| 96 | } |
| 97 | |
| 98 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_password); |
| 99 | |
| 100 | if (conn_set_loggedusercxx . . $ pvpgn/bnetd/conn_set_loggeduser(2e9022cda97b266d).(c, temp) < 0) |
| 101 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not set username to \"{}\"", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), temp); |
| 102 | |
| 103 | { |
| 104 | char const * const msg = "\r\nPassword: "; |
| 105 | |
| 106 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 107 | { |
| 108 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 109 | break; |
| 110 | } |
| 111 | #if 1 /* don't echo */ |
| 112 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, conn_get_loggedusercxx . . $ pvpgn/bnetd/conn_get_loggeduser(c99dbccf638f5c6).(c)); |
| 113 | #endif |
| 114 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, msg); |
| 115 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 116 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 117 | } |
| 118 | } |
| 119 | break; |
| 120 | |
| 121 | case conn_state_bot_username: |
| 122 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_password); |
| 123 | |
| 124 | if (conn_set_loggedusercxx . . $ pvpgn/bnetd/conn_set_loggeduser(2e9022cda97b266d).(c, linestr) < 0) |
| 125 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not set username to \"{}\"", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), linestr); |
| 126 | |
| 127 | { |
| 128 | char const * const temp = "\r\nPassword: "; |
| 129 | |
| 130 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 131 | { |
| 132 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 133 | break; |
| 134 | } |
| 135 | #if 1 /* don't echo */ |
| 136 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, linestr); |
| 137 | #endif |
| 138 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, temp); |
| 139 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 140 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 141 | } |
| 142 | break; |
| 143 | |
| 144 | case conn_state_bot_password: |
| 145 | { |
| 146 | char const * const tempa = "\r\nLogin failed.\r\n\r\nUsername: "; |
| 147 | char const * const tempb = "\r\nAccount has no bot access.\r\n\r\nUsername: "; |
| 148 | char const * loggeduser = conn_get_loggedusercxx . . $ pvpgn/bnetd/conn_get_loggeduser(c99dbccf638f5c6).(c); |
| 149 | t_accountcxx . . $ pvpgn/bnetd/t_account# * account; |
| 150 | char const * oldstrhash1; |
| 151 | t_hashcxx . . $ pvpgn/t_hash# trypasshash1; |
| 152 | t_hashcxx . . $ pvpgn/t_hash# oldpasshash1; |
| 153 | char * testpass; |
| 154 | |
| 155 | if (!loggeduser) /* error earlier in login */ |
| 156 | { |
| 157 | /* no std::log message... */ |
| 158 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 159 | |
| 160 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 161 | { |
| 162 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 163 | break; |
| 164 | } |
| 165 | |
| 166 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempa); |
| 167 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 168 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 169 | break; |
| 170 | } |
| 171 | if (connlist_find_connection_by_accountnamecxx . . $ pvpgn/bnetd/connlist_find_connection_by_accountname(2f6d5fbe0174f787).(loggeduser)) |
| 172 | { |
| 173 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] bot login for \"{}\" refused (already logged in)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 174 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 175 | |
| 176 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 177 | { |
| 178 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 179 | break; |
| 180 | } |
| 181 | |
| 182 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempa); |
| 183 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 184 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 185 | break; |
| 186 | } |
| 187 | if (!(account = accountlist_find_accountcxx . . $ pvpgn/bnetd/accountlist_find_account(db6f5ebdea1fa12b).(loggeduser))) |
| 188 | { |
| 189 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] bot login for \"{}\" refused (bad account)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 190 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 191 | |
| 192 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 193 | { |
| 194 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 195 | break; |
| 196 | } |
| 197 | |
| 198 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempa); |
| 199 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 200 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 201 | break; |
| 202 | } |
| 203 | if ((oldstrhash1 = account_get_passcxx . . $ pvpgn/bnetd/account_get_pass(4b37305d4a4563d0).(account))) |
| 204 | { |
| 205 | if (hash_set_strcxx . . $ pvpgn/hash_set_str(bc9a1c18029b2ef4).(&oldpasshash1, oldstrhash1) < 0) |
| 206 | { |
| 207 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] bot login for \"{}\" refused (corrupted passhash1?)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 208 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 209 | |
| 210 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 211 | { |
| 212 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 213 | break; |
| 214 | } |
| 215 | |
| 216 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempa); |
| 217 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 218 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 219 | break; |
| 220 | } |
| 221 | |
| 222 | testpass = xstrdupcxx . . $ `src/common/xalloc.h:49:9`!(linestr); |
| 223 | { |
| 224 | strtolowercxx . . $ pvpgn/strtolower(7a9722d75b371431).(testpass); |
| 225 | } |
| 226 | if (bnet_hashcxx . . $ pvpgn/bnet_hash(2a8392f275be648).(&trypasshash1, stdcxx . . $ std/::strlen(testpass), testpass) < 0) /* FIXME: force to lowercase */ |
| 227 | { |
| 228 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] bot login for \"{}\" refused (unable to hash password)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 229 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 230 | |
| 231 | xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)testpass); |
| 232 | |
| 233 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 234 | { |
| 235 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 236 | break; |
| 237 | } |
| 238 | |
| 239 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempa); |
| 240 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 241 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 242 | break; |
| 243 | } |
| 244 | xfreecxx . . $ `src/common/xalloc.h:51:9`!((void *)testpass); |
| 245 | if (hash_eqcxx . . $ pvpgn/hash_eq(4301982f75a4a5fa).(trypasshash1, oldpasshash1) != 1) |
| 246 | { |
| 247 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] bot login for \"{}\" refused (wrong password)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 248 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 249 | |
| 250 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 251 | { |
| 252 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 253 | break; |
| 254 | } |
| 255 | |
| 256 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempa); |
| 257 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 258 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 259 | break; |
| 260 | } |
| 261 | |
| 262 | |
| 263 | if (account_get_auth_botlogincxx . . $ pvpgn/bnetd/account_get_auth_botlogin(367bfb076f70247b).(account) != 1) /* default to false */ |
| 264 | { |
| 265 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] bot login for \"{}\" refused (no bot access)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 266 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 267 | |
| 268 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 269 | { |
| 270 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 271 | break; |
| 272 | } |
| 273 | |
| 274 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempb); |
| 275 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 276 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 277 | break; |
| 278 | } |
| 279 | else if (account_get_auth_lockcxx . . $ pvpgn/bnetd/account_get_auth_lock(367bfb076f70247b).(account) == 1) /* default to false */ |
| 280 | { |
| 281 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] bot login for \"{}\" refused (this account is locked)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 282 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_bot_username); |
| 283 | |
| 284 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) |
| 285 | { |
| 286 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 287 | break; |
| 288 | } |
| 289 | |
| 290 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, tempb); |
| 291 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 292 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 293 | break; |
| 294 | } |
| 295 | |
| 296 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] \"{}\" bot logged in (correct password)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 297 | #ifdef WITH_LUA |
| 298 | if (lua_handle_user(c, NULL, NULL, luaevent_user_login) == 1) |
| 299 | { |
| 300 | // feature to break login from Lua |
| 301 | conn_set_state(c, conn_state_destroy); |
| 302 | break; |
| 303 | } |
| 304 | #endif |
| 305 | } |
| 306 | else |
| 307 | { |
| 308 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "[{}] \"{}\" bot logged in (no password)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), loggeduser); |
| 309 | } |
| 310 | if (!(rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) /* if we got this far, let them std::log in even if this fails */ |
| 311 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] could not create rpacket", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 312 | else |
| 313 | { |
| 314 | packet_append_ntstringcxx . . $ pvpgn/packet_append_ntstring(41801851180b7cbb).(rpacket, "\r\n"); |
| 315 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 316 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 317 | } |
| 318 | |
| 319 | conn_logincxx . . $ pvpgn/bnetd/conn_login(37ada50ef2b0abe1).(c, account, loggeduser); |
| 320 | |
| 321 | message_send_textcxx . . $ pvpgn/bnetd/message_send_text(61daf7e3ba1862c4).(c, message_type_uniqueidcxx . . $ pvpgn/bnetd/message_type_uniqueid., c, loggeduser); |
| 322 | |
| 323 | if (conn_set_channelcxx . . $ pvpgn/bnetd/conn_set_channel(2e9022cda97b266d).(c, CHANNEL_NAME_CHATcxx . . $ `src/bnetd/channel.h:127:9`!) < 0) |
| 324 | conn_set_channelcxx . . $ pvpgn/bnetd/conn_set_channel(2e9022cda97b266d).(c, CHANNEL_NAME_BANNEDcxx . . $ `src/bnetd/channel.h:125:9`!); /* should not fail */ |
| 325 | } |
| 326 | break; |
| 327 | |
| 328 | case conn_state_loggedin: |
| 329 | { |
| 330 | t_channelcxx . . $ pvpgn/bnetd/t_channel# const * channel; |
| 331 | |
| 332 | conn_set_idletimecxx . . $ pvpgn/bnetd/conn_set_idletime(c4dfbc2386fe4fc3).(c); |
| 333 | |
| 334 | if ((channel = conn_get_channelcxx . . $ pvpgn/bnetd/conn_get_channel(17dd609cd0747384).(c))) |
| 335 | channel_message_logcxx . . $ pvpgn/bnetd/channel_message_log(3119144774c93d10).(channel, c, 1, linestr); |
| 336 | /* we don't log game commands currently */ |
| 337 | |
| 338 | if (linestr[0] == '/') |
| 339 | handle_commandcxx . . $ pvpgn/bnetd/handle_command(2e9022cda97b266d).(c, linestr); |
| 340 | else |
| 341 | if (channel && !conn_quota_exceededcxx . . $ pvpgn/bnetd/conn_quota_exceeded(2e9022cda97b266d).(c, linestr)) |
| 342 | channel_message_sendcxx . . $ pvpgn/bnetd/channel_message_send(3c4bd88e6f433f89).(channel, message_type_talkcxx . . $ pvpgn/bnetd/message_type_talk., c, linestr); |
| 343 | /* else discard */ |
| 344 | } |
| 345 | break; |
| 346 | |
| 347 | default: |
| 348 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] unknown bot connection state {}", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), (int)conn_get_statecxx . . $ pvpgn/bnetd/conn_get_state(14586157a79399d4).(c)); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | } |
| 356 | |
| 357 | } |