J'ai plusieurs serveurs WHOIS pour lesquels je veux avoir un seul proxy. Le proxy doit transférer les demandes aux serveurs appropriés en fonction des données de la requête. Comment aborder ce problème?Comment puis-je implémenter un proxy WHOIS simple en Perl?
Répondre
Étape 1 lire le RFC for WHOIS
Étape 2 mettre en œuvre un serveur simulé avec Net::Server
Étape 3 mettre en œuvre le proxy en utilisant votre serveur Mock et Net::Whois::Proxy ou un autre module WHOIS
Une analyse rapide de la RFC semble dire Il s'agit simplement d'un protocole basé sur du texte simple qui attend une ligne terminée CRLF, puis envoie un blob de lignes de terminaison CRLF et ferme le socket.
Eh oui, il semble vraiment aussi simple que cela, étant donné ce code
#!/usr/bin/perl
{
package Whois;
use strict;
use warnings;
use parent 'Net::Server';
sub process_request {
my $request = <>;
print "you sent me $request";
}
}
Whois->run;
vous pouvez dire
whois -h localhost -p 20203 foo.com
et retourner
you sent me foo.com
Compte tenu de l'étiquette "charge élevée" , vous voudrez probablement passer à Net::Server::PreForkSimple
personnalité lorsque vous avez terminé avec les tests.
Et juste parce que je me suis ennuyé:
#!/usr/bin/perl
package Whois {
use strict;
use warnings;
use parent 'Net::Server::PreFork';
use Net::Whois::Raw;
my %handler = (
org => "whois.publicinterestregistry.net",
);
sub process_request {
(my $request = <>) =~ s/[.]([^.]+)\x{0d}\x{0a}/.$1/;
print exists $handler{$1} ?
whois $request, $handler{$1} :
"I don't know where to look for $request\r\n";
}
}
Whois->run(
user => "nobody",
group => "nobody",
port => 43,
min_servers => 1, #min number of children
max_servers => 10, #max number of children
min_spare_servers => 1, #fork if we don't have this many waiting
max_spare_servers => 5, #kill if we have this many waiting
max_requests => 10_000, #num of requests before killing a child
);
qui, lorsque je lance
sudo perl whois.pl
puis
whois -h localhost foo.org
nous donne
NOTICE: Access to .ORG WHOIS information is provided to assist persons in
determining the contents of a domain name registration record in the Public Interest Registry
registry database. The data in this record is provided by Public Interest Registry
for informational purposes only, and Public Interest Registry does not guarantee its
accuracy. This service is intended only for query-based access. You agree
that you will use this data only for lawful purposes and that, under no
circumstances will you use this data to: (a) allow, enable, or otherwise
support the transmission by e-mail, telephone, or facsimile of mass
unsolicited, commercial advertising or solicitations to entities other than
the data recipient's own existing customers; or (b) enable high volume,
automated, electronic processes that send queries or data to the systems of
Registry Operator or any ICANN-Accredited Registrar, except as reasonably
necessary to register domain names or modify existing registrations. All
rights reserved. Public Interest Registry reserves the right to modify these terms at any
time. By submitting this query, you agree to abide by this policy.
Domain ID:D1608104-LROR
Domain Name:FOO.ORG
Created On:10-Jan-1995 05:00:00 UTC
Last Updated On:07-Mar-2011 00:26:43 UTC
Expiration Date:09-Jan-2012 05:00:00 UTC
Sponsoring Registrar:Fabulous.com Pty Ltd. (R133-LROR)
Status:CLIENT DELETE PROHIBITED
Status:CLIENT TRANSFER PROHIBITED
Registrant ID:fabwpp-000700385
Registrant Name:Domain Hostmaster, CustomerID : 85519846801225
Registrant Organization:Whois Privacy Services Pty Ltd
Registrant Street1:PO Box 923
Registrant Street2:
Registrant Street3:
Registrant City:Fortitude Valley
Registrant State/Province:QLD
Registrant Postal Code:4006
Registrant Country:AU
Registrant Phone:+61.730070090
Registrant Phone Ext.:
Registrant FAX:+61.730070091
Registrant FAX Ext.:
Registrant Email:[email protected]
Admin ID:fabwpp-000700385
Admin Name:Domain Hostmaster, CustomerID : 85519846801225
Admin Organization:Whois Privacy Services Pty Ltd
Admin Street1:PO Box 923
Admin Street2:
Admin Street3:
Admin City:Fortitude Valley
Admin State/Province:QLD
Admin Postal Code:4006
Admin Country:AU
Admin Phone:+61.730070090
Admin Phone Ext.:
Admin FAX:+61.730070091
Admin FAX Ext.:
Admin Email:[email protected]
Tech ID:fabwpp-000700385
Tech Name:Domain Hostmaster, CustomerID : 85519846801225
Tech Organization:Whois Privacy Services Pty Ltd
Tech Street1:PO Box 923
Tech Street2:
Tech Street3:
Tech City:Fortitude Valley
Tech State/Province:QLD
Tech Postal Code:4006
Tech Country:AU
Tech Phone:+61.730070090
Tech Phone Ext.:
Tech FAX:+61.730070091
Tech FAX Ext.:
Tech Email:[email protected]
Name Server:NS1.HITFARM.COM
Name Server:NS2.HITFARM.COM
Name Server:
Name Server:
Name Server:
Name Server:
Name Server:
Name Server:
Name Server:
Name Server:
Name Server:
Name Server:
Name Server:
DNSSEC:Unsigned
whois.publicinterestregistry.net
Je ne suis pas un expert sur whois, mais Net::Whois::Proxy semble être ce que vous voulez.
- 1. Comment puis-je écrire un simple proxy HTTP en Perl?
- 2. Comment implémenter votre propre serveur WHOIS?
- 3. Comment implémenter un site proxy en PHP?
- 4. Comment Whois en PHP?
- 5. Comment implémenter le proxy inverse?
- 6. Comment implémenter un simple bouton dans PyQt
- 7. Comment implémenter un arbre d'analyse simple?
- 8. DotNetOpenAuth: Comment implémenter un simple fournisseur OpenId?
- 9. Comment implémenter un modèle de proxy impliquant un appel asynchrone?
- 10. Perl: simple remplacement question
- 11. comment implémenter k-means pour un regroupement simple en java
- 12. Comment implémenter dynamiquement le modèle de proxy?
- 13. Utiliser un proxy avec le script perl
- 14. Comment implémenter le pool de proxy WCF?
- 15. Comment boucler/redémarrer un script Perl?
- 16. WHOIS pour un TLD donné?
- 17. traitement parallèle simple en perl
- 18. Comment implémenter un proxy http pour localhost dans Windows?
- 19. Paramètre d'enregistrement avec proxy (perl)
- 20. PHP simple proxy
- 21. proxy socks 5 sur Perl
- 22. proxy avec le script perl
- 23. WHOIS requête objet
- 24. Implémenter un algorithme simple en divisant et vaincre
- 25. Programme proxy simple avec BOOST
- 26. perl Authentification SOAP :: Lite proxy
- 27. Comment puis-je implémenter Unix grep en Perl?
- 28. Comment puis-je implémenter des services Web en Perl?
- 29. Comment puis-je implémenter une classe singleton en Perl?
- 30. Un exemple simple pour implémenter OAuth2.0
Je ne pense pas. Malgré le nom, Net :: Whois :: Proxy semble être un client _client_, pas un proxy du tout. – cjm
Un serveur proxy qui prend les requêtes whois et les transmet au serveur réel approprié est un client. La seule chose qu'il fait en tant que serveur est l'écoute des demandes. – Schwern
@Schwern: J'ai besoin de proxy les demandes d'origine, ne pas les reconstruire. – planetp