/* * G_ClientConnect * * Called when a player begins connecting to the server. * The game can refuse entrance to a client by returning false. * If the client is allowed, the connection process will continue * and eventually get to G_Begin() * Changing levels will NOT cause this to be called again. */ boolean_t G_ClientConnect(g_edict_t *ent, char *user_info) { // check password const char *value = GetUserInfo(user_info, "password"); if (*password->string && strcmp(password->string, "none") && strcmp( password->string, value)) { SetUserInfo(user_info, "rejmsg", "Password required or incorrect."); return false; } // they can connect ent->client = g_game.clients + (ent - g_game.edicts - 1); // clean up locals things which are not reset on spawns ent->client->persistent.score = 0; ent->client->persistent.team = NULL; ent->client->persistent.vote = VOTE_NO_OP; ent->client->persistent.spectator = false; ent->client->persistent.net_name[0] = 0; // set name, skin, etc.. G_ClientUserInfoChanged(ent, user_info); if (sv_max_clients->integer > 1) gi.BroadcastPrint(PRINT_HIGH, "%s connected\n", ent->client->persistent.net_name); ent->sv_flags = 0; // make sure we start with known default return true; }
void CAsyncClient::LogoutUser( const int nCn, const char* szUserName ) { /* USERINFO *pUser = FindPayUser( szUserName ); if( pUser == NULL ) { return; } if( nCn != pUser->dwConnectionIndex ) { return; } */ if( NULL == szUserName ) // 030701 kyo { return; } LISTUSERIT it = FindUserIterator( szUserName ); if( it == NULL ) { return; } USERINFOPAY userinfo; SetUserInfo( userinfo, (*it).dwConnectionIndex, (*it).szUserId, "", CAsyncClient::GAME_ID, CAsyncClient::USER_TYPE); SendUserLogout( userinfo); }
BOOL UIComms::Setup(HWND hwnd) { AppWnd_=hwnd; SetUserInfo(); StartUITracking(); StartCommsQueue(); return(TRUE); }
/* * Sv_UserInfoChanged * * Enforces safe user_info data before passing onto game module. */ void Sv_UserInfoChanged(sv_client_t *cl) { char *val; size_t i; if (*cl->user_info == '\0') { // catch empty user_info Com_Print("Empty user_info from %s\n", Sv_NetaddrToString(cl)); Sv_KickClient(cl, "Bad user info"); return; } if (strchr(cl->user_info, '\xFF')) { // catch end of message exploit Com_Print("Illegal user_info contained xFF from %s\n", Sv_NetaddrToString(cl)); Sv_KickClient(cl, "Bad user info"); return; } if (!ValidateUserInfo(cl->user_info)) { // catch otherwise invalid user_info Com_Print("Invalid user_info from %s\n", Sv_NetaddrToString(cl)); Sv_KickClient(cl, "Bad user info"); return; } val = GetUserInfo(cl->user_info, "skin"); if (strstr(val, "..")) // catch malformed skins SetUserInfo(cl->user_info, "skin", "enforcer/qforcer"); // call game code to allow overrides svs.game->ClientUserInfoChanged(cl->edict, cl->user_info); // name for C code, mask off high bit strncpy(cl->name, GetUserInfo(cl->user_info, "name"), sizeof(cl->name) - 1); for (i = 0; i < sizeof(cl->name); i++) { cl->name[i] &= 127; } // rate command val = GetUserInfo(cl->user_info, "rate"); if (*val != '\0') { cl->rate = atoi(val); if (cl->rate > CLIENT_RATE_MAX) cl->rate = CLIENT_RATE_MAX; else if (cl->rate < CLIENT_RATE_MIN) cl->rate = CLIENT_RATE_MIN; } // limit the print messages the client receives val = GetUserInfo(cl->user_info, "message_level"); if (*val != '\0') { cl->message_level = atoi(val); } // start/stop sending view angles for demo recording val = GetUserInfo(cl->user_info, "recording"); cl->recording = atoi(val) == 1; }
void CAsyncClient::LogoutUser( USERINFO *pUser ) { if( pUser == NULL ) { return; } USERINFOPAY userinfo; SetUserInfo( userinfo, pUser->dwConnectionIndex, pUser->szName, "", CAsyncClient::GAME_ID, CAsyncClient::USER_TYPE); //MyLog( 0, "[PayClient] UserLogout cn: %d, name = %s" , pUser->dwConnectionIndex, pUser->szName ); SendUserLogout( userinfo); }
void CAsyncClient::LoginUser( const int nCn, const char* szUserId, const char* szUserPass , const char* szGameId, const char* szUserType, const char* szUserRealIp, const char* szUserVrIp) { USERINFOPAY userInfo; SetUserInfo( userInfo, nCn, szUserId, szUserPass, szGameId, szUserType );//GAME_ID, USER_TYPE ); //기존테이블에 유저가 있으면 그 유저를 삭제하고 현제 유저를 삽입한다. int nReConnect = AddPayUser( userInfo ); //유저를 해당 테이블에 저장한다. /* 030502 kyo int nReConnect = 0; USERINFO *pUser = g_pUserTable->GetUserInfo( szUserId ); ( NULL == pUser) { nReConnect = 0; } else nReConnect = 1; */ SendUserLogin( userInfo, szUserRealIp, szUserVrIp, nReConnect ); //SendUserLogin( userInfo, szUserRealIp, szUserVrIp, 0); }
void DealSmsContent(void) { static BYTE SmsCmd; if (SmsContent[0] == '?') { SysHelp(); return; } if (SmsContent[0] != 'F') { return; } SmsCmd = SmsContent[1]; switch (SmsCmd) { case '0': //设置参数 //F0:13912345678,dddd-hh //SetSysParam(); //短信唤醒 //F0:192.168.1.1,8000 // 服务器IP和端口 SmsWakeup(); break; #if 0 //F1 case '1': //读当前电量 if (SysParam[SP_ENABLESOCKET] == 1) { ReportCurentPower(); } else { //GetCurIpAdd(); Clear_Sms_Content(); mcpy(&SmsContent[0],"Socket mode don't support the CMD!\r\n",36); SmsLength = 36; if (SysParam[SP_MODTYPE] == GSM_MG323) { Send_Pdu_SMS(); } else if (SysParam[SP_MODTYPE] == CDMA_MC323) { Send_Txt_SMS(SmsNumber, SmsContent); } } break; #endif //F2:0/1 case '2': //控制外部设备 // ControlDevice(); break; //F3 case '3': //读取机房环境状态 RepStatus(); break; //F4 case '4': //设置串口参数 SetUartParam(); break; #if 0 //特殊需求: 当外部设备开启时提前1个小时取电 //F5:1[,0/1] 是否根据读电量的时间控制外设,是否需要偷电为可选择项 case '5': //偷电 ^_^ SetDeviceParam(); break; #endif case '6': //设置服务器域名 //SetHostName(); SetUserInfo(); break; //系统设置开关:GPRS/恢复默认参数/系统复位 case '7': SysConfig(); break; //返回电表ID case '8': if (SysParam[SP_ENABLESOCKET] == 0) { GetEmId(); } else { GetCurIpAdd(); /* Clear_Sms_Content(); mcpy(&SmsContent[0],"Socket mode don't support the CMD!\r\n",36); SmsLength = 36; Send_Txt_SMS(SmsNumber, SmsContent); */ } break; //设置服务器IP地址和端口及本地端口 //F9:192.168.1.1,5000,9000 case '9': SetServerAddr(); break; //错误命名不处理,也不返回,防止垃圾短信 } Clear_Sms_Content(); }
/* * @brief A connection request that did not come from the master. */ static void Svc_Connect(void) { char user_info[MAX_USER_INFO_STRING]; sv_client_t *cl, *client; int32_t i; Com_Debug("Svc_Connect()\n"); net_addr_t *addr = &net_from; const int32_t version = strtol(Cmd_Argv(1), NULL, 0); // resolve protocol if (version != PROTOCOL) { Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nServer is version %d.\n", PROTOCOL); return; } const uint8_t qport = strtoul(Cmd_Argv(2), NULL, 0); const uint32_t challenge = strtoul(Cmd_Argv(3), NULL, 0); // copy user_info, leave room for ip stuffing g_strlcpy(user_info, Cmd_Argv(4), sizeof(user_info) - 25); if (*user_info == '\0') { // catch empty user_info Com_Print("Empty user_info from %s\n", Net_NetaddrToString(addr)); Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nConnection refused\n"); return; } if (strchr(user_info, '\xFF')) { // catch end of message in string exploit Com_Print("Illegal user_info contained xFF from %s\n", Net_NetaddrToString(addr)); Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nConnection refused\n"); return; } if (strlen(GetUserInfo(user_info, "ip"))) { // catch spoofed ips Com_Print("Illegal user_info contained ip from %s\n", Net_NetaddrToString(addr)); Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nConnection refused\n"); return; } if (!ValidateUserInfo(user_info)) { // catch otherwise invalid user_info Com_Print("Invalid user_info from %s\n", Net_NetaddrToString(addr)); Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nConnection refused\n"); return; } // force the ip so the game can filter on it SetUserInfo(user_info, "ip", Net_NetaddrToString(addr)); // enforce a valid challenge to avoid denial of service attack for (i = 0; i < MAX_CHALLENGES; i++) { if (Net_CompareClientNetaddr(addr, &svs.challenges[i].addr)) { if (challenge == svs.challenges[i].challenge) { svs.challenges[i].challenge = 0; break; // good } Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nBad challenge\n"); return; } } if (i == MAX_CHALLENGES) { Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nNo challenge for address\n"); return; } // resolve the client slot client = NULL; // first check for an ungraceful reconnect (client crashed, perhaps) for (i = 0, cl = svs.clients; i < sv_max_clients->integer; i++, cl++) { const net_chan_t *ch = &cl->net_chan; if (cl->state == SV_CLIENT_FREE) // not in use, not interested continue; // the base address and either the qport or real port must match if (Net_CompareClientNetaddr(addr, &ch->remote_address)) { if (addr->port == ch->remote_address.port || qport == ch->qport) { client = cl; break; } } } // otherwise, treat as a fresh connect to a new slot if (!client) { for (i = 0, cl = svs.clients; i < sv_max_clients->integer; i++, cl++) { if (cl->state == SV_CLIENT_FREE && !cl->edict->ai) { // we have a free one client = cl; break; } } } // no soup for you, next!! if (!client) { Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nServer is full\n"); Com_Debug("Rejected a connection\n"); return; } // give the game a chance to reject this connection or modify the user_info if (!(svs.game->ClientConnect(client->edict, user_info))) { const char *rejmsg = GetUserInfo(user_info, "rejmsg"); if (strlen(rejmsg)) { Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\n%s\nConnection refused\n", rejmsg); } else { Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "print\nConnection refused\n"); } Com_Debug("Game rejected a connection\n"); return; } // parse some info from the info strings g_strlcpy(client->user_info, user_info, sizeof(client->user_info)); Sv_UserInfoChanged(client); // send the connect packet to the client Netchan_OutOfBandPrint(NS_UDP_SERVER, addr, "client_connect %s", sv_download_url->string); Netchan_Setup(NS_UDP_SERVER, &client->net_chan, addr, qport); Mem_InitBuffer(&client->datagram.buffer, client->datagram.data, sizeof(client->datagram.data)); client->datagram.buffer.allow_overflow = true; client->last_message = svs.real_time; // don't timeout client->state = SV_CLIENT_CONNECTED; }