gleewhois

Package Version Hex Docs

WHOIS client for Gleam built using mug🍺. Programmatically query WHOIS servers from Gleam or use it from the command line, if for whatever reason you desire that.

Use it to query from the CLI

~/gleewhois$ gleam run -- --server=whois.ripe.net --port=43 AS51019

Or use it in your code

gleam add gleewhois
import gleam/io
import gleewhois.{ParsingError, SocketError, UnknownError}

pub fn main() {
  let query =
    gleewhois.query(
      "AS51019",
      server: "whois.ripe.net",
      port: 43,
      timeout_ms: 60_000,
    )
  // -> Result(String, Err)

  case query {
    Ok(result) -> io.print(result)
    Error(err) ->
      case err {
        SocketError -> io.println("Error establishing connection.")
        ParsingError -> io.println("Error parsing result data.")
        UnknownError -> io.println("An unknown error ocurred during query.")
      }
  }
}

Documentation also available at https://hexdocs.pm/gleewhois.

License

MIT

Search Document