Skip to content

Commit

Permalink
Add previous missing and invalid TLDs (#7)
Browse files Browse the repository at this point in the history
* Add support for invalid dict/TLD names

* Add missing TLDs
  • Loading branch information
SWx5YWF6 authored Nov 16, 2022
1 parent 51ad43d commit 4d144f2
Show file tree
Hide file tree
Showing 3 changed files with 371 additions and 338 deletions.
7 changes: 5 additions & 2 deletions tld.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ curl https://gist.githubusercontent.com/thde/3890aa48e03a2b551374/raw/138589bfca
TLDs=$(cut -d " " -f1 whois.conf | sed -e 's/\\//' -e 's/\.//' -e 's/\$//' | egrep -v '^$|^#')

# Skip existing supported TLDs
SKIP=$(grep = ./whois/tld_regexpr.py | cut -d " " -f1)
# Skip commented TLDs
# Remove underscore at end of TLDs
# Replace underscore with hypen
SKIP=$(grep = ./whois/tld_regexpr.py | sed -e 's/^#//g' -e 's/_\s/ /' -e 's/_/-/g' | cut -d " " -f1)

config(){
tld="$1"
Expand All @@ -20,6 +23,6 @@ EOF
}

for tld in $TLDs; do
[[ $SKIP =~ .*$tld.* ]] && continue
[[ $SKIP =~ (^|.*[[:space:]])$tld([[:space:]].*|$) ]] && continue
config $tld
done
8 changes: 6 additions & 2 deletions whois/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def query(domain, host=None, force=0, cache_file=None, slow_down=0, ignore_retur
tld = 'co_jp'
elif domain.endswith('.рф') or domain.endswith('.xn--p1ai'):
tld = 'ru_rf'
elif domain.endswith('.in'):
tld = 'IN'
elif domain.endswith(('.as','.global','.help','.id','.in','.int','.is','.next','.property','.zip')):
# Convert TLD which matches a Python function/keyword by adding suffix
tld = d[-1] + '_'
elif '-' in domain:
# Convert invalid dict name
tld = d[-1].replace('-', '_')
else:
tld = d[-1]

Expand Down
Loading

0 comments on commit 4d144f2

Please sign in to comment.