Author SHA1 Message Date
klemek 4df2bab348 chore: version 1.1.0
Python Lint CI / ruff (push) Failing after 1m35s
Python Lint CI / ruff-format-check (push) Successful in 3m3s
Python Lint CI / ty (push) Successful in 2m51s
2026-06-15 14:22:52 +02:00
klemek d5b9018ef2 feat: multiple words 2026-06-15 14:22:40 +02:00
klemek b387fec2b3 fix: check dig NS
Python Lint CI / ruff-format-check (push) Successful in 44s
Python Lint CI / ty (push) Successful in 44s
Python Lint CI / ruff (push) Successful in 44s
2026-06-15 14:18:58 +02:00
6 changed files with 23 additions and 10 deletions
+3 -2
View File
@@ -23,14 +23,15 @@ uvx --from git+https://git.klemek.fr/klemek/cool-domain cool-domain
## Usage ## Usage
```txt ```txt
usage: cool-domain [-h] [--count DOMAIN_COUNT] [--lang {english,french}] [--dig | --no-dig] [--debug | --no-debug] [--quiet | --no-quiet] usage: cool-domain [-h] [--count DOMAIN_COUNT] [--lang {english,french}] [--words WORD_COUNT] [--dig | --no-dig] [--debug | --no-debug]
[--cache | --no-cache] [--cache-file CACHE_FILE] [--tld-list-uri TLD_LIST_URI] [--quiet | --no-quiet] [--cache | --no-cache] [--cache-file CACHE_FILE] [--tld-list-uri TLD_LIST_URI]
options: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--count DOMAIN_COUNT number of domains to generate (default: 1) --count DOMAIN_COUNT number of domains to generate (default: 1)
--lang {english,french} --lang {english,french}
word list lang (default: english) word list lang (default: english)
--words WORD_COUNT number of words per domain (default: 1)
--dig, --no-dig check availability with dig (default: true) --dig, --no-dig check availability with dig (default: true)
--debug, --no-debug --debug, --no-debug
--quiet, --no-quiet --quiet, --no-quiet
+1 -1
View File
@@ -19,7 +19,7 @@ def main() -> int:
TLDList(cache=cache, remote_uri=params.tld_list_uri) as tld_list, TLDList(cache=cache, remote_uri=params.tld_list_uri) as tld_list,
LANGS[params.lang] as word_list, LANGS[params.lang] as word_list,
): ):
factory = Factory(tld_list=tld_list, word_list=word_list) factory = Factory(tld_list=tld_list, word_list=word_list, words=params.words)
logging.getLogger().info( logging.getLogger().info(
"Searching %s domain%s", params.count, "s" if params.count > 1 else "" "Searching %s domain%s", params.count, "s" if params.count > 1 else ""
) )
+9 -5
View File
@@ -14,12 +14,13 @@ class FactoryError(Exception):
class Factory: class Factory:
__slots__ = ["__found", "__tld_list", "__word_list", "logger", "logger"] __slots__ = ["__found", "__tld_list", "__word_list", "logger", "__words"]
def __init__(self, tld_list: TLDList, word_list: WordList) -> None: def __init__(self, tld_list: TLDList, word_list: WordList, words: int) -> None:
self.logger: logging.Logger = logging.getLogger(self.__class__.__name__) self.logger: logging.Logger = logging.getLogger(self.__class__.__name__)
self.__tld_list = tld_list self.__tld_list = tld_list
self.__word_list = word_list self.__word_list = word_list
self.__words = words
self.__found: set[str] = set() self.__found: set[str] = set()
def __iter__(self) -> typing.Self: def __iter__(self) -> typing.Self:
@@ -41,10 +42,10 @@ class Factory:
msg = "dig is not installed" msg = "dig is not installed"
raise FactoryError(msg) raise FactoryError(msg)
try: try:
output = subprocess.check_output([dig_bin, domain, "+short"]) # noqa: S603 output = subprocess.check_output([dig_bin, domain, "NS", "+short"]) # noqa: S603
return len(output) == 0 return len(output) == 0
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return True return False
def random_domain(self) -> str: def random_domain(self) -> str:
k = 10000 k = 10000
@@ -65,7 +66,7 @@ class Factory:
return domain return domain
def __random_domain(self) -> str | None: def __random_domain(self) -> str | None:
word = random.choice(self.__word_list.words) # noqa: S311 word = self.__random_word()
for tld in self.__tld_list_shuffled: for tld in self.__tld_list_shuffled:
tld_escaped = tld.replace(".", "") tld_escaped = tld.replace(".", "")
if word.endswith(tld_escaped) and len(word) > len(tld_escaped): if word.endswith(tld_escaped) and len(word) > len(tld_escaped):
@@ -74,3 +75,6 @@ class Factory:
self.__found.add(domain) self.__found.add(domain)
return domain return domain
return None return None
def __random_word(self) -> str:
return "-".join(random.sample(self.__word_list.words, self.__words))
+8
View File
@@ -15,6 +15,7 @@ class Parameters:
quiet: bool = False quiet: bool = False
cache: bool = True cache: bool = True
count: int = 1 count: int = 1
words: int = 1
dig: bool = True dig: bool = True
lang: str = "english" lang: str = "english"
cache_file: str = str(pathlib.Path(tempfile.gettempdir()) / ".cool-domain-cache") cache_file: str = str(pathlib.Path(tempfile.gettempdir()) / ".cool-domain-cache")
@@ -104,6 +105,13 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
help="word list lang (default: english)", help="word list lang (default: english)",
choices=LANGS.keys(), choices=LANGS.keys(),
) )
__add_arg_int(
parser,
"--words",
env_var="WORD_COUNT",
default=default_values.words,
help_txt="number of words per domain",
)
__add_arg_bool( __add_arg_bool(
parser, parser,
"--dig", "--dig",
+1 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "cool-domain" name = "cool-domain"
version = "1.0.0" version = "1.1.0"
description = "Add your description here" description = "Add your description here"
readme = "README.md" readme = "README.md"
requires-python = ">=3.14" requires-python = ">=3.14"
Generated
+1 -1
View File
@@ -54,7 +54,7 @@ wheels = [
[[package]] [[package]]
name = "cool-domain" name = "cool-domain"
version = "1.0.0" version = "1.1.0"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "requests" }, { name = "requests" },