From 75a6b7fb2c3063c2419ecba1c4a69753e91345bd Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Mon, 27 Feb 2012 11:14:27 -0500 Subject: [PATCH] SMTP config + timeout configurable. Additional MPL debug logging, record format change for SMTP stuff --- mystic/109to110.pas | 13 +++--- mystic/HISTORY.txt | 2 + mystic/bbs_cfg_main.pas | 1 + mystic/bbs_cfg_syscfg.pas | 31 ++++++++++++++ mystic/mis_client_smtp.pas | 5 +-- mystic/mpl_execute.pas | 85 ++++++++++++++++++++++++++++++++++---- mystic/mystic.pas | 12 +++--- mystic/records.pas | 3 +- mystic/todo.pas | 3 ++ 9 files changed, 133 insertions(+), 22 deletions(-) diff --git a/mystic/109to110.pas b/mystic/109to110.pas index 414db42..7a01b12 100644 --- a/mystic/109to110.pas +++ b/mystic/109to110.pas @@ -588,6 +588,7 @@ Begin Config.inetTNNodes := MaxNode; Config.inetSMTPDupes := 1; + Config.inetSMTPTimeout := 120; Config.inetPOP3Dupes := 1; Config.inetPOP3Delete := False; @@ -1193,17 +1194,17 @@ Begin WarningDisplay; //COMMENT this out if mystic.dat is being converted: - Assign (ConfigFile, 'mystic.dat'); - Reset (ConfigFile); - Read (ConfigFile, Config); - Close (ConfigFile); +// Assign (ConfigFile, 'mystic.dat'); +// Reset (ConfigFile); +// Read (ConfigFile, Config); +// Close (ConfigFile); -// ConvertConfig; //1.10a11 + ConvertConfig; //1.10a11 // ConvertUsers; //1.10a11 //ConvertSecurity; //1.10a11 //ConvertFileLists; //1.10a11 //ConvertFileBases; //1.10a11 -ConvertMessageBases; //1.10a11 +//ConvertMessageBases; //1.10a11 // ConvertArchives; //1.10a1 // ConvertGroups; //1.10a1 diff --git a/mystic/HISTORY.txt b/mystic/HISTORY.txt index 9641689..54bd3e8 100644 --- a/mystic/HISTORY.txt +++ b/mystic/HISTORY.txt @@ -3900,3 +3900,5 @@ + Added new ANSI message base editor. + Added new ANSI security level editor. + + + SMTP server now has a configurable timeout value per session (in seconds) diff --git a/mystic/bbs_cfg_main.pas b/mystic/bbs_cfg_main.pas index 655c194..54b5c37 100644 --- a/mystic/bbs_cfg_main.pas +++ b/mystic/bbs_cfg_main.pas @@ -243,6 +243,7 @@ Begin '1' : Configuration_TelnetServer; '2' : Configuration_FTPServer; '3' : Configuration_POP3Server; + '4' : Configuration_SMTPServer; 'X' : Break; Else MenuPtr := 0; diff --git a/mystic/bbs_cfg_syscfg.pas b/mystic/bbs_cfg_syscfg.pas index ad5a590..72d982a 100644 --- a/mystic/bbs_cfg_syscfg.pas +++ b/mystic/bbs_cfg_syscfg.pas @@ -14,6 +14,7 @@ Procedure Configuration_Internet; Procedure Configuration_FTPServer; Procedure Configuration_TelnetServer; Procedure Configuration_POP3Server; +Procedure Configuration_SMTPServer; Implementation @@ -414,4 +415,34 @@ Begin Box.Free; End; +Procedure Configuration_SMTPServer; +Var + Box : TAnsiMenuBox; + Form : TAnsiMenuForm; + Topic : String[80]; +Begin + Topic := '|03(|09SMTP Server|03) |01-|09> |15'; + + Box := TAnsiMenuBox.Create; + Form := TAnsiMenuForm.Create; + + Box.Header := ' SMTP Server '; + + Box.Open (27, 8, 53, 16); + + VerticalLine (45, 10, 14); + + Form.AddBol ('U', ' Use Server', 33, 10, 47, 10, 12, 3, @Config.inetSMTPUse, Topic + 'Enable SMTP server'); + Form.AddWord ('P', ' Server Port', 32, 11, 47, 11, 13, 5, 0, 65535, @Config.inetSMTPPort, Topic + 'Server port'); + Form.AddByte ('N', ' Max Connections', 28, 12, 47, 12, 17, 3, 1, 255, @Config.inetSMTPMax, Topic + 'Max Connections'); + Form.AddByte ('I', ' Dupe IP Limit', 30, 13, 47, 13, 15, 3, 1, 255, @Config.inetSMTPDupes, Topic + 'Max connections with same IP'); + Form.AddWord ('T', ' Timeout', 36, 14, 47, 14, 9, 5, 0, 65535, @Config.inetSMTPTimeout, Topic + 'Connection timeout (seconds)'); + + Form.Execute; + Form.Free; + + Box.Close; + Box.Free; +End; + End. diff --git a/mystic/mis_client_smtp.pas b/mystic/mis_client_smtp.pas index 48c686c..70a0991 100644 --- a/mystic/mis_client_smtp.pas +++ b/mystic/mis_client_smtp.pas @@ -52,8 +52,7 @@ Type Implementation Const - SMTPTimeOut = 120; { MCFG } - SMTPHackThresh = 10000; + SMTPHackThresh = 10000; re_Goodbye = '221 Goodbye'; re_UnknownCmd = '502 Unknown command'; @@ -292,7 +291,7 @@ Begin Client.WriteLine('220 ' + bbsConfig.iNetDomain + ' Mystic SMTP Ready'); Repeat - If Client.WaitForData(SMTPTimeOut * 1000) = 0 Then Break; + If Client.WaitForData(bbsConfig.inetSMTPTimeout * 1000) = 0 Then Break; If Terminated Then Exit; diff --git a/mystic/mpl_execute.pas b/mystic/mpl_execute.pas index 40d3016..be89975 100644 --- a/mystic/mpl_execute.pas +++ b/mystic/mpl_execute.pas @@ -43,6 +43,9 @@ Type SavedMCI : Boolean; SavedGroup : Boolean; SavedArrow : Boolean; + {$IFDEF LOGGING} + Depth : LongInt; + {$ENDIF} Function GetErrorMsg : String; Procedure Error (Err: Byte; Str: String); @@ -98,6 +101,10 @@ Type Constructor Create (O: Pointer); Destructor Destroy; Override; Function Execute (FN: String) : Byte; + + {$IFDEF LOGGING} + Procedure LogVarInformation (Num: LongInt); + {$ENDIF} End; Function ExecuteMPL (Owner: Pointer; Str: String) : Byte; @@ -116,6 +123,35 @@ Uses {$I MPL_COMMON.PAS} +{$IFDEF LOGGING} +Procedure TInterpEngine.LogVarInformation (Num: LongInt); +Begin + Session.SystemLog(' DUMP VAR ' + strI2S(Num)); + + With VarData[Num]^ Do Begin + Session.SystemLog(' ID: ' + strI2S(VarID)); + Session.SystemLog(' Type: ' + strI2S(Ord(vType))); + Session.SystemLog(' DataSize: ' + strI2S(DataSize)); + Session.SystemLog(' VarSize: ' + strI2S(VarSize)); + Session.SystemLog(' Kill: ' + strI2S(Ord(Kill))); + + If Data <> NIL Then + Session.SystemLog(' Data: Assigned') + Else + Session.SystemLog(' Data: NIL'); + End; + +// Params : Array[1..mplMaxProcParams] of Char; +// NumParams : Byte; +// pID : Array[1..mplMaxProcParams] of Word; +// ProcPos : LongInt; +// Data : PStack; +// ArrPos : Byte; +// ArrDim : TArrayInfo; + +End; +{$ENDIF} + Procedure TInterpEngine.GetUserVars (Var U: RecUser); Begin Move (U.PermIdx, VarData[IdxVarUser ]^.Data^, SizeOf(U.PermIdx)); @@ -261,6 +297,10 @@ Begin ErrStr := ''; Ch := #0; W := 0; + + {$IFDEF LOGGING} + Depth := 0; + {$ENDIF} End; Destructor TInterpEngine.Destroy; @@ -1116,6 +1156,10 @@ Begin // or a predefined procedure from mpl_common. If VarData[VarNum]^.ProcPos > 0 Then Begin + {$IFDEF LOGGING} + Session.SystemLog(' Custom Proc: ' + strI2S(ProcID)); + {$ENDIF} + Sub := CurFilePos; SavedVar := CurVarNum; @@ -1209,7 +1253,7 @@ Begin // execution speed? {$IFDEF LOGGING} - Session.SystemLog('MPE ProcID: ' + strI2S(ProcID)); + Session.SystemLog(' Internal Proc: ' + strI2S(ProcID)); {$ENDIF} Case ProcID of @@ -1983,6 +2027,11 @@ Var Begin Result := 0; + {$IFDEF LOGGING} + Inc(Depth); + Session.SystemLog('[' + strI2S(Depth) + '] ExecBlock BEGIN Var: ' + strI2S(StartVar) + ' Rec: ' + strI2S(StartRec)); + {$ENDIF} + NextChar; // block begin character... can we ignore it? at least for case_else NextWord; // or just have case else ignore the begin at the compiler level // but still output the begin @@ -2060,19 +2109,31 @@ Begin Until (ErrNum <> 0) or Done or DataFile^.EOF; {$IFDEF LOGGING} - Session.SystemLog('MPE: Kill Block Vars'); + Session.SystemLog('[' + strI2S(Depth) + '] ExecBlock KILL VAR: ' + strI2S(CurVarNum) + ' to ' + strI2S(StartVar + 1)); {$ENDIF} For Count := CurVarNum DownTo StartVar + 1 Do Begin - If (VarData[Count]^.Kill) And (VarData[Count]^.Data <> NIL) Then begin + {$IFDEF LOGGING} + LogVarInformation(Count); + {$ENDIF} + + If (VarData[Count]^.Kill) And (VarData[Count]^.Data <> NIL) Then Begin FreeMem(VarData[Count]^.Data, VarData[Count]^.DataSize); - end; + + {$IFDEF LOGGING} + Session.SystemLog(' FreeMem ' + strI2S(Count)); + {$ENDIF} + End; + + {$IFDEF LOGGING} + Session.SystemLog(' Dispose ' + strI2S(Count)); + {$ENDIF} Dispose (VarData[Count]); End; {$IFDEF LOGGING} - Session.SystemLog('MPE: Kill Block Done'); + Session.SystemLog('[' + strI2S(Depth) + '] ExecBlock KILL REC: ' + strI2S(CurRecNum) + ' to ' + strI2S(StartRec + 1)); {$ENDIF} For Count := CurRecNum DownTo StartRec + 1 Do @@ -2082,6 +2143,11 @@ Begin CurVarNum := StartVar; CurRecNum := StartRec; + + {$IFDEF LOGGING} + Session.SystemLog('[' + strI2S(Depth) + '] ExecBlock END'); + Dec (Depth); + {$ENDIF} End; Function TInterpEngine.Execute (FN: String) : Byte; @@ -2119,6 +2185,7 @@ Begin If Not DataFile^.Open(FN) Then Begin Dispose(DataFile, Done); + Exit; End; @@ -2126,8 +2193,10 @@ Begin If DataFile^.FileSize < mplVerLength Then Begin DataFile^.Close; - Error (mpxInvalidFile, FN); + + Error (mpxInvalidFile, FN); Dispose (DataFile, Done); + Exit; End; @@ -2136,8 +2205,10 @@ Begin If VerStr <> mplVersion Then Begin DataFile^.Close; - Error (mpxVerMismatch, VerStr); + + Error (mpxVerMismatch, VerStr); Dispose (DataFile, Done); + Exit; End; diff --git a/mystic/mystic.pas b/mystic/mystic.pas index f386512..1e7e725 100644 --- a/mystic/mystic.pas +++ b/mystic/mystic.pas @@ -119,12 +119,14 @@ Begin DirClean (Session.TempPath, ''); - {$IFNDEF UNIX} - Screen.TextAttr := 14; - Screen.SetWindow (1, 1, 80, 25, False); - Screen.ClearScreen; + {$IFNDEF LOGGING} + {$IFNDEF UNIX} + Screen.TextAttr := 14; + Screen.SetWindow (1, 1, 80, 25, False); + Screen.ClearScreen; - Screen.WriteLine ('Exiting with Errorlevel ' + strI2S(ExitCode)); + Screen.WriteLine ('Exiting with Errorlevel ' + strI2S(ExitCode)); + {$ENDIF} {$ENDIF} DisposeClasses; diff --git a/mystic/records.pas b/mystic/records.pas index 4da6486..9663d98 100644 --- a/mystic/records.pas +++ b/mystic/records.pas @@ -219,6 +219,7 @@ Type inetSMTPPort : Word; inetSMTPMax : Word; inetSMTPDupes : Byte; + inetSMTPTimeOut : Word; inetPOP3Use : Boolean; inetPOP3Port : Word; inetPOP3Max : Word; @@ -242,7 +243,7 @@ Type inetNNTPMax : Word; inetNNTPDupes : Byte; // UNSORTED - Reserved : Array[1..486] of Char; + Reserved : Array[1..484] of Char; End; Const diff --git a/mystic/todo.pas b/mystic/todo.pas index 47d10f4..1928df9 100644 --- a/mystic/todo.pas +++ b/mystic/todo.pas @@ -19,6 +19,9 @@ BUGS AND POSSIBLE ISSUES the CPU requirement for new versions. Or just tell people the code is already available GPL and let them compile it if it is a problem? ! RAR internal viewer does not work with files that have embedded comments +! Investigate strange crashing when Mystic is built in the FPC editor vs + the makewin script. Something is out of whack with compiler options? OR + FPC BUG? DirAttr is suspect in MPL is it 1 byte or 4 in size? FUTURE / IDEAS / WORK IN PROGRESS / NOTES =========================================