IndySockets / Indy

Indy - Internet Direct
https://www.indyproject.org
461 stars 155 forks source link

Support Multiple Whois Servers :: TIdWhois #400

Open bouhlal opened 2 years ago

bouhlal commented 2 years ago

Can you add support for multiple whois servers in TIdWhois? https://www.nirsoft.net/whois-servers.txt

rlebeau commented 2 years ago

I don't see the point in doing that. TIdWhois is a TCP client, it can only connect to one TCP server at a time. If you want to query multiple servers, you would have to either connect to them one at a time, or else use multiple TIdWhois in parallel.

bouhlal commented 2 years ago

I mean to add All servers in Stringlist and indy WhoisClient chose the servers automatically from its extensions as ics Overbyte whois client do. please check the image: https://pasteboard.co/IVz3Xxym4dtu.png and check the source code of files how they do : http://svn.overbyte.be:8443/svn/ics/trunk/Source/OverbyteIcsWhoisCli.pas

rlebeau commented 2 years ago

I don't really see any value in adding that to Indy at this time, when you can simply handle that in your own code. Load a TStringList with servers, loop through it, calling TIdWhois.Whois() on each iteration as needed. And frankly, I don't understand the logic that ICS's Whois client is doing. It is doing more than just looping through a list of servers, it is performing multiple queries and matching them against the list to perform even more queries. What is it looking for exactly? An authorative server? I don't know. So, what is the point in trying to replicate something like that in Indy? That goes well beyond the documented WHOIS protocol spec.

bouhlal commented 2 years ago

You can copy this code and add it to indywhoisclient to be automatique it works fine :

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit,
  FMX.Controls.Presentation, FMX.StdCtrls, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdWhois, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    IdWhois1: TIdWhois;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    protected
    FWhoisServers       : TStringList;
    FHost               : String;
    procedure SetWhoisServers(const Value: TStringList);
    published
    property WhoisServers: TStringList              read  FWhoisServers
                                                    write SetWhoisServers;
    property Host  : String                         read  FHost
                                                    write FHost;
   end;
   const
   IcsSPACE           = #32;
   const
{
;WHOIS Servers List
;Maintained by Nir Sofer
;This servers list if freely available for any use and without any restriction.
;For more information: http://www.nirsoft.net/whois_servers_list.html
;Last updated on 16/02/2016  }

  WhoisNames: array [0..232] of PChar = (
    '?? whois.iana.org',      // specials, top level
    '00 whois.ripe.net',      // specials, European addresses
    '00 whois.arin.net',      // specials, Nothern American addresses
    '00 whois.apnic.net',     // specials, Far East addresses
    'com whois.verisign-grs.com', // moved common servers to top
    'org whois.pir.org',
    'net whois.verisign-grs.com',
    'uk whois.nic.uk',
    'ac whois.nic.ac',
    'ad whois.ripe.net',
    'ae whois.aeda.net.ae',
    'aero whois.aero',
    'af whois.nic.af',
    'ag whois.nic.ag',
    'ai whois.ai',
    'al whois.ripe.net',
    'am whois.amnic.net',
    'as whois.nic.as',
    'asia whois.nic.asia',
    'at whois.nic.at',
    'au whois.aunic.net',
    'aw whois.nic.aw',
    'ax whois.ax ',
    'az whois.ripe.net',
    'ba whois.ripe.net',
    'bar whois.nic.bar',
    'be whois.dns.be',
    'berlin whois.nic.berlin',
    'best whois.nic.best',
    'bg whois.register.bg',
    'bi whois.nic.bi',
    'biz whois.neulevel.biz',
    'bj www.nic.bj',
    'bo whois.nic.bo',
    'br whois.nic.br',
    'br.com whois.centralnic.com',
    'bt whois.netnames.net',
    'bw whois.nic.net.bw',
    'by whois.cctld.by',
    'bz whois.belizenic.bz',
    'bzh whois-bzh.nic.fr',
    'ca whois.cira.ca',
    'cat whois.cat',
    'cc whois.nic.cc',
    'cd whois.nic.cd',
    'ceo whois.nic.ceo',
    'cf whois.dot.cf',
    'ch whois.nic.ch ',
    'ci whois.nic.ci',
    'ck whois.nic.ck',
    'cl whois.nic.cl',
    'cloud whois.nic.cloud',
    'club whois.nic.club',
    'cn whois.cnnic.net.cn',
    'cn.com whois.centralnic.com',
    'co whois.nic.co',
    'co.nl whois.co.nl',
    'coop whois.nic.coop',
    'cx whois.nic.cx',
    'cy whois.ripe.net',
    'cz whois.nic.cz',
    'de whois.denic.de',
    'dk whois.dk-hostmaster.dk',
    'dm whois.nic.cx',
    'dz whois.nic.dz',
    'ec whois.nic.ec',
    'edu whois.educause.net',
    'ee whois.tld.ee',
    'eg whois.ripe.net',
    'es whois.nic.es',
    'eu whois.eu',
    'eu.com whois.centralnic.com',
    'eus whois.nic.eus',
    'fi whois.fi',
    'fo whois.nic.fo',
    'fr whois.nic.fr',
    'gb whois.ripe.net',
    'gb.com whois.centralnic.com',
    'gb.net whois.centralnic.com',
    'qc.com whois.centralnic.com',
    'ge whois.ripe.net',
    'gg whois.gg',
    'gi whois2.afilias-grs.net',
    'gl whois.nic.gl',
    'gm whois.ripe.net',
    'gov whois.nic.gov',
    'gr whois.ripe.net',
    'gs whois.nic.gs',
    'gy whois.registry.gy',
    'hamburg whois.nic.hamburg',
    'hiphop whois.uniregistry.net',
    'hk whois.hknic.net.hk',
    'hm whois.registry.hm',
    'hn whois2.afilias-grs.net',
    'host whois.nic.host',
    'hr whois.dns.hr',
    'ht whois.nic.ht',
    'hu whois.nic.hu',
    'hu.com whois.centralnic.com',
    'id whois.pandi.or.id',
    'ie whois.domainregistry.ie',
    'il whois.isoc.org.il',
    'im whois.nic.im',
    'in whois.inregistry.net',
    'info whois.afilias.info',
    'ing domain-registry-whois.l.google.com',
    'ink whois.centralnic.com',
    'int whois.isi.edu',
    'io whois.nic.io',
    'iq whois.cmc.iq',
    'ir whois.nic.ir',
    'is whois.isnic.is',
    'it whois.nic.it',
    'je whois.je',
    'jobs jobswhois.verisign-grs.com',
    'jp whois.jprs.jp',
    'ke whois.kenic.or.ke',
    'kg whois.domain.kg',
    'ki whois.nic.ki',
    'kr whois.kr',
    'kz whois.nic.kz',
    'la whois2.afilias-grs.net',
    'li whois.nic.li',
    'london whois.nic.london',
    'lt whois.domreg.lt',
    'lu whois.restena.lu',
    'lv whois.nic.lv',
    'ly whois.lydomains.com',
    'ma whois.iam.net.ma',
    'mc whois.ripe.net',
    'md whois.nic.md',
    'me whois.nic.me',
    'mg whois.nic.mg',
    'mil whois.nic.mil',
    'mk whois.ripe.net',
    'ml whois.dot.ml',
    'mo whois.monic.mo',
    'mobi whois.dotmobiregistry.net',
    'ms whois.nic.ms',
    'mt whois.ripe.net',
    'mu whois.nic.mu',
    'museum whois.museum',
    'mx whois.nic.mx',
    'my whois.mynic.net.my',
    'mz whois.nic.mz',
    'na whois.na-nic.com.na',
    'name whois.nic.name',
    'nc whois.nc',
    'nf whois.nic.cx',
    'ng whois.nic.net.ng',
    'nl whois.domain-registry.nl',
    'no whois.norid.no',
    'no.com whois.centralnic.com',
    'nu whois.nic.nu',
    'nz whois.srs.net.nz',
    'om whois.registry.om',
    'ong whois.publicinterestregistry.net',
    'ooo whois.nic.ooo',
    'paris whois-paris.nic.fr',
    'pe kero.yachay.pe',
    'pf whois.registry.pf',
    'pics whois.uniregistry.net',
    'pl whois.dns.pl',
    'pm whois.nic.pm',
    'pr whois.nic.pr',
    'press whois.nic.press',
    'pro whois.registrypro.pro',
    'pt whois.dns.pt',
    'pub whois.unitedtld.com',
    'pw whois.nic.pw',
    'qa whois.registry.qa',
    're whois.nic.re',
    'ro whois.rotld.ro',
    'rs whois.rnids.rs',
    'ru whois.tcinet.ru',
    'sa saudinic.net.sa',
    'sa.com whois.centralnic.com',
    'sb whois.nic.net.sb',
    'sc whois2.afilias-grs.net',
    'se whois.nic-se.se',
    'se.com whois.centralnic.com',
    'se.net whois.centralnic.com',
    'sg whois.nic.net.sg',
    'sh whois.nic.sh',
    'si whois.arnes.si',
    'sk whois.sk-nic.sk',
    'sm whois.nic.sm',
    'st whois.nic.st',
    'so whois.nic.so',
    'su whois.tcinet.ru',
    'sx whois.sx',
    'sy whois.tld.sy',
    'tc whois.adamsnames.tc',
    'tel whois.nic.tel',
    'tf whois.nic.tf',
    'th whois.thnic.net',
    'tj whois.nic.tj',
    'tk whois.nic.tk',
    'tl whois.domains.tl',
    'tm whois.nic.tm',
    'tn whois.ati.tn',
    'to whois.tonic.to',
    'top whois.nic.top',
    'tp whois.domains.tl',
    'tr whois.nic.tr',
    'travel whois.nic.travel',
    'tw whois.twnic.net.tw',
    'tv whois.nic.tv',
    'tz whois.tznic.or.tz',
    'ua whois.ua',
    'ug whois.co.ug',
    'uk.com whois.centralnic.com',
    'uk.net whois.centralnic.com',
    'ac.uk whois.ja.net',
    'gov.uk whois.ja.net',
    'us whois.nic.us',
    'us.com whois.centralnic.com',
    'uy nic.uy',
    'uy.com whois.centralnic.com',
    'uz whois.cctld.uz',
    'va whois.ripe.net',
    'vc whois2.afilias-grs.net',
    've whois.nic.ve',
    'vg ccwhois.ksregistry.net',
    'vu vunic.vu',
    'wang whois.nic.wang',
    'wf whois.nic.wf',
    'wiki whois.nic.wiki',
    'ws whois.website.ws',
    'xxx whois.nic.xxx',
    'xyz whois.nic.xyz',
    'yu whois.ripe.net',
    'za.com whois.centralnic.com');
//  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}
{$R *.iPhone4in.fmx IOS}
{$R *.Windows.fmx MSWINDOWS}
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure Tform1.SetWhoisServers(const Value: TStringList);
begin
    if FWhoisServers.Text <> Value.Text then begin
        FWhoisServers.Assign(Value);
    end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
    I, J, K, svr: integer ;
    domain1, domain2: string ;
begin
for J := Length (edit1.text) downto 2 do begin
            if edit1.text [J] = '.' then begin   // search host.co.uk
                if domain1 = '' then
                    domain1 := Copy (edit1.text, J + 1, 99) + IcsSpace   // found  uk
                else begin
                    domain2 := Copy (edit1.text, J + 1, 99) + IcsSpace ;  // found co.uk
                   Break ;
                end;
            end;
        end;
     FWhoisServers := TStringList.Create;
    for I := 0 to Length(WhoisNames) - 1 do
                FWhoisServers.add(WhoisNames[I]);
     FHost := 'whois.ripe.net' ;
         K := -1 ;
        if FWhoisServers.Count > 0 then begin
            for I := 0 to FWhoisServers.Count - 1 do
            begin
                if (Pos (domain1, FWhoisServers [I]) = 1) then K := I ;
                if (Pos (domain2, FWhoisServers [I]) = 1) then
                begin
                    K := I ;
                    break ;
                end ;
            end;
            if K >= 0 then begin
                J := Pos (IcsSpace, FWhoisServers [K]) ;
           end;
        end;
        if K < 0 then begin
       end;
   IdWhois1.host :=  Copy (FWhoisServers [K], J + 1, 99) ;

   edit2.text  :=  Copy (FWhoisServers [K], J + 1, 99) ;
   memo1.Lines.Text := IdWhois1.WhoIs(edit1.text);
    end;
end.
rlebeau commented 2 years ago

You can copy this code and add it to indywhoisclient to be automatique it works fine

I will not be incorporating this code into Indy's TIdWhois, as it has clearly been ripped off from ICS's code with little modification. If you want to use their code in your own project, that is your decision, but you will have to follow their licensing agreement.

I may consider a similar feature in the future (not anytime soon), but it will not be based on this code.

bouhlal commented 2 years ago

You can create your own code for that, now you have an idea about it and this tool is very very useful, ICS also if very good I can't say anything about it the only problem it does not support mobile