IdWhoIsServer.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.5 12/2/2004 4:24:00 PM JPMugaas
  18. Adjusted for changes in Core.
  19. Rev 1.4 1/21/2004 4:21:18 PM JPMugaas
  20. InitComponent
  21. Rev 1.3 2/24/2003 10:39:58 PM JPMugaas
  22. Rev 1.2 1/17/2003 07:11:10 PM JPMugaas
  23. Now compiles under new framework.
  24. Rev 1.1 1/9/2003 06:55:54 AM JPMugaas
  25. Changed OnQueryEvent so users do not have to bother with WriteLn's in their
  26. events.
  27. Now works with IdContext.
  28. Rev 1.0 11/13/2002 08:04:48 AM JPMugaas
  29. }
  30. unit IdWhoIsServer;
  31. {
  32. 2000-Apr-19 Hadi Hariri
  33. Converted to Indy
  34. 13-JAN-2000 MTL: Moved to new Palette Scheme (Winshoes Servers)
  35. 5.13.99 Final Version
  36. ? [responds with the following]
  37. Please enter a name or a NIC handle, such as "Smith" or "SRI-NIC".
  38. Starting with a period forces a name-only search; starting with
  39. exclamation point forces handle-only. Examples:
  40. Smith [looks for name or handle SMITH]
  41. !SRI-NIC [looks for handle SRI-NIC only]
  42. .Smith, John
  43. [looks for name JOHN SMITH only]
  44. Adding "..." to the argument will match anything from that point,
  45. e.g. "ZU..." will match ZUL, ZUM, etc.
  46. To search for mailboxes, use one of these forms:
  47. Smith@ [looks for mailboxes with username SMITH]
  48. @Host [looks for mailboxes on HOST]
  49. Smith@Host
  50. Orig Author: Ozz Nixon (RFC 954)
  51. }
  52. interface
  53. {$i IdCompilerDefines.inc}
  54. uses
  55. Classes,
  56. IdAssignedNumbers,
  57. IdContext,
  58. IdCustomTCPServer;
  59. type
  60. TGetEvent = procedure(AContext:TIdContext; ALookup: string; var VResponse : String) of object;
  61. TIdWhoIsServer = class(TIdCustomTCPserver)
  62. protected
  63. FOnCommandLookup: TGetEvent;
  64. //
  65. function DoExecute(AContext:TIdContext): boolean; override;
  66. public
  67. constructor Create(AOwner: TComponent); override;
  68. published
  69. property OnCommandLookup: TGetEvent read FOnCommandLookup write FOnCommandLookup;
  70. property DefaultPort default IdPORT_WHOIS;
  71. end;
  72. implementation
  73. { TIdWhoIsServer }
  74. constructor TIdWhoIsServer.Create(AOwner: TComponent);
  75. begin
  76. inherited Create(AOwner);
  77. DefaultPort := IdPORT_WHOIS;
  78. end;
  79. function TIdWhoIsServer.DoExecute(AContext:TIdContext): boolean;
  80. var
  81. LRequest, VResponse: string;
  82. begin
  83. Result := True;
  84. // Get the domain name the client is inquiring about
  85. LRequest := AContext.Connection.IOHandler.ReadLn;
  86. if Assigned(OnCommandLookup) then begin
  87. OnCommandLookup(AContext, LRequest, VResponse);
  88. AContext.Connection.IOHandler.Write(VResponse);
  89. end;
  90. AContext.Connection.Disconnect;
  91. end;
  92. end.