DomainTwistex.Utils (domaintwistex v0.6.0)

DomainTwistEx provides domain permutation generation and validation utilities. Combines Rust NIFs for permutation generation with domain validation and server checking capabilities.

Prerequisites

If you see a :enoent error during compilation, ensure Rust/Cargo is installed and available in your PATH.

Summary

Functions

Performs comprehensive domain validation checks including DNS and server availability.

Performs a basic HTTP check on a domain's web server.

Validates and resolves domain information while checking for TLD-related issues.

1. Native Implemented Functions (RUST)

Generates domain permutations using the Twistrs Rust library.

Functions

check_domain(permutation)

Performs comprehensive domain validation checks including DNS and server availability.

Parameters

  • permutation - Map containing at least :fqdn and :tld keys

Returns

  • {:ok, map} - Successfully checked domain with all information
  • {:error, binary} - Error message when checks fail
  • {:error, :not_resolvable} - When domain cannot be resolved

Example

```
iex> permutation = %{fqdn: "example.com", tld: "com"}
iex> DomainTwistex.Utils.check_domain(permutation)
{:ok, %{
  resolvable: true,
  ip_addresses: ["93.184.216.34"],
  mx_records: [%{priority: 10, server: "mail.example.com"}],
  txt_records: ["v=spf1 -all"],
  server_response: %{status_code: "200", server: "ECS"},
  nameservers: ["ns1.example.com", "ns2.example.com"]
}}
```

check_server(domain)

Performs a basic HTTP check on a domain's web server.

Parameters

  • domain - String representing the domain to check

Returns

  • map containing server response information or error details

Example

```
iex> DomainTwistex.Utils.check_server("example.com")
%{
  status_code: "200",
  server: "ECS",
  headers: %{"Server" => "ECS", "Content-Type" => "text/html"}
}
```

validate_domain_resolution(domain, tld)

Validates and resolves domain information while checking for TLD-related issues.

Parameters

  • domain - String representing the domain to check
  • tld - String representing the top-level domain to validate against

Returns

  • {:ok, [string]} - List of valid IP addresses
  • {:error, reason} - Error message when validation fails

1. Native Implemented Functions (RUST)

generate_permutations(domain)

Generates domain permutations using the Twistrs Rust library.

This function is implemented as a Native Implemented Function (NIF) that interfaces with the Twistrs Rust library for efficient domain permutation generation.

Attribution

This NIF wraps functionality from the Twistrs library: https://github.com/haveibeensquatted/twistrs

Parameters

  • domain - String representing the domain to generate permutations for

Returns

List of generated domain permutation strings

Examples

```
iex(1)> DomainTwistex.Utils.generate_permutations("google.com")
[
  %{kind: "Keyword", fqdn: "servicegoogle.com", tld: "com"},
  %{kind: "Homoglyph", fqdn: "ğöögle.com", tld: "com"},
  # ...
]
```