#include "copyright.h"#include "autoconf.h"#include "config.h"#include "externs.h"#include <time.h>#include "ansi.h"#include "attrs.h"#include "command.h"#include "comsys.h"#include "file_c.h"#include "functions.h"#include "mguests.h"#include "powers.h"#include "svdreport.h"Include dependency graph for netcommon.cpp:

Go to the source code of this file.
Defines | |
| #define | MAX_TRIMMED_NAME_LENGTH 16 |
| #define | INFO_VERSION "1" |
| #define | S_SUSPECT 1 |
| #define | S_ACCESS 2 |
| #define | CIF_LOGOUTTIME 4 |
Functions | |
| void | make_portlist (dbref player, dbref target, char *buff, char **bufc) |
| void | make_port_ulist (dbref player, char *buff, char **bufc) |
| void | update_quotas (CLinearTimeAbsolute <aLast, const CLinearTimeAbsolute <aCurrent) |
| void | raw_notify_html (dbref player, const char *msg) |
| void | raw_notify (dbref player, const char *msg) |
| void | raw_notify_newline (dbref player) |
| void DCL_CDECL | raw_broadcast (int inflags, char *fmt,...) |
| void | clearstrings (DESC *d) |
| static void | add_to_output_queue (DESC *d, const char *b, int n) |
| void | queue_write_LEN (DESC *d, const char *b, int n) |
| void | queue_write (DESC *d, const char *b) |
| static const char * | encode_iac (const char *szString) |
| void | queue_string (DESC *d, const char *s) |
| void | freeqs (DESC *d) |
| void | desc_addhash (DESC *d) |
| static void | desc_delhash (DESC *d) |
| void | welcome_user (DESC *d) |
| void | save_command (DESC *d, CBLK *command) |
| static void | set_userstring (char **userstring, const char *command) |
| static void | parse_connect (const char *msg, char *command, char *user, char *pass) |
| static void | announce_connect (dbref player, DESC *d) |
| void | announce_disconnect (dbref player, DESC *d, const char *reason) |
| int | boot_off (dbref player, const char *message) |
| int | boot_by_port (SOCKET port, bool bGod, const char *message) |
| void | desc_reload (dbref player) |
| int | fetch_session (dbref target) |
| static DESC * | find_least_idle (dbref target) |
| int | fetch_height (dbref target) |
| int | fetch_width (dbref target) |
| int | fetch_idle (dbref target) |
| void | find_oldest (dbref target, DESC *dOldest[2]) |
| int | fetch_connect (dbref target) |
| void | check_idle (void) |
| void | check_events (void) |
| static const char * | trimmed_name (dbref player, int *pvw) |
| static char * | trimmed_site (char *szName) |
| static void | dump_users (DESC *e, char *match, int key) |
| static void | dump_info (DESC *arg_desc) |
| static char * | MakeCanonicalDoing (char *pDoing, int *pnValidDoing, bool *pbValidDoing) |
| void | do_doing (dbref executor, dbref caller, dbref enactor, int key, char *arg) |
| void | init_logout_cmdtab (void) |
| static void | failconn (const char *logcode, const char *logtype, const char *logreason, DESC *d, int disconnect_reason, dbref player, int filecache, char *motd_msg, char *command, char *user, char *password, char *cmdsave) |
| static bool | check_connect (DESC *d, char *msg) |
| static void | do_logged_out_internal (DESC *d, int key, char *arg) |
| void | do_command (DESC *d, char *command) |
| void | logged_out1 (dbref executor, dbref caller, dbref enactor, int key, char *arg) |
| void | logged_out0 (dbref executor, dbref caller, dbref enactor, int key) |
| void | Task_ProcessCommand (void *arg_voidptr, int arg_iInteger) |
| int | site_check (struct in_addr host, SITE *site_list) |
| static const char * | stat_string (int strtype, int flag) |
| static void | list_sites (dbref player, SITE *site_list, const char *header_txt, int stat_type) |
| void | list_siteinfo (dbref player) |
| void | make_ulist (dbref player, char *buff, char **bufc, bool bPorts) |
| dbref | find_connected_name (dbref player, char *name) |
| FUNCTION (fun_doing) | |
| FUNCTION (fun_host) | |
| FUNCTION (fun_poll) | |
| FUNCTION (fun_motd) | |
| int | fetch_cmds (dbref target) |
| static void | ParseConnectionInfoString (char *pConnInfo, char *pFields[5]) |
| void | fetch_ConnectionInfoFields (dbref target, long anFields[4]) |
| void | put_ConnectionInfoFields (dbref target, long anFields[4], CLinearTimeAbsolute <aLogout) |
| long | fetch_ConnectionInfoField (dbref target, int iField) |
| CLinearTimeAbsolute | fetch_logouttime (dbref target) |
Variables | |
| NAMETAB | logout_cmdtable [] |
| static const char * | connect_fail = "Either that player does not exist, or has a different password.\r\n" |
| #define CIF_LOGOUTTIME 4 |
| #define INFO_VERSION "1" |
| #define MAX_TRIMMED_NAME_LENGTH 16 |
| #define S_ACCESS 2 |
| #define S_SUSPECT 1 |
| static void add_to_output_queue | ( | DESC * | d, | |
| const char * | b, | |||
| int | n | |||
| ) | [static] |
Definition at line 253 of file netcommon.cpp.
References text_block::data, text_block_hdr::end, text_block::hdr, ISOUTOFMEMORY, left, MEMALLOC, text_block_hdr::nchars, text_block_hdr::nxt, OUTPUT_BLOCK_SIZE, descriptor_data::output_head, descriptor_data::output_tail, and text_block_hdr::start.
Referenced by queue_write_LEN().
00254 { 00255 TBLOCK *tp; 00256 int left; 00257 00258 // Allocate an output buffer if needed. 00259 // 00260 if (d->output_head == NULL) 00261 { 00262 tp = (TBLOCK *)MEMALLOC(OUTPUT_BLOCK_SIZE); 00263 ISOUTOFMEMORY(tp); 00264 tp->hdr.nxt = NULL; 00265 tp->hdr.start = tp->data; 00266 tp->hdr.end = tp->data; 00267 tp->hdr.nchars = 0; 00268 d->output_head = tp; 00269 d->output_tail = tp; 00270 } 00271 else 00272 { 00273 tp = d->output_tail; 00274 } 00275 00276 // Now tp points to the last buffer in the chain. 00277 // 00278 do 00279 { 00280 // See if there is enough space in the buffer to hold the 00281 // string. If so, copy it and update the pointers.. 00282 // 00283 left = OUTPUT_BLOCK_SIZE - (tp->hdr.end - (char *)tp + 1); 00284 if (n <= left) 00285 { 00286 memcpy(tp->hdr.end, b, n); 00287 tp->hdr.end += n; 00288 tp->hdr.nchars += n; 00289 n = 0; 00290 } 00291 else 00292 { 00293 // It didn't fit. Copy what will fit and then allocate 00294 // another buffer and retry. 00295 // 00296 if (left > 0) 00297 { 00298 memcpy(tp->hdr.end, b, left); 00299 tp->hdr.end += left; 00300 tp->hdr.nchars += left; 00301 b += left; 00302 n -= left; 00303 } 00304 tp = (TBLOCK *)MEMALLOC(OUTPUT_BLOCK_SIZE); 00305 ISOUTOFMEMORY(tp); 00306 tp->hdr.nxt = NULL; 00307 tp->hdr.start = tp->data; 00308 tp->hdr.end = tp->data; 00309 tp->hdr.nchars = 0; 00310 d->output_tail->hdr.nxt = tp; 00311 d->output_tail = tp; 00312 } 00313 } while (n > 0); 00314 }
Definition at line 706 of file netcommon.cpp.
References A_ACONNECT, A_LPAGE, A_TIMEOUT, descriptor_data::addr, descriptor_data::address, alloc_lbuf, ANSI_HILITE, ANSI_NORMAL, atr_get_str_LEN(), atr_pget_str_LEN(), Can_Hide, CF_LOGIN, check_mail(), Contents, confdata::control_flags, statedata::curr_enactor, DARK, db, desc_addhash(), DESC_ITER_CONN, DESC_ITER_PLAYER, do_comconnect(), DOLIST, DS_PUEBLOCLIENT, FLAG_WORD1, FLAG_WORD2, descriptor_data::flags, Flags2, free_lbuf, object::fs, CLinearTimeAbsolute::GetLocal(), Good_obj, Guest, H_SUSPECT, confdata::have_comsys, confdata::have_mailer, confdata::have_zones, Hidden, descriptor_data::host_info, confdata::idle_timeout, LK_OBEYTERSE, LK_SHOWEXIT, LK_SHOWVRML, Location, log_text(), look_in(), confdata::master_room, Moniker(), MONITOR, confdata::motd_msg, MSG_FWDLIST, MSG_INV, MSG_LOC, MSG_NBR, MSG_NBR_EXITS, mudconf, mudstate, mux_atol(), Name, NOTHING, notify_check(), notify_except_rlevel(), raw_broadcast(), raw_notify(), record_login(), statedata::record_players, CLinearTimeAbsolute::ReturnDateString(), s_Connected, s_Flags, s_Html, Suspect, descriptor_data::timeout, tprintf(), TYPE_ROOM, TYPE_THING, Typeof, descriptor_data::username, VACATION, wait_que(), WIZARD, Wizard, confdata::wizmotd_msg, flagset::word, and Zone.
Referenced by check_connect().
00707 { 00708 desc_addhash(d); 00709 00710 DESC *dtemp; 00711 int count = 0; 00712 DESC_ITER_CONN(dtemp) 00713 { 00714 count++; 00715 } 00716 00717 if (mudstate.record_players < count) 00718 { 00719 mudstate.record_players = count; 00720 } 00721 00722 char *buf = alloc_lbuf("announce_connect"); 00723 dbref aowner; 00724 int aflags; 00725 size_t nLen; 00726 atr_pget_str_LEN(buf, player, A_TIMEOUT, &aowner, &aflags, &nLen); 00727 if (nLen) 00728 { 00729 d->timeout = mux_atol(buf); 00730 if (d->timeout <= 0) 00731 { 00732 d->timeout = mudconf.idle_timeout; 00733 } 00734 } 00735 00736 dbref loc = Location(player); 00737 s_Connected(player); 00738 00739 if (d->flags & DS_PUEBLOCLIENT) 00740 { 00741 s_Html(player); 00742 } 00743 00744 raw_notify( player, tprintf("\n%sMOTD:%s %s\n", ANSI_HILITE, 00745 ANSI_NORMAL, mudconf.motd_msg)); 00746 00747 if (Wizard(player)) 00748 { 00749 raw_notify(player, tprintf("%sWIZMOTD:%s %s\n", ANSI_HILITE, 00750 ANSI_NORMAL, mudconf.wizmotd_msg)); 00751 00752 if (!(mudconf.control_flags & CF_LOGIN)) 00753 { 00754 raw_notify(player, "*** Logins are disabled."); 00755 } 00756 } 00757 atr_get_str_LEN(buf, player, A_LPAGE, &aowner, &aflags, &nLen); 00758 if (nLen) 00759 { 00760 raw_notify(player, "Your PAGE LOCK is set. You may be unable to receive some pages."); 00761 } 00762 int num = 0; 00763 DESC_ITER_PLAYER(player, dtemp) 00764 { 00765 num++; 00766 } 00767 00768 // Reset vacation flag. 00769 // 00770 s_Flags(player, FLAG_WORD2, Flags2(player) & ~VACATION); 00771 00772 char *pRoomAnnounceFmt; 00773 char *pMonitorAnnounceFmt; 00774 if (num < 2) 00775 { 00776 pRoomAnnounceFmt = "%s has connected."; 00777 if (mudconf.have_comsys) 00778 { 00779 do_comconnect(player); 00780 } 00781 if ( Hidden(player) 00782 && Can_Hide(player)) 00783 { 00784 pMonitorAnnounceFmt = "GAME: %s has DARK-connected."; 00785 } 00786 else 00787 { 00788 pMonitorAnnounceFmt = "GAME: %s has connected."; 00789 } 00790 if ( Suspect(player) 00791 || (d->host_info & H_SUSPECT)) 00792 { 00793 raw_broadcast(WIZARD, "[Suspect] %s has connected.", Moniker(player)); 00794 } 00795 } 00796 else 00797 { 00798 pRoomAnnounceFmt = "%s has reconnected."; 00799 pMonitorAnnounceFmt = "GAME: %s has reconnected."; 00800 if ( Suspect(player) 00801 || (d->host_info & H_SUSPECT)) 00802 { 00803 raw_broadcast(WIZARD, "[Suspect] %s has reconnected.", Moniker(player)); 00804 } 00805 } 00806 sprintf(buf, pRoomAnnounceFmt, Moniker(player)); 00807 raw_broadcast(MONITOR, pMonitorAnnounceFmt, Moniker(player)); 00808 00809 int key = MSG_INV; 00810 if ( loc != NOTHING 00811 && !( Hidden(player) 00812 && Can_Hide(player))) 00813 { 00814 key |= (MSG_NBR | MSG_NBR_EXITS | MSG_LOC | MSG_FWDLIST); 00815 } 00816 00817 dbref temp = mudstate.curr_enactor; 00818 mudstate.curr_enactor = player; 00819 #ifdef REALITY_LVLS 00820 if(loc == NOTHING) 00821 notify_check(player, player, buf, key); 00822 else 00823 notify_except_rlevel(loc, player, player, buf, 0); 00824 #else 00825 notify_check(player, player, buf, key); 00826 #endif /* REALITY_LVLS */ 00827 atr_pget_str_LEN(buf, player, A_ACONNECT, &aowner, &aflags, &nLen); 00828 CLinearTimeAbsolute lta; 00829 dbref zone, obj; 00830 if (nLen) 00831 { 00832 wait_que(player, player, player, false, lta, NOTHING, 0, buf, 00833 (char **)NULL, 0, NULL); 00834 } 00835 if (mudconf.master_room != NOTHING) 00836 { 00837 atr_pget_str_LEN(buf, mudconf.master_room, A_ACONNECT, &aowner, 00838 &aflags, &nLen); 00839 if (nLen) 00840 { 00841 wait_que(mudconf.master_room, player, player, false, lta, 00842 NOTHING, 0, buf, (char **)NULL, 0, NULL); 00843 } 00844 DOLIST(obj, Contents(mudconf.master_room)) 00845 { 00846 atr_pget_str_LEN(buf, obj, A_ACONNECT, &aowner, &aflags, &nLen); 00847 if (nLen) 00848 { 00849 wait_que(obj, player, player, false, lta, NOTHING, 0, buf, 00850 (char **)NULL, 0, NULL); 00851 } 00852 } 00853 } 00854 00855 // Do the zone of the player's location's possible aconnect. 00856 // 00857 if ( mudconf.have_zones 00858 && Good_obj(zone = Zone(loc))) 00859 { 00860 switch (Typeof(zone)) 00861 { 00862 case TYPE_THING: 00863 00864 atr_pget_str_LEN(buf, zone, A_ACONNECT, &aowner, &aflags, &nLen); 00865 if (nLen) 00866 { 00867 wait_que(zone, player, player, false, lta, NOTHING, 0, buf, 00868 (char **)NULL, 0, NULL); 00869 } 00870 break; 00871 00872 case TYPE_ROOM: 00873 00874 // check every object in the room for a connect action. 00875 // 00876 DOLIST(obj, Contents(zone)) 00877 { 00878 atr_pget_str_LEN(buf, obj, A_ACONNECT, &aowner, &aflags, 00879 &nLen); 00880 if (nLen) 00881 { 00882 wait_que(obj, player, player, false, lta, NOTHING, 0, 00883 buf, (char **)NULL, 0, NULL); 00884 } 00885 } 00886 break; 00887 00888 default: 00889 00890 log_text(tprintf("Invalid zone #%d for %s(#%d) has bad type %d", 00891 zone, Name(player), player, Typeof(zone))); 00892 } 00893 } 00894 free_lbuf(buf); 00895 CLinearTimeAbsolute ltaNow; 00896 ltaNow.GetLocal(); 00897 char *time_str = ltaNow.ReturnDateString(7); 00898 00899 record_login(player, true, time_str, d->addr, d->username, 00900 inet_ntoa((d->address).sin_addr)); 00901 if (mudconf.have_mailer) 00902 { 00903 check_mail(player, 0, false); 00904 } 00905 look_in(player, Location(player), (LK_SHOWEXIT|LK_OBEYTERSE|LK_SHOWVRML)); 00906 mudstate.curr_enactor = temp; 00907 if (Guest(player)) 00908 { 00909 db[player].fs.word[FLAG_WORD1] &= ~DARK; 00910 } 00911 }
Definition at line 913 of file netcommon.cpp.
References A_ADISCONNECT, alloc_lbuf, alloc_mbuf, argv, atr_pget_str_LEN(), c_Connected, Can_Hide, Contents, statedata::curr_enactor, DARK, db, desc_delhash(), DESC_ITER_PLAYER, do_comdisconnect(), do_mail_purge(), DOLIST, DS_AUTODARK, FLAG_WORD1, descriptor_data::flags, free_lbuf, free_mbuf, object::fs, Good_obj, Guest, H_SUSPECT, halt_que(), confdata::have_comsys, confdata::have_mailer, confdata::have_zones, Hidden, descriptor_data::host_info, local_disconnect(), Location, log_text(), confdata::master_room, Moniker(), MONITOR, MSG_FWDLIST, MSG_INV, MSG_LOC, MSG_NBR, MSG_NBR_EXITS, mudconf, mudstate, Name, NOTHING, notify_check(), notify_except_rlevel(), raw_broadcast(), Suspect, tprintf(), TYPE_ROOM, TYPE_THING, Typeof, wait_que(), WIZARD, flagset::word, and Zone.
Referenced by shutdownsock().
00914 { 00915 int num = 0, key; 00916 DESC *dtemp; 00917 DESC_ITER_PLAYER(player, dtemp) 00918 { 00919 num++; 00920 } 00921 00922 dbref temp = mudstate.curr_enactor; 00923 mudstate.curr_enactor = player; 00924 dbref loc = Location(player); 00925 00926 if (num < 2) 00927 { 00928 if ( Suspect(player) 00929 || (d->host_info & H_SUSPECT)) 00930 { 00931 raw_broadcast(WIZARD, "[Suspect] %s has disconnected.", Moniker(player)); 00932 } 00933 char *buf = alloc_lbuf("announce_disconnect.only"); 00934 00935 sprintf(buf, "%s has disconnected.", Moniker(player)); 00936 key = MSG_INV; 00937 if ( loc != NOTHING 00938 && !( Hidden(player) 00939 && Can_Hide(player))) 00940 { 00941 key |= (MSG_NBR | MSG_NBR_EXITS | MSG_LOC | MSG_FWDLIST); 00942 } 00943 #ifdef REALITY_LVLS 00944 if(loc == NOTHING) 00945 notify_check(player, player, buf, key); 00946 else 00947 notify_except_rlevel(loc, player, player, buf, 0); 00948 #else 00949 notify_check(player, player, buf, key); 00950 #endif /* REALITY_LVLS */ 00951 00952 if (mudconf.have_mailer) 00953 { 00954 do_mail_purge(player); 00955 } 00956 00957 raw_broadcast(MONITOR, "GAME: %s has disconnected. <%s>", Moniker(player), reason); 00958 00959 c_Connected(player); 00960 00961 if (mudconf.have_comsys) 00962 { 00963 do_comdisconnect(player); 00964 } 00965 00966 dbref aowner, zone, obj; 00967 int aflags; 00968 size_t nLen; 00969 char *argv[1]; 00970 argv[0] = (char *)reason; 00971 CLinearTimeAbsolute lta; 00972 atr_pget_str_LEN(buf, player, A_ADISCONNECT, &aowner, &aflags, &nLen); 00973 if (nLen) 00974 { 00975 wait_que(player, player, player, false, lta, NOTHING, 0, buf, 00976 argv, 1, NULL); 00977 } 00978 if (mudconf.master_room != NOTHING) 00979 { 00980 atr_pget_str_LEN(buf, mudconf.master_room, A_ADISCONNECT, &aowner, 00981 &aflags, &nLen); 00982 if (nLen) 00983 { 00984 wait_que(mudconf.master_room, player, player, false, lta, 00985 NOTHING, 0, buf, (char **)NULL, 0, NULL); 00986 } 00987 DOLIST(obj, Contents(mudconf.master_room)) 00988 { 00989 atr_pget_str_LEN(buf, obj, A_ADISCONNECT, &aowner, &aflags, 00990 &nLen); 00991 if (nLen) 00992 { 00993 wait_que(obj, player, player, false, lta, NOTHING, 0, 00994 buf, (char **)NULL, 0, NULL); 00995 } 00996 } 00997 } 00998 00999 // Do the zone of the player's location's possible adisconnect. 01000 // 01001 if (mudconf.have_zones && Good_obj(zone = Zone(loc))) 01002 { 01003 switch (Typeof(zone)) 01004 { 01005 case TYPE_THING: 01006 01007 atr_pget_str_LEN(buf, zone, A_ADISCONNECT, &aowner, &aflags, 01008 &nLen); 01009 if (nLen) 01010 { 01011 wait_que(zone, player, player, false, lta, NOTHING, 0, 01012 buf, (char **)NULL, 0, NULL); 01013 } 01014 break; 01015 01016 case TYPE_ROOM: 01017 01018 // check every object in the room for a connect action. 01019 // 01020 DOLIST(obj, Contents(zone)) 01021 { 01022 atr_pget_str_LEN(buf, obj, A_ADISCONNECT, &aowner, &aflags, 01023 &nLen); 01024 if (nLen) 01025 { 01026 wait_que(obj, player, player, false, lta, NOTHING, 01027 0, buf, (char **)NULL, 0, NULL); 01028 } 01029 } 01030 break; 01031 01032 default: 01033 log_text(tprintf("Invalid zone #%d for %s(#%d) has bad type %d", 01034 zone, Name(player), player, Typeof(zone))); 01035 } 01036 } 01037 free_lbuf(buf); 01038 if (d->flags & DS_AUTODARK) 01039 { 01040 d->flags &= ~DS_AUTODARK; 01041 db[player].fs.word[FLAG_WORD1] &= ~DARK; 01042 } 01043 01044 if (Guest(player)) 01045 { 01046 db[player].fs.word[FLAG_WORD1] |= DARK; 01047 halt_que(NOTHING, player); 01048 } 01049 } 01050 else 01051 { 01052 if ( Suspect(player) 01053 || (d->host_info & H_SUSPECT)) 01054 { 01055 raw_broadcast(WIZARD, "[Suspect] %s has partially disconnected.", Moniker(player)); 01056 } 01057 char *mbuf = alloc_mbuf("announce_disconnect.partial"); 01058 sprintf(mbuf, "%s has partially disconnected.", Moniker(player)); 01059 key = MSG_INV; 01060 if ( loc != NOTHING 01061 && !( Hidden(player) 01062 && Can_Hide(player))) 01063 { 01064 key |= (MSG_NBR | MSG_NBR_EXITS | MSG_LOC | MSG_FWDLIST); 01065 } 01066 #ifdef REALITY_LVLS 01067 if(loc == NOTHING) 01068 notify_check(player, player, mbuf, key); 01069 else 01070 notify_except_rlevel(loc, player, player, mbuf, 0); 01071 #else 01072 notify_check(player, player, mbuf, key); 01073 #endif /* REALITY_LVLS */ 01074 raw_broadcast(MONITOR, "GAME: %s has partially disconnected.", 01075 Moniker(player)); 01076 free_mbuf(mbuf); 01077 } 01078 01079 mudstate.curr_enactor = temp; 01080 desc_delhash(d); 01081 01082 local_disconnect(player, num); 01083 }
| int boot_by_port | ( | SOCKET | port, | |
| bool | bGod, | |||
| const char * | message | |||
| ) |
Definition at line 1102 of file netcommon.cpp.
References DESC_SAFEITER_ALL, descriptor_data::descriptor, DS_CONNECTED, descriptor_data::flags, God, descriptor_data::player, queue_string(), queue_write_LEN(), R_BOOT, and shutdownsock().
Referenced by do_boot().
01103 { 01104 DESC *d, *dnext; 01105 int count = 0; 01106 DESC_SAFEITER_ALL(d, dnext) 01107 { 01108 if ( d->descriptor == port 01109 && ( bGod 01110 || !(d->flags & DS_CONNECTED) 01111 || !God(d->player))) 01112 { 01113 if ( message 01114 && *message) 01115 { 01116 queue_string(d, message); 01117 queue_write_LEN(d, "\r\n", 2); 01118 } 01119 shutdownsock(d, R_BOOT); 01120 count++; 01121 } 01122 } 01123 return count; 01124 }
| int boot_off | ( | dbref | player, | |
| const char * | message | |||
| ) |
Definition at line 1085 of file netcommon.cpp.
References DESC_SAFEITER_PLAYER, queue_string(), queue_write_LEN(), R_BOOT, and shutdownsock().
Referenced by destroy_player(), do_boot(), and do_toad().
01086 { 01087 DESC *d, *dnext; 01088 int count = 0; 01089 DESC_SAFEITER_PLAYER(player, d, dnext) 01090 { 01091 if (message && *message) 01092 { 01093 queue_string(d, message); 01094 queue_write_LEN(d, "\r\n", 2); 01095 } 01096 shutdownsock(d, R_BOOT); 01097 count++; 01098 } 01099 return count; 01100 }
| static bool check_connect | ( | DESC * | d, | |
| char * | msg | |||
| ) | [static] |
Definition at line 1954 of file netcommon.cpp.
References A_LAST, descriptor_data::addr, descriptor_data::address, AddToPublicChannel(), alloc_lbuf, alloc_mbuf, confdata::allow_guest_from_registered_site, announce_connect(), atr_get, CF_GUEST, CF_LOGIN, connect_player(), descriptor_data::connected_at, confdata::control_flags, create_player(), DARK, db, statedata::debug_cmd, DESC_ITER_CONN, DESC_ITER_PLAYER, descriptor_data::descriptor, confdata::downmotd_msg, DS_CONNECTED, ENDLOG, failconn(), FC_CONN_DOWN, FC_CONN_FULL, FC_CONN_GUEST, FC_CONN_REG, FC_CONN_SITE, FC_CREA_NEW, FC_CREA_REG, FC_MOTD, FC_WIZMOTD, fcache_dump(), FLAG_WORD1, descriptor_data::flags, free_lbuf, free_mbuf, object::fs, confdata::fullmotd_msg, CLinearTimeAbsolute::GetUTC(), God, Guest, confdata::guest_char, GUEST_PASSWORD, confdata::guest_prefix, H_GUEST, H_REGISTRATION, descriptor_data::host_info, descriptor_data::input_tot, local_connect(), LOG_LOGIN, log_name(), log_name_and_loc(), LOG_PCREATES, LOG_SECURITY, log_text(), confdata::max_players, move_object(), mudconf, mudstate, NOTHING, parse_connect(), descriptor_data::player, descriptor_data::program_data, queue_write(), queue_write_LEN(), R_BADLOGIN, R_GAMEDOWN, R_GAMEFULL, shutdownsock(), confdata::start_room, STARTLOG, string_prefix(), descriptor_data::username, welcome_user(), Wizard, WizRoy, and flagset::word.
Referenced by do_command().
01955 { 01956 char *buff; 01957 dbref player, aowner; 01958 int aflags, nplayers; 01959 DESC *d2; 01960 const char *p; 01961 bool isGuest = false; 01962 01963 char *cmdsave = mudstate.debug_cmd; 01964 mudstate.debug_cmd = (char *)"< check_connect >"; 01965 01966 // Hide the password length from SESSION. 01967 // 01968 d->input_tot -= (strlen(msg) + 1); 01969 01970 // Crack the command apart. 01971 // 01972 char *command = alloc_lbuf("check_conn.cmd"); 01973 char *user = alloc_lbuf("check_conn.user"); 01974 char *password = alloc_lbuf("check_conn.pass"); 01975 parse_connect(msg, command, user, password); 01976 01977 // At this point, command, user, and password are all less than 01978 // MBUF_SIZE. 01979 // 01980 if ( strncmp(command, "co", 2) == 0 01981 || strncmp(command, "cd", 2) == 0) 01982 { 01983 if (string_prefix(user, mudconf.guest_prefix)) 01984 { 01985 if ( (d->host_info & H_GUEST) 01986 || ( !mudconf.allow_guest_from_registered_site 01987 && (d->host_info & H_REGISTRATION))) 01988 { 01989 // Someone from an IP with guest restrictions is 01990 // trying to use a guest account. Give them the blurb 01991 // most likely to have instructions about requesting a 01992 // character by other means and then fail this 01993 // connection. 01994 // 01995 // The guest 'power' is handled separately further 01996 // down. 01997 // 01998 failconn("CONN", "Connect", "Guest Site Forbidden", d, 01999 R_GAMEDOWN, NOTHING, FC_CONN_REG, mudconf.downmotd_msg, 02000 command, user, password, cmdsave); 02001 return false; 02002 } 02003 if ( mudconf.guest_char != NOTHING 02004 && (mudconf.control_flags & CF_LOGIN)) 02005 { 02006 if (!(mudconf.control_flags & CF_GUEST)) 02007 { 02008 queue_write(d, "Guest logins are disabled.\r\n"); 02009 free_lbuf(command); 02010 free_lbuf(user); 02011 free_lbuf(password); 02012 return false; 02013 } 02014 02015 if ((p = Guest.Create(d)) == NULL) 02016 { 02017 queue_write(d, "All guests are tied up, please try again later.\r\n"); 02018 free_lbuf(command); 02019 free_lbuf(user); 02020 free_lbuf(password); 02021 return false; 02022 } 02023 strcpy(user, p); 02024 strcpy(password, GUEST_PASSWORD); 02025 isGuest = true; 02026 } 02027 } 02028 02029 // See if this connection would exceed the max #players. 02030 // 02031 if (mudconf.max_players < 0) 02032 { 02033 nplayers = mudconf.max_players - 1; 02034 } 02035 else 02036 { 02037 nplayers = 0; 02038 DESC_ITER_CONN(d2) 02039 { 02040 nplayers++; 02041 } 02042 } 02043 02044 player = connect_player(user, password, d->addr, d->username, inet_ntoa((d->address).sin_addr)); 02045 if ( player == NOTHING 02046 || (!isGuest && Guest.CheckGuest(player))) 02047 { 02048 // Not a player, or wrong password. 02049 // 02050 queue_write(d, connect_fail); 02051 STARTLOG(LOG_LOGIN | LOG_SECURITY, "CON", "BAD"); 02052 buff = alloc_lbuf("check_conn.LOG.bad"); 02053 sprintf(buff, "[%u/%s] Failed connect to '%s'", d->descriptor, d->addr, user); 02054 log_text(buff); 02055 free_lbuf(buff); 02056 ENDLOG; 02057 if (--(d->retries_left) <= 0) 02058 { 02059 free_lbuf(command); 02060 free_lbuf(user); 02061 free_lbuf(password); 02062 shutdownsock(d, R_BADLOGIN); 02063 mudstate.debug_cmd = cmdsave; 02064 return false; 02065 } 02066 } 02067 else if ( ( (mudconf.control_flags & CF_LOGIN) 02068 && (nplayers < mudconf.