IdWhoIsServer.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 10423: IdWhoIsServer.pas
  11. {
  12. { Rev 1.0 2002.11.12 11:00:14 PM czhower
  13. }
  14. unit IdWhoIsServer;
  15. {
  16. 2000-Apr-19 Hadi Hariri
  17. Converted to Indy
  18. 13-JAN-2000 MTL: Moved to new Palette Scheme (Winshoes Servers)
  19. 5.13.99 Final Version
  20. ? [responds with the following]
  21. Please enter a name or a NIC handle, such as "Smith" or "SRI-NIC".
  22. Starting with a period forces a name-only search; starting with
  23. exclamation point forces handle-only. Examples:
  24. Smith [looks for name or handle SMITH]
  25. !SRI-NIC [looks for handle SRI-NIC only]
  26. .Smith, John
  27. [looks for name JOHN SMITH only]
  28. Adding "..." to the argument will match anything from that point,
  29. e.g. "ZU..." will match ZUL, ZUM, etc.
  30. To search for mailboxes, use one of these forms:
  31. Smith@ [looks for mailboxes with username SMITH]
  32. @Host [looks for mailboxes on HOST]
  33. Smith@Host
  34. Orig Author: Ozz Nixon (RFC 954)
  35. }
  36. interface
  37. uses
  38. Classes,
  39. IdAssignedNumbers,
  40. IdTCPServer;
  41. type
  42. TGetEvent = procedure(AThread: TIdPeerThread; ALookup: string) of object;
  43. TIdWhoIsServer = class(TIdTCPserver)
  44. protected
  45. FOnCommandLookup: TGetEvent;
  46. //
  47. function DoExecute(AThread: TIdPeerThread): boolean; override;
  48. public
  49. constructor Create(AOwner: TComponent); override;
  50. published
  51. property OnCommandLookup: TGetEvent read FOnCommandLookup write FOnCommandLookup;
  52. property DefaultPort default IdPORT_WHOIS;
  53. end;
  54. implementation
  55. { TIdWhoIsServer }
  56. constructor TIdWhoIsServer.Create(AOwner: TComponent);
  57. begin
  58. inherited;
  59. DefaultPort := IdPORT_WHOIS;
  60. end;
  61. function TIdWhoIsServer.DoExecute(AThread: TIdPeerThread): boolean;
  62. var
  63. LRequest: string;
  64. begin
  65. Result := True;
  66. with AThread.Connection do begin
  67. // Get the domain name the client is inquiring about
  68. LRequest := ReadLn;
  69. if Assigned(OnCommandLookup) then begin
  70. OnCommandLookup(AThread, LRequest);
  71. end;
  72. Disconnect;
  73. end;
  74. end;
  75. end.