IdWhoIsServer.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. IdAssignedNumbers,
  56. IdContext,
  57. IdCustomTCPServer;
  58. type
  59. TGetEvent = procedure(AContext:TIdContext; ALookup: string; var VResponse : String) of object;
  60. TIdWhoIsServer = class(TIdCustomTCPserver)
  61. protected
  62. FOnCommandLookup: TGetEvent;
  63. //
  64. function DoExecute(AContext:TIdContext): boolean; override;
  65. procedure InitComponent; override;
  66. published
  67. property OnCommandLookup: TGetEvent read FOnCommandLookup write FOnCommandLookup;
  68. property DefaultPort default IdPORT_WHOIS;
  69. end;
  70. implementation
  71. { TIdWhoIsServer }
  72. procedure TIdWhoIsServer.InitComponent;
  73. begin
  74. inherited;
  75. DefaultPort := IdPORT_WHOIS;
  76. end;
  77. function TIdWhoIsServer.DoExecute(AContext:TIdContext): boolean;
  78. var
  79. LRequest, VResponse: string;
  80. begin
  81. Result := True;
  82. // Get the domain name the client is inquiring about
  83. LRequest := AContext.Connection.IOHandler.ReadLn;
  84. if Assigned(OnCommandLookup) then begin
  85. OnCommandLookup(AContext, LRequest, VResponse);
  86. AContext.Connection.IOHandler.Write(VResponse);
  87. end;
  88. AContext.Connection.Disconnect;
  89. end;
  90. end.