From 6562c7a5103e31ccabe8117486a93303b80f470b Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Sun, 2 Sep 2012 21:14:10 -0400 Subject: [PATCH] MIS nodenumber fix, Mystic auto generates node in Windows --- mystic/HISTORY.txt | 15 ++++++ mystic/bbs_core.pas | 4 +- mystic/bbs_msgbase.pas | 2 +- mystic/mis.pas | 6 ++- mystic/mis_client_telnet.pas | 10 +--- mystic/mis_nodedata.pas | 30 ++++++++++++ mystic/mystic.pas | 90 ++++++++++++++++++------------------ mystic/todo.pas | 2 + 8 files changed, 101 insertions(+), 58 deletions(-) diff --git a/mystic/HISTORY.txt b/mystic/HISTORY.txt index bc765f4..4931043 100644 --- a/mystic/HISTORY.txt +++ b/mystic/HISTORY.txt @@ -4708,3 +4708,18 @@ ! Fixed a bug which could sometimes cause a node to get disconnected just after MIS answered the all in Windows. + + + If the user has zero downloads and uploads, Mystic will now allow them to + transfer one file for "free" (either a download or an upload) before the + ratio tracking comes into play. + + ! Sysop chat hours now function as expected. This was broken somewhere + around the 1.09 era. + + ! Fixed bugs with MIS calculating the wrong node number if a user was + logged in locally in Windows. + + + Mystic in non-Unix will not assign an available node number automatically + similar to how it works in a Unix environment. This will help prevent + a person from accidentally logging into a node that is being used during + a local login. diff --git a/mystic/bbs_core.pas b/mystic/bbs_core.pas index bb905f0..742985b 100644 --- a/mystic/bbs_core.pas +++ b/mystic/bbs_core.pas @@ -112,12 +112,12 @@ Begin ShutDown := False; CommHandle := -1; LocalMode := False; - Baud := -1; + Baud := 38400; ExitLevel := 0; EventWarn := False; EventExit := False; EventRunAfter := False; - NodeNum := 1; + NodeNum := 0; UserHostInfo := ''; UserIPInfo := ''; CheckTimeOut := True; diff --git a/mystic/bbs_msgbase.pas b/mystic/bbs_msgbase.pas index 00c5e59..f460bd2 100644 --- a/mystic/bbs_msgbase.pas +++ b/mystic/bbs_msgbase.pas @@ -1203,7 +1203,7 @@ Var Addr : RecEchoMailAddr; Begin Result := False; - Session.User.IgnoreGroup := True; + Session.User.IgnoreGroup := True; Repeat If IsCopy Then diff --git a/mystic/mis.pas b/mystic/mis.pas index 47879ae..a84d628 100644 --- a/mystic/mis.pas +++ b/mystic/mis.pas @@ -110,6 +110,7 @@ Begin DirChange(bbsConfig.SystemPath); End; +(* Procedure ReadChatData; Var ChatFile : File of ChatRec; @@ -137,6 +138,7 @@ Begin End; End; End; +*) Function GetFocusPtr : TServerManager; Begin @@ -160,7 +162,7 @@ Var Begin If FocusPtr = NIL Then Exit; - ReadChatData; + NodeData.SynchronizeNodeData; PosY := 0; @@ -172,7 +174,7 @@ Begin If Count = BarPos Then Attr := 31 Else Attr := 7; Case FocusCurrent of - 0 : If (Count <= FocusPtr.ClientList.Count) And (FocusPtr.ClientList[Count - 1] <> NIL) Then Begin + 0 : If NI.Busy Then Begin Console.WriteXY (3, 3 + PosY, Attr, strPadL(strI2S(NI.Num), 3, '0') + ' ' + strPadR(NI.User, 12, ' ') + ' ' + diff --git a/mystic/mis_client_telnet.pas b/mystic/mis_client_telnet.pas index c453518..74137a8 100644 --- a/mystic/mis_client_telnet.pas +++ b/mystic/mis_client_telnet.pas @@ -106,14 +106,11 @@ End; {$IFDEF UNIX} Procedure TTelnetServer.Execute; -Const - BufferSize = 4096; Var Cmd : String; Num : LongInt; NI : TNodeInfoRec; Proc : TProcess; -// Buffer : Array[1..BufferSize] of Char; Buffer : TIOBuffer; bRead : LongInt; bWrite : LongInt; @@ -141,15 +138,12 @@ Begin While Proc.Running Do Begin If Proc.Output.NumBytesAvailable > 0 Then Begin While Proc.Output.NumBytesAvailable > 0 Do Begin - bRead := Proc.Output.Read(Buffer, BufferSize); + bRead := Proc.Output.Read(Buffer, TIOBufferSize); Client.WriteBufEscaped (Buffer, bRead); - -// If Snooping Then -// Term.ProcessBuf(Buffer[0], bRead); End; End Else If Client.DataWaiting Then Begin - bWrite := Client.ReadBuf(Buffer, BufferSize); + bWrite := Client.ReadBuf(Buffer, TIOBufferSize); If bWrite < 0 Then Break; diff --git a/mystic/mis_nodedata.pas b/mystic/mis_nodedata.pas index 2c5c63b..e8be36a 100644 --- a/mystic/mis_nodedata.pas +++ b/mystic/mis_nodedata.pas @@ -25,6 +25,8 @@ Type Constructor Create (Nodes: Byte); Destructor Destroy; Override; + + Procedure SynchronizeNodeData; Function GetNodeTotal : LongInt; Function GetNodeInfo (Num: Byte; Var NI: TNodeInfoRec): Boolean; Procedure SetNodeInfo (Num: Byte; NI: TNodeInfoRec); @@ -37,6 +39,32 @@ Uses m_FileIO, m_Strings; +Procedure TNodeData.SynchronizeNodeData; +Var + ChatFile : File of ChatRec; + Chat : ChatRec; + Count : LongInt; + NI : TNodeInfoRec; +Begin + For Count := 1 to NodeTotal Do Begin + GetNodeInfo(Count, NI); + + Assign (ChatFile, bbsConfig.DataPath + 'chat' + strI2S(NI.Num) + '.dat'); + + If ioReset(ChatFile, SizeOf(ChatRec), fmRWDN) Then Begin + ioRead (ChatFile, Chat); + Close (ChatFile); + + NI.Busy := Chat.Active; + NI.User := Chat.Name; + NI.Action := Chat.Action; + End Else + NI.Busy := False; + + SetNodeInfo(NI.Num, NI); + End; +End; + Function TNodeData.GetFreeNode : LongInt; Var Count : LongInt; @@ -103,6 +131,8 @@ Begin For Count := 1 to NodeTotal Do NodeInfo[Count].Num := Count; + + SynchronizeNodeData; End; Destructor TNodeData.Destroy; diff --git a/mystic/mystic.pas b/mystic/mystic.pas index b82d3c9..73ed1be 100644 --- a/mystic/mystic.pas +++ b/mystic/mystic.pas @@ -155,6 +155,33 @@ Begin End; End; +Procedure CalculateNodeNumber; +Var + Count : Word; + TChat : ChatRec; +Begin + Session.NodeNum := 0; + + For Count := 1 to Config.INetTNNodes Do Begin + Assign (ChatFile, Config.DataPath + 'chat' + strI2S(Count) + '.dat'); + + If Not ioReset (ChatFile, Sizeof(ChatRec), fmRWDN) Then Begin + Session.NodeNum := Count; + + Break; + End Else Begin + ioRead (ChatFile, TChat); + Close (ChatFile); + + If Not TChat.Active Then Begin + Session.NodeNum := Count; + + Break; + End; + End; + End; +End; + {$IFDEF UNIX} Procedure LinuxEventSignal (Sig : LongInt); cdecl; Begin @@ -179,10 +206,9 @@ Begin End; End; -Procedure Linux_Init; +Procedure InitializeUnix; Var Count : Word; - TChat : ChatRec; Info : Stat; Begin If fpStat('mystic', Info) = 0 Then Begin @@ -190,35 +216,6 @@ Begin fpSetUID (Info.st_UID); End; - Session.NodeNum := 0; - - For Count := 1 to Config.INetTNNodes Do Begin - Assign (ChatFile, Config.DataPath + 'chat' + strI2S(Count) + '.dat'); - - {$I-} Reset(ChatFile); {$I+} - - If IoResult <> 0 Then Begin - Session.NodeNum := Count; - Break; - End; - - Read (ChatFile, TChat); - Close (ChatFile); - - If Not TChat.Active Then Begin - Session.NodeNum := Count; - Break; - End; - End; - - If Session.NodeNum = 0 Then Begin - WriteLn ('BUSY'); {++lang} - - DisposeClasses; - - Halt; - End; - fpSignal (SIGTERM, LinuxEventSignal); fpSignal (SIGHUP, LinuxEventSignal); @@ -371,14 +368,12 @@ Begin For Count := 1 to ParamCount Do Begin Temp := strUpper(ParamStr(Count)); - If Copy(Temp, 1, 4) = '-TID' Then Begin - Session.CommHandle := strS2I(Copy(Temp, 5, Length(Temp))); - Session.Baud := 38400; - End Else - If Copy(Temp, 1, 2) = '-B' Then Begin - Session.Baud := strS2I(Copy(Temp, 3, Length(Temp))); - If Session.Baud = 0 Then Session.LocalMode := True; - End Else + If Copy(Temp, 1, 4) = '-TID' Then + Session.CommHandle := strS2I(Copy(Temp, 5, Length(Temp))) + Else + If Copy(Temp, 1, 2) = '-B' Then + Session.Baud := strS2I(Copy(Temp, 3, Length(Temp))) + Else If Copy(Temp, 1, 2) = '-T' Then Session.TimeOffset := strS2I(Copy(Temp, 3, Length(Temp))) Else @@ -411,13 +406,20 @@ Begin If Temp = '-L' Then Session.LocalMode := True; End; - FileMode := 66; - {$IFDEF UNIX} - Linux_Init; - Session.Baud := 38400; + InitializeUnix; {$ENDIF} + If Session.NodeNum = 0 Then CalculateNodeNumber; + + If Session.NodeNum = 0 Then Begin + WriteLn ('BUSY'); + + DisposeClasses; + + Halt; + End; + CheckPathsAndDataFiles; {$IFNDEF UNIX} @@ -450,8 +452,6 @@ Begin Else Session.SetTimeLeft(Config.LoginTime); - If Session.Baud = -1 Then Session.Baud := 0; - {$IFNDEF UNIX} Screen.TextAttr := 7; Screen.ClearScreen; diff --git a/mystic/todo.pas b/mystic/todo.pas index c5074e1..63347e6 100644 --- a/mystic/todo.pas +++ b/mystic/todo.pas @@ -21,10 +21,12 @@ BUGS AND POSSIBLE ISSUES ! Test MIS blocking features or just rewrite MIS completely. ! Test midnight rollovers for time (flag for user to be immune to timecheck) ! Elasped time will need to be recalculated based on flag above ^^ +! Validate that "groupX.ans" and "fgroupX.ans" actually work. FUTURE / IDEAS / WORK IN PROGRESS / NOTES ========================================= +- Add better MIS logging per server (connect, refuse, blocked, etc) - BBS email autoforwarded to Internet email - Ability to send internet email to people from within the BBS. - ANSI post-processor for message uploads via FSE