OpenRDAP Documentation

repository·main·Indexed 19 days ago

https://github.com/openrdap/rdap

A command-line RDAP (Registration Data Access Protocol) client implemented in Go. OpenRDAP allows users to query registration data for domains, IP addresses, ASNs, and entities. It features automatic server detection via IANA Service Registry files, support for multiple output formats (JSON, text, and WHOIS), X.509 client authentication, and a bootstrap client for discovering RDAP server URLs.

Tokens
13.4K
Snippets
61
Records
74
Agent score
63%

What's inside OpenRDAP

  1. OpenRDAP Features and Capabilities

    main

    OpenRDAP provides a robust set of features for interacting with RDAP servers:

    • Output Formats: Supports text, JSON, and WHOIS style outputs.
    • Automatic Server Detection: Automatically identifies the correct server for ip, domain, autnum, and entities queries.
    • Bootstrap Cache: Optionally caches data to $XDG_CACHE_HOME/openrdap (defaults to ~/.cache/openrdap).
    • Authentication: Supports X.509 client authentication.
    • Object Tags: Supports querying via object tags.
  2. Advanced Usage with Specific Servers and Query Types

    main

    When performing specialized searches or using servers that do not support automatic detection, you must specify the server using the -s flag and the query type using the -t flag.

    Query typeUsage
    Nameserverrdap -v -t nameserver -s <SERVER_URL> <NS_NAME>
    Helprdap -v -t help -s <SERVER_URL>
    Domain Searchrdap -v -t domain-search -s <SERVER_URL> <PATTERN>
    Domain Search (by NS)rdap -v -t domain-search-by-nameserver -s <SERVER_URL> <NS_NAME>
    Domain Search (by NS IP)rdap -v -t domain-search-by-nameserver-ip -s <SERVER_URL> <IP>
    Nameserver Searchrdap -v -t nameserver-search -s <SERVER_URL> <NS_NAME>
    Nameserver Search (by IP)rdap -v -t nameserver-search-by-ip -s <SERVER_URL> <IP>
    Entity Searchrdap -v -t entity-search -s <SERVER_URL> <ENTITY-TAG>
    Entity Search (by handle)rdap -v -t entity-search-by-handle -s <SERVER_URL> <ENTITY-TAG>
    # Example: Querying a specific nameserver via Verisign
    rdap -v -t nameserver -s https://rdap.verisign.com/com/v1 ns1.google.com
  3. Install the OpenRDAP CLI

    main

    OpenRDAP is a command line RDAP client written in Go. You can install the rdap binary using go install.

    After installation, the binary will be located in your $GOPATH/go/bin directory.

    go install github.com/openrdap/rdap/cmd/rdap@master
  4. Basic Usage of the rdap CLI

    main

    For standard queries, OpenRDAP automatically detects the appropriate server for IP addresses, domains, ASNs, and entities. Use the -v flag for verbose output.

    Common query patterns:

    • Domain: rdap -v example.com
    • IPv4 Address: rdap -v 192.0.2.0
    • IPv6 Address: rdap -v 2001:db8::
    • Autonomous System (ASN): rdap -v AS15169
    • Entity (using object tag): rdap -v OPS4-RIPE
    ~/go/bin/rdap google.com
  5. Understand the VCardProperty structure

    main

    A VCardProperty represents a single attribute in a jCard. It consists of:

    • Name: The property name (e.g., "tel", "fn").
    • Parameters: A map[string][]string containing property parameters (e.g., {"type": ["work", "voice"]}).
    • Type: The data type of the property (e.g., "text", "uri").
    • Value: The actual data. This can be a string, float64, bool, nil, or a nested []interface{} containing a mixture of these types.
  6. Access unknown or malformed fields via DecodeData

    main

    The decoder supports and stores unknown RDAP fields and minor decoding errors. If a struct includes a *rdap.DecodeData field, the decoder will populate it.

    • Unknown Fields: You can access raw values for fields not explicitly defined in your Go struct via the DecodeData.values map.
    • Minor Errors: Type conversion issues or mism actually occurring during decoding are recorded in the DecodeData.notes map, where the key is the field name and the value is a slice of error messages.
  7. Define custom RDAP field names using struct tags

    main

    By default, the decoder maps RDAP field names to Go struct fields by lowercasing the first letter of the field name (e.g., LDHName becomes ldhName).

    You can override this behavior using the rdap struct tag. Note that fields must be exported (start with an uppercase letter) to be decodable.

    type Domain struct {
        // Maps to RDAP field "custom_name"
        CustomName string `rdap:"custom_name"` 
        // Maps to RDAP field "ldhname" (default behavior)
        LDHName    string 
    }
  8. Use DecodeData to access unknown or raw RDAP fields

    main

    The DecodeData struct is embedded in RDAP response structs (such as rdap.Domain). It acts as a snapshot of all fields present in the RDAP response at the time of decoding. This is useful for retrieving values of fields that are not explicitly defined in the Go struct (unknown fields) or inspecting minor warnings encountered during the decoding process.

    Important Notes:

    • DecodeData is only populated during automatic decoding of RDAP responses. If you manually construct a struct (e.g., d := &rdap.Domain{Handle: "x"}), DecodeData will be empty and irrelevant.
    • When querying fields, use the RDAP field name (e.g., "port43"), not the Go struct field name (e.g., "Port43").
  9. How RDAP bootstrapping works in the Client

    main

    When you call Do(req) and the Request.Server field is nil, the client automatically performs a bootstrapping process:

    1. It determines the appropriate RegistryType based on the Request.Type (e.g., bootstrap.DNS for DomainRequest, bootstrap.IPv4 or bootstrap.IPv6 for IPRequest).
    2. It uses the configured Bootstrap client to look up authoritative RDAP server URLs.
    3. It iterates through the returned URLs and attempts the query against each server until one responds successfully.

    If a server is explicitly provided in req.Server, bootstrapping is skipped and the client queries that specific server directly.

  10. Identify and handle ClientError types

    main

    The rdap package uses the ClientError type to represent errors encountered during client-side operations (such as input validation or connectivity issues) as opposed to errors returned directly by an RDAP server.

    To handle specific error scenarios, you can check the Type field of a ClientError. Common error types include:

    • InputError: Invalid input provided to the client.
    • BootstrapNotSupported: The bootstrap process is not supported.
    • BootstrapNoMatch: No match found during bootstrap.
    • WrongResponseType: The server returned a response type that was not expected.
    • NoWorkingServers: No servers were able to respond to the request.
    • ObjectDoesNotExist: The requested RDAP object could not be found.
    • RDAPServerError: The RDAP server itself returned an error (mapped from an RDAP Error type).
  11. How RDAP Request types work

    main

    An RDAP Request is a configuration object that defines how to query an RDAP server. It consists of a Type (an enum of RequestType), a Query string, and an optional Server URL.

    Request Types and Bootstrapping

    RDAP supports various query types. Some are 'bootstrapped', meaning the client can automatically find the correct server using IANA data. Others require you to provide the server URL manually.

    RequestTypeBootstrapped?HTTP Path Example
    rdap.AutnumRequestYesautnum/QUERY
    rdap.DomainRequestYesdomain/QUERY
    rdap.IPRequestYesip/QUERY
    rdap.EntityRequestExperimentalentity/QUERY
    rdap.NameserverRequestNonameserver/QUERY
    rdap.DomainSearchRequestNodomains?name=QUERY
    rdap.EntitySearchRequestNoentities?fn=QUERY
    rdap.RawRequestN/A(Uses the Server field as the full URL)

    The RawRequest Type

    RawRequest is a special type used when you already have a complete RDAP URL. In this case, the Server field should contain the full URL, and the Query and Params fields are ignored.

    // Example of a bootstrapped request (server is found automatically)
    req := rdap.NewDomainRequest("example.com")
    
    // Example of a request requiring a manual server
    server, _ := url.Parse("https://rdap.nic.cz")
    req := &rdap.Request{
        Type:   rdap.NameserverRequest,
        Query:  "a.ns.nic.cz",
        Server: server,
    }
  12. Use the rdap CLI to query RDAP data

    main

    The rdap command-line tool allows you to query RDAP servers for information about domains, IP addresses, ASNs, nameservers, entities, and more. It can automatically detect the query type based on the input or allow manual specification via the --type flag.

    Basic Usage: rdap [OPTIONS] DOMAIN|IP|ASN|ENTITY|NAMESERVER|RDAP-URL

    Common Examples:

    • Query a domain: rdap example.com
    • Query an IP: rdap 192.0.2.0
    • Query an ASN: rdap AS2856
    • Query a specific RDAP server: rdap https://rdap.nic.cz/domain/example.cz
    rdap example.com
    rdap 192.0.2.0
    rdap AS2856
    rdap https://rdap.nic.cz/domain/example.cz