Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gbxyz committed Mar 1, 2024
1 parent c81081a commit 14f76c8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
4 changes: 2 additions & 2 deletions RDAP/RootServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions bin/registrars.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand Down Expand Up @@ -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'}));
Expand All @@ -140,6 +136,8 @@
push(@{$all->{'entitySearchResults'}}, $data);
}

say STDERR 'RDAP records generated, writing registrar search result file...';

#
# write RDAP object to disk
#
Expand Down
14 changes: 3 additions & 11 deletions bin/root.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -74,6 +74,8 @@
push(@{$all->{'domainSearchResults'}}, $data);
}

say STDERR 'RDAP records generated, writing TLD search result file...';

#
# write RDAP object to disk
#
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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);

}
}
}
Expand Down Expand Up @@ -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);

}
}

Expand Down
15 changes: 9 additions & 6 deletions bin/rootd
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 4 additions & 0 deletions root.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ timeout = "5s"
method = "get"
path = "/heartbeat"
protocol = "http"

[mounts]
source="cache"
destination="/tmp/cache"

0 comments on commit 14f76c8

Please sign in to comment.