From 14f76c8b0e86c3696081e6151bb1c01730c475ec Mon Sep 17 00:00:00 2001 From: Gavin Brown Date: Fri, 1 Mar 2024 11:09:13 +0000 Subject: [PATCH] updated --- RDAP/RootServer.php | 4 ++-- bin/registrars.pl | 8 +++----- bin/root.pl | 14 +++----------- bin/rootd | 15 +++++++++------ docker-compose.yml | 4 ++-- root.toml | 4 ++++ 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/RDAP/RootServer.php b/RDAP/RootServer.php index 8bcae39..a30d4bf 100644 --- a/RDAP/RootServer.php +++ b/RDAP/RootServer.php @@ -11,8 +11,8 @@ */ class RootServer extends Server { - private const ROOTDIR = '/tmp/tlds'; - private const RARDIR = '/tmp/registrars'; + private const ROOTDIR = '/tmp/cache/tlds'; + private const RARDIR = '/tmp/cache/registrars'; /** * load the registry data and then start the server diff --git a/bin/registrars.pl b/bin/registrars.pl index cf6591c..a00d427 100755 --- a/bin/registrars.pl +++ b/bin/registrars.pl @@ -49,7 +49,7 @@ my $rars = $object->{'accredited-registrars-{"languageTag":"en","siteLanguageTag":"en","slug":"accredited-registrars"}'}->{'data'}->{'accreditedRegistrarsOperations'}->{'registrars'}; -say STDERR 'generating RDAP records...'; +say STDERR 'generating RDAP records for registrars...'; foreach my $rar (sort { $a->{'ianaNumber'} <=> $b->{'ianaNumber'} } @{$rars}) { my $id = $rar->{'ianaNumber'}; @@ -127,10 +127,6 @@ if (!write_file($jfile, {'binmode' => ':utf8'}, $json->encode($data))) { printf(STDERR "Unable to write data to '%s': %s\n", $jfile, $!); exit(1); - - } else { - say STDERR sprintf('wrote %s', $jfile); - } $all->{'notices'} = $data->{'notices'} unless (defined($all->{'notices'})); @@ -140,6 +136,8 @@ push(@{$all->{'entitySearchResults'}}, $data); } +say STDERR 'RDAP records generated, writing registrar search result file...'; + # # write RDAP object to disk # diff --git a/bin/root.pl b/bin/root.pl index 4ca36e7..990ac11 100755 --- a/bin/root.pl +++ b/bin/root.pl @@ -62,7 +62,7 @@ 'domainSearchResults' => [], }; -say STDERR 'generating RDAP records...'; +say STDERR 'generating RDAP records for TLDs...'; foreach my $tld (@tlds) { my $data = process_tld($tld); @@ -74,6 +74,8 @@ push(@{$all->{'domainSearchResults'}}, $data); } +say STDERR 'RDAP records generated, writing TLD search result file...'; + # # write RDAP object to disk # @@ -103,8 +105,6 @@ sub process_tld { my $data; if (-e $jfile && stat($jfile) >= time() - TTL_SECS) { - printf(STDERR "file %s is up to date\n", $jfile); - my @data = read_file($jfile); $data = $json->decode(join('', @data)); @@ -135,10 +135,6 @@ sub process_tld { if (!write_file($file, {'binmode' => ':utf8'}, @data)) { printf(STDERR "Unable to write data to '%s': %s\n", $file, $!); exit(1); - - } else { - say STDERR sprintf('updated WHOIS record for .%s', $tld); - } } } @@ -445,10 +441,6 @@ sub process_tld { if (!write_file($jfile, {'binmode' => ':utf8'}, $json->encode($data))) { printf(STDERR "Unable to write to '%s': %s\n", $jfile, $!); next; - - } else { - say STDERR sprintf('wrote %s', $jfile); - } } diff --git a/bin/rootd b/bin/rootd index 2b1fb40..01db8dd 100755 --- a/bin/rootd +++ b/bin/rootd @@ -1,17 +1,20 @@ #!/bin/sh export PATH="$PATH:/app:$(dirname "$0")" -mkdir -p /tmp/registrars /tmp/tlds +BASEDIR="/tmp/cache" +ROOTDIR="$BASEDIR/tlds" +RARDIR="$BASEDIR/registrars" +mkdir -p "$ROOTDIR" "$RARDIR" update_data() { - registrars.pl /tmp/registrars & - PID1=$! + registrars.pl "$RARDIR" & + PID1="$!" - root.pl /tmp/tlds & - PID2=$! + root.pl "$ROOTDIR" & + PID2="$!" - wait $PID1 $PID2 + wait "$PID1" "$PID2" } update_data diff --git a/docker-compose.yml b/docker-compose.yml index 6cc377e..55a239e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,8 +17,8 @@ services: build: . volumes: - .:/app - - tld_cache:/tmp/tlds - - rar_cache:/tmp/registrars + - tld_cache:/tmp/cache/tlds + - rar_cache:/tmp/cache/registrars ports: - 8181:8080 command: ["/app/bin/rootd"] diff --git a/root.toml b/root.toml index 4358201..8e2af36 100644 --- a/root.toml +++ b/root.toml @@ -24,3 +24,7 @@ timeout = "5s" method = "get" path = "/heartbeat" protocol = "http" + +[mounts] +source="cache" +destination="/tmp/cache"