NTTP server functional. AUTH and LIST commands completed
This commit is contained in:
parent
cfbb2840e0
commit
f74c99f392
|
@ -367,7 +367,7 @@ Begin
|
||||||
SMTPServer := TServerManager.Create(bbsConfig, bbsConfig.INetSMTPPort, bbsConfig.inetSMTPMax, NodeData, @CreateSMTP);
|
SMTPServer := TServerManager.Create(bbsConfig, bbsConfig.INetSMTPPort, bbsConfig.inetSMTPMax, NodeData, @CreateSMTP);
|
||||||
|
|
||||||
SMTPServer.Server.FTelnetServer := False;
|
SMTPServer.Server.FTelnetServer := False;
|
||||||
SMTPServer.ClientMaxIPs := 1;
|
SMTPServer.ClientMaxIPs := bbsConfig.INetSMTPDupes;
|
||||||
|
|
||||||
Started := True;
|
Started := True;
|
||||||
End;
|
End;
|
||||||
|
@ -394,7 +394,7 @@ Begin
|
||||||
NNTPServer := TServerManager.Create(bbsConfig, bbsConfig.InetNNTPPort, bbsConfig.inetNNTPMax, NodeData, @CreateNNTP);
|
NNTPServer := TServerManager.Create(bbsConfig, bbsConfig.InetNNTPPort, bbsConfig.inetNNTPMax, NodeData, @CreateNNTP);
|
||||||
|
|
||||||
NNTPServer.Server.FTelnetServer := False;
|
NNTPServer.Server.FTelnetServer := False;
|
||||||
NNTPServer.ClientMaxIPs := 1;
|
NNTPServer.ClientMaxIPs := bbsConfig.inetNNTPDupes;
|
||||||
|
|
||||||
Started := True;
|
Started := True;
|
||||||
End;
|
End;
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
{$I M_OPS.PAS}
|
|
||||||
|
|
||||||
Unit MIS_Client_NNTP;
|
Unit MIS_Client_NNTP;
|
||||||
|
|
||||||
// lookup:
|
{$I M_OPS.PAS}
|
||||||
// how to send greeting and goodbye?
|
|
||||||
// how to send capabilities so far only AUTHINFO
|
// RFC 977
|
||||||
// determine base feature-set required
|
|
||||||
|
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
|
@ -19,13 +16,13 @@ Uses
|
||||||
MIS_NodeData,
|
MIS_NodeData,
|
||||||
MIS_Common;
|
MIS_Common;
|
||||||
|
|
||||||
Function CreateNNTP (Owner: TServerManager; ND: TNodeData; CliSock: TSocketClass) : TServerClient;
|
Function CreateNNTP (Owner: TServerManager; Config: RecConfig; ND: TNodeData; CliSock: TSocketClass) : TServerClient;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TNNTPServer = Class(TServerClient)
|
TNNTPServer = Class(TServerClient)
|
||||||
Server : TServerManager;
|
Server : TServerManager;
|
||||||
UserName : String[40];
|
UserName : String[30];
|
||||||
Password : String[20];
|
Password : String[15];
|
||||||
LoggedIn : Boolean;
|
LoggedIn : Boolean;
|
||||||
Cmd : String;
|
Cmd : String;
|
||||||
Data : String;
|
Data : String;
|
||||||
|
@ -36,19 +33,28 @@ Type
|
||||||
Procedure Execute; Override;
|
Procedure Execute; Override;
|
||||||
Destructor Destroy; Override;
|
Destructor Destroy; Override;
|
||||||
|
|
||||||
|
Procedure ClientWriteLine (Str: String);
|
||||||
|
|
||||||
Procedure ResetSession;
|
Procedure ResetSession;
|
||||||
|
|
||||||
Procedure cmd_AUTHINFO;
|
Procedure cmd_AUTHINFO;
|
||||||
|
Procedure cmd_GROUP;
|
||||||
|
Procedure cmd_LIST;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
|
Uses
|
||||||
|
bbs_MsgBase_ABS,
|
||||||
|
bbs_MsgBase_JAM,
|
||||||
|
bbs_MsgBase_Squish;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
NNTPTimeOut = 180; // make configurable
|
FileReadBuffer = 2048;
|
||||||
|
|
||||||
re_Greeting = 'Mystic BBS NNTP Server';
|
|
||||||
re_Goodbye = 'Goodbye';
|
|
||||||
|
|
||||||
|
re_Greeting = '200 Mystic BBS NNTP server ready';
|
||||||
|
re_Goodbye = '205 Goodbye';
|
||||||
|
re_ListFollows = '215 List of newsgroups follows';
|
||||||
re_AuthOK = '281 Authentication accepted';
|
re_AuthOK = '281 Authentication accepted';
|
||||||
re_AuthBad = '381 Authentication rejected';
|
re_AuthBad = '381 Authentication rejected';
|
||||||
re_AuthPass = '381 Password required';
|
re_AuthPass = '381 Password required';
|
||||||
|
@ -56,7 +62,7 @@ Const
|
||||||
re_Unknown = '500 Unknown command';
|
re_Unknown = '500 Unknown command';
|
||||||
re_UnknownOption = '501 Unknown option';
|
re_UnknownOption = '501 Unknown option';
|
||||||
|
|
||||||
Function CreateNNTP (Owner: TServerManager; ND: TNodeData; CliSock: TSocketClass) : TServerClient;
|
Function CreateNNTP (Owner: TServerManager; Config: RecConfig; ND: TNodeData; CliSock: TSocketClass) : TServerClient;
|
||||||
Begin
|
Begin
|
||||||
Result := TNNTPServer.Create(Owner, CliSock);
|
Result := TNNTPServer.Create(Owner, CliSock);
|
||||||
End;
|
End;
|
||||||
|
@ -68,6 +74,12 @@ Begin
|
||||||
Server := Owner;
|
Server := Owner;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Procedure TNNTPServer.ClientWriteLine (Str: String);
|
||||||
|
Begin
|
||||||
|
Server.Server.Status('S:' + Str);
|
||||||
|
Client.WriteLine(Str);
|
||||||
|
End;
|
||||||
|
|
||||||
Procedure TNNTPServer.ResetSession;
|
Procedure TNNTPServer.ResetSession;
|
||||||
Begin
|
Begin
|
||||||
LoggedIn := False;
|
LoggedIn := False;
|
||||||
|
@ -81,29 +93,91 @@ Var
|
||||||
NewCmd : String;
|
NewCmd : String;
|
||||||
NewData : String;
|
NewData : String;
|
||||||
Begin
|
Begin
|
||||||
ResetSession;
|
|
||||||
|
|
||||||
NewCmd := strWordGet(1, Data, ' ');
|
NewCmd := strWordGet(1, Data, ' ');
|
||||||
NewData := Copy(Data, Pos(' ', Data) + 1, 255);
|
NewData := Copy(Data, Pos(' ', Data) + 1, 255);
|
||||||
|
|
||||||
If NewCmd = 'USER' Then Begin
|
If NewCmd = 'USER' Then Begin
|
||||||
If SearchForUser(NewData, User, UserPos) Then Begin
|
If SearchForUser(NewData, User, UserPos) Then Begin
|
||||||
Client.WriteLine(re_AuthPass);
|
ClientWriteLine(re_AuthPass);
|
||||||
UserName := NewData;
|
UserName := NewData;
|
||||||
End Else
|
End Else
|
||||||
Client.WriteLine(re_AuthBad);
|
ClientWriteLine(re_AuthBad);
|
||||||
End Else
|
End Else
|
||||||
If NewCmd = 'PASS' Then Begin
|
If NewCmd = 'PASS' Then Begin
|
||||||
If UserPos = -1 Then
|
If UserPos = -1 Then
|
||||||
Client.WriteLine(re_AuthSync)
|
ClientWriteLine(re_AuthSync)
|
||||||
Else
|
Else
|
||||||
If strUpper(NewData) = User.Password Then Begin
|
If strUpper(NewData) = User.Password Then Begin
|
||||||
Client.WriteLine(re_AuthOK);
|
ClientWriteLine(re_AuthOK);
|
||||||
LoggedIn := True;
|
LoggedIn := True;
|
||||||
End Else
|
End Else
|
||||||
Client.WriteLine(re_AuthBad);
|
ClientWriteLine(re_AuthBad);
|
||||||
End Else
|
End Else
|
||||||
Client.WriteLine(re_UnknownOption);
|
ClientWriteLine(re_UnknownOption);
|
||||||
|
|
||||||
|
If LoggedIn Then
|
||||||
|
Server.Server.Status('Logged in as ' + UserName);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure TNNTPServer.cmd_GROUP;
|
||||||
|
Begin
|
||||||
|
// 211 number_of_estimated_articles first_msg last_msg newsname
|
||||||
|
// 411 nosuchnewsgroup
|
||||||
|
// this selects the "current" base
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure TNNTPServer.cmd_LIST;
|
||||||
|
Var
|
||||||
|
MBaseFile : TBufFile;
|
||||||
|
TempBase : RecMessageBase;
|
||||||
|
MsgBase : PMsgBaseABS;
|
||||||
|
LowMessage : LongInt = 0;
|
||||||
|
HighMessage : LongInt = 0;
|
||||||
|
PostAbility : Char;
|
||||||
|
Begin
|
||||||
|
ClientWriteLine(re_ListFollows);
|
||||||
|
|
||||||
|
MBaseFile := TBufFile.Create(FileReadBuffer);
|
||||||
|
|
||||||
|
If MBaseFile.Open(bbsConfig.DataPath + 'mbases.dat', fmOpen, fmRWDN, SizeOf(RecMessageBase)) Then Begin
|
||||||
|
MBaseFile.Read(TempBase);
|
||||||
|
|
||||||
|
While Not MBaseFile.EOF Do Begin
|
||||||
|
MBaseFile.Read(TempBase);
|
||||||
|
|
||||||
|
If TempBase.NewsName = '' Then Continue;
|
||||||
|
|
||||||
|
If CheckAccess(User, True, TempBase.ListACS) Then Begin
|
||||||
|
LowMessage := 0;
|
||||||
|
HighMessage := 0;
|
||||||
|
|
||||||
|
Case CheckAccess(User, True, TempBase.PostACS) of
|
||||||
|
False : PostAbility := 'n';
|
||||||
|
True : PostAbility := 'y';
|
||||||
|
End;
|
||||||
|
|
||||||
|
Case TempBase.BaseType of
|
||||||
|
0 : MsgBase := New(PMsgBaseJAM, Init);
|
||||||
|
1 : MsgBase := New(PMsgBaseSquish, Init);
|
||||||
|
End;
|
||||||
|
|
||||||
|
MsgBase^.SetMsgPath (TempBase.Path + TempBase.FileName);
|
||||||
|
|
||||||
|
If MsgBase^.OpenMsgBase Then Begin
|
||||||
|
LowMessage := 1;
|
||||||
|
HighMessage := MsgBase^.GetHighActiveMsgNum;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Dispose (MsgBase, Done);
|
||||||
|
|
||||||
|
ClientWriteLine (TempBase.NewsName + ' ' + strI2S(LowMessage) + ' ' + strI2S(HighMessage) + ' ' + PostAbility);
|
||||||
|
End;
|
||||||
|
End;
|
||||||
|
End;
|
||||||
|
|
||||||
|
MBaseFile.Free;
|
||||||
|
|
||||||
|
ClientWriteLine('.');
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure TNNTPServer.Execute;
|
Procedure TNNTPServer.Execute;
|
||||||
|
@ -112,16 +186,16 @@ Var
|
||||||
Begin
|
Begin
|
||||||
ResetSession;
|
ResetSession;
|
||||||
|
|
||||||
Client.WriteLine(re_Greeting);
|
ClientWriteLine(re_Greeting);
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
If Client.WaitForData(NNTPTimeOut * 1000) = 0 Then Break;
|
If Client.WaitForData(bbsConfig.inetNNTPTimeout * 1000) = 0 Then Break;
|
||||||
|
|
||||||
If Terminated Then Exit;
|
If Terminated Then Exit;
|
||||||
|
|
||||||
If Client.ReadLine(Str) = -1 Then Exit;
|
If Client.ReadLine(Str) = -1 Then Exit;
|
||||||
|
|
||||||
//server.server.status(str);
|
Server.Server.Status('C:' + Str);
|
||||||
|
|
||||||
Cmd := strUpper(strWordGet(1, Str, ' '));
|
Cmd := strUpper(strWordGet(1, Str, ' '));
|
||||||
|
|
||||||
|
@ -131,11 +205,13 @@ Begin
|
||||||
Data := '';
|
Data := '';
|
||||||
|
|
||||||
If Cmd = 'AUTHINFO' Then cmd_AUTHINFO Else
|
If Cmd = 'AUTHINFO' Then cmd_AUTHINFO Else
|
||||||
If Cmd = 'QUIT' Then Break Else
|
If Cmd = 'GROUP' Then cmd_GROUP Else
|
||||||
Client.WriteLine(re_Unknown);
|
If Cmd = 'LIST' Then cmd_LIST Else
|
||||||
|
If Cmd = 'QUIT' Then Break Else
|
||||||
|
ClientWriteLine(re_Unknown);
|
||||||
Until Terminated;
|
Until Terminated;
|
||||||
|
|
||||||
If Not Terminated Then Client.WriteLine(re_Goodbye);
|
If Not Terminated Then ClientWriteLine(re_Goodbye);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Destructor TNNTPServer.Destroy;
|
Destructor TNNTPServer.Destroy;
|
||||||
|
@ -143,4 +219,4 @@ Begin
|
||||||
Inherited Destroy;
|
Inherited Destroy;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
End.
|
End.
|
||||||
|
|
Loading…
Reference in New Issue