new handles the following parameters:
{ debug => <0|1|5>, use_cache => <0|1>, service_url => <0|service_url, norid_header_secret => <0|test_secret>, norid_header_proxy => <0|1>, norid_referral_ip => <0|1|ip-address>, } All parameters are optional: * use_cache: - 1: activate lookup cache, see Net::RDAP for use * debug: - 0: debug off - 1: debug from this module on - 5: full debug from Net::RDAP on, see Net::RDAP for use * service_url: - the full http(s)-address of the Norid RDAP-servie to be accessed. - default is $SERVICE_URL above. * norid_header_secret: - access token for layered access, and the token is sent in the 'X-RDAP-Secret' header. * norid_header_proxy : - Norid internal use only. - true if the calling client can act as a proxy, and the header 'X-RDAP-Web-Proxy' is then set to 1. * norid_referral_ip : - Norid internal use only. - set if the calling client ip address argument shall be sent. When set: - if the argument passed is a pure integer, use the local ip-address as value. - if the argument passed is a valid ip address, use that address as value. This is the normal variant to be used to pass a proper client ip address. - the ip-address is passed to the server in the '?client_ip=<ip-address>' argument.
Do an RDAP lookup.
- $query : specifies the query string - $check : specifies if http 'head' shall be done, default is 'get'. - $nameservers: must be set to true for nameserver_name search - $entity : must be set to true for entity lookup, in which case the query should identify an entity, like: - a domain name - a handle, like registrar handle, registrant handle, ns handle or contact handle must be set to false to trig a search if the query contains something that allows a search, like: - identity (organization number, N.PRI.xxx etc) - a registrant handle (P- or O- handle) - a nameserver name (must then be combined with $nameservers=1 to distinguish from a domain name)
Do an RDAP HEAD or GET lookup.
- $http_type: 'head' or 'get' - $uri : full arguments to base URI, identifying the actual lookup method and args - other args as passed in $self.
Some RDAP error is returned from Net::RDAP, ref. Net::RDAP::Error.
Those are normally HTTP response errors in the 400 and 500 range, which are mapped to one of the $RDAP_LOOKUP_ERR_XXX local errors.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status - All 1xx are not errors, but Ok, need not be handled. - All 2xx are not errors, but Ok, need not be handled. - All 3xx are redirection errors, which are not expected, map to other if we get it. - All 3xx are redirection errors, which are not expected, map to other if we get it.
All 5xx errors are considered connection problems at some level
Find local ip-address.
(Note: Sys::HostAddr were also tried for this purpose, but could die at random, so Sys::HostIP is selected. Only ipv4 seems to be processed by Sys::HostIP, so the selection is limited to ipv4. TODO: Consider using another module, which also supports v6).
Best guess IP seems to be the one on the en0-interface, but when a VPN is in use, you might want that address to be selected. So, try to do the best ip selection by ourselves by a reverse sort instead of a sort, thus selecting the 'highest' numbered and public ip-address).
Return localhost if no other ip is found.
Return empty if localhost iface not found.
1) Validate ip address, if set 2) Validate query, return if query not among the expexted ones. - domain name or name server name - some object handle (D, P, R, H) - some registrar handle (regXXX-NORID) - some identity (9 digits orgno, N.XXX.yyyyyyyy) 2) Analyze query and args and find what http method and uri arguments to use for the lookup and set them in '_method' and '_uri'
Return sensible rdap formatted string. Uses internal helper formatting functions.
Shows how to access data returned by Net::RDAP.
Return sensible rdap formatted string.
Code stolen from rdapper and adapted.
Format vcard object(s) as string.
Fetch the name from an object. If we have a Net::DNS::Domain object (domain/ns), also get the xname.
Determine type of Norid handle.
NOLookup::RDAP::RDAPLookup - Lookup RDAP data from the Norid (.no) RDAP service.
use Encode; use NOLookup::RDAP::RDAPLookup; # Default API service URL my $SERVICE_URL = "https://rdap.norid.no"; # Example 1: Domain name lookup # Decode the query when needed, like for IDNs # or names with national characters. my $q = 'norid.no'; #$q = decode('ISO8859-1', 'øl.no'); my $bo = NOLookup::RDAP::RDAPLookup->new( { service_url => 'https://rdap.norid.no', debug => 0, use_cache => 0, norid_header_secret => 'secret1234', norid_header_proxy => 1, }); # test HEAD operation for existence $bo->lookup($q, 1, 0, 0); if ($bo->error) { print "HEAD: Error, error / status: ", $bo->error . "/" . $bo->status) . "\n"; } # test GET operations $bo->lookup($q, 0, 0, 0); if ($bo->error) { print "GET: Error, error / status: ", $bo->error . "/" . $bo->status) . "\n"; } # result of lookup is in $bo->result # This result contains response objects built by Net::RDAP my $res = $bo->result; print "handle: ", $bo->handle, "\n"; * See bin/no_rdap.pl for more information on usage. * See various formatting/helper functions in this file for how to access the various objects returned by Net::RDAP.
This module provides an object oriented API for use with the Norid RDAP service. It uses the Net::RDAP module from Cpan internally to fetch information from the Norid RDAP.
For now, support questions should be sent to:
<(nospam)info(at)norid.no>
http://www.norid.no/en https://www.norid.no/en/registrar/system/tjenester/whois-das-service https://teknisk.norid.no/en/registrar/system/tjenester/rdap =head1 CAVEATS
Trond Haugen, <(nospam)info(at)norid.no>
Copyright (c) 2020- Trond Haugen <(nospam)info(at)norid.no>. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
From Norid doc:
RDAP is based on a subset of the HTTP protocol. The server accepts requests of type GET and HEAD. GET lookup is answered with data about the object in question. HEAD responds if the object exists or not. Both request types are answered with return code 200 / OK if the object exists, and return code 404 / NOT FOUND if the object does not exist, and other return code for other error types.
The server supports the following types of lookups:
GET/HEAD https://rdap.norid.no/domain/<domenenavn> GET/HEAD https://rdap.norid.no/entity/<handle> GET/HEAD https://rdap.norid.no/registrar/<reg_handle> (Norid extension) Note: Returns same result as /entity/<reg_handle> GET/HEAD https://rdap.norid.no/nameserver_handle/<handle> (Norid extension)
And the following searches:
GET https://rdap.norid.no/nameservers?name=<hostname> GET https://rdap.norid.no/domains?identity=<identity> (Norid extension for proxy) GET https://rdap.norid.no/domains?registrant=<handle> (Norid extension for proxy) GET https://rdap.norid.no/entities?identity=<identity> (Norid extension for proxy)
To install NOLookup, copy and paste the appropriate command in to your terminal.
cpanm
cpanm NOLookup
CPAN shell
perl -MCPAN -e shell install NOLookup
For more information on module installation, please visit the detailed CPAN module installation guide.