mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 10:15:41 +00:00
feat: add tld properties
This commit is contained in:
parent
08e13e73c4
commit
300e68e3a1
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240717182345 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE domain ADD COLUMN created_at DATE NOT NULL');
|
||||
$this->addSql('ALTER TABLE domain ADD COLUMN updated_at DATE NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TEMPORARY TABLE __temp__domain AS SELECT ldh_name, handle, status FROM domain');
|
||||
$this->addSql('DROP TABLE domain');
|
||||
$this->addSql('CREATE TABLE domain (ldh_name VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
|
||||
, PRIMARY KEY(ldh_name))');
|
||||
$this->addSql('INSERT INTO domain (ldh_name, handle, status) SELECT ldh_name, handle, status FROM __temp__domain');
|
||||
$this->addSql('DROP TABLE __temp__domain');
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240718170120 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE rdap_server (tld VARCHAR(63) NOT NULL, url VARCHAR(255) NOT NULL, updated_at DATE NOT NULL --(DC2Type:date_immutable)
|
||||
, PRIMARY KEY(tld, url))');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP TABLE rdap_server');
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240713145845 extends AbstractMigration
|
||||
final class Version20240719124300 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
@ -20,8 +20,11 @@ final class Version20240713145845 extends AbstractMigration
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE domain (ldh_name VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
|
||||
, PRIMARY KEY(ldh_name))');
|
||||
$this->addSql('CREATE TABLE domain (ldh_name VARCHAR(255) NOT NULL, tld_id VARCHAR(63) NOT NULL, handle VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
|
||||
, created_at DATE NOT NULL --(DC2Type:date_immutable)
|
||||
, updated_at DATE NOT NULL --(DC2Type:date_immutable)
|
||||
, PRIMARY KEY(ldh_name), CONSTRAINT FK_A7A91E0B50F7084E FOREIGN KEY (tld_id) REFERENCES tld (tld) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
||||
$this->addSql('CREATE INDEX IDX_A7A91E0B50F7084E ON domain (tld_id)');
|
||||
$this->addSql('CREATE TABLE domain_nameservers (domain_ldh_name VARCHAR(255) NOT NULL, nameserver_ldh_name VARCHAR(255) NOT NULL, PRIMARY KEY(domain_ldh_name, nameserver_ldh_name), CONSTRAINT FK_B6E6B63AAF923913 FOREIGN KEY (domain_ldh_name) REFERENCES domain (ldh_name) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_B6E6B63AA6496BFE FOREIGN KEY (nameserver_ldh_name) REFERENCES nameserver (ldh_name) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
||||
$this->addSql('CREATE INDEX IDX_B6E6B63AAF923913 ON domain_nameservers (domain_ldh_name)');
|
||||
$this->addSql('CREATE INDEX IDX_B6E6B63AA6496BFE ON domain_nameservers (nameserver_ldh_name)');
|
||||
@ -43,6 +46,10 @@ final class Version20240713145845 extends AbstractMigration
|
||||
, PRIMARY KEY(nameserver_id, entity_id), CONSTRAINT FK_A269AFB41A555619 FOREIGN KEY (nameserver_id) REFERENCES nameserver (ldh_name) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_A269AFB481257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
||||
$this->addSql('CREATE INDEX IDX_A269AFB41A555619 ON nameserver_entity (nameserver_id)');
|
||||
$this->addSql('CREATE INDEX IDX_A269AFB481257D5D ON nameserver_entity (entity_id)');
|
||||
$this->addSql('CREATE TABLE rdap_server (url VARCHAR(255) NOT NULL, tld_id VARCHAR(63) NOT NULL, updated_at DATE NOT NULL --(DC2Type:date_immutable)
|
||||
, PRIMARY KEY(url, tld_id), CONSTRAINT FK_CCBF17A850F7084E FOREIGN KEY (tld_id) REFERENCES tld (tld) NOT DEFERRABLE INITIALLY IMMEDIATE)');
|
||||
$this->addSql('CREATE INDEX IDX_CCBF17A850F7084E ON rdap_server (tld_id)');
|
||||
$this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, PRIMARY KEY(tld))');
|
||||
$this->addSql('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles CLOB NOT NULL --(DC2Type:json)
|
||||
, password VARCHAR(255) NOT NULL)');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON user (email)');
|
||||
@ -71,6 +78,8 @@ final class Version20240713145845 extends AbstractMigration
|
||||
$this->addSql('DROP TABLE entity_event');
|
||||
$this->addSql('DROP TABLE nameserver');
|
||||
$this->addSql('DROP TABLE nameserver_entity');
|
||||
$this->addSql('DROP TABLE rdap_server');
|
||||
$this->addSql('DROP TABLE tld');
|
||||
$this->addSql('DROP TABLE user');
|
||||
$this->addSql('DROP TABLE watch_list');
|
||||
$this->addSql('DROP TABLE watch_lists_domains');
|
||||
40
migrations/Version20240719164643.php
Normal file
40
migrations/Version20240719164643.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240719164643 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE tld ADD COLUMN contract_terminated BOOLEAN DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE tld ADD COLUMN date_of_contract_signature DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE tld ADD COLUMN delegation_date DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE tld ADD COLUMN registry_operator VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE tld ADD COLUMN removal_date DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE tld ADD COLUMN specification13 BOOLEAN DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TEMPORARY TABLE __temp__tld AS SELECT tld FROM tld');
|
||||
$this->addSql('DROP TABLE tld');
|
||||
$this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, PRIMARY KEY(tld))');
|
||||
$this->addSql('INSERT INTO tld (tld) SELECT tld FROM __temp__tld');
|
||||
$this->addSql('DROP TABLE __temp__tld');
|
||||
}
|
||||
}
|
||||
@ -105,6 +105,10 @@ class Domain
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
|
||||
private ?Tld $tld = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->events = new ArrayCollection();
|
||||
@ -293,4 +297,16 @@ class Domain
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
}
|
||||
|
||||
public function getTld(): ?Tld
|
||||
{
|
||||
return $this->tld;
|
||||
}
|
||||
|
||||
public function setTld(?Tld $tld): static
|
||||
{
|
||||
$this->tld = $tld;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,9 +10,6 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
#[ORM\Entity(repositoryClass: RdapServerRepository::class)]
|
||||
class RdapServer
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(length: 63)]
|
||||
private ?string $tld = null;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(length: 255)]
|
||||
@ -21,23 +18,17 @@ class RdapServer
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\ManyToOne(inversedBy: 'rdapServers')]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
|
||||
private ?Tld $tld = null;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->updatedAt = new DateTimeImmutable('now');
|
||||
}
|
||||
|
||||
public function getTld(): ?string
|
||||
{
|
||||
return $this->tld;
|
||||
}
|
||||
|
||||
public function setTld(string $tld): static
|
||||
{
|
||||
$this->tld = $tld;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->url;
|
||||
@ -68,4 +59,16 @@ class RdapServer
|
||||
{
|
||||
$this->setUpdatedAt(new DateTimeImmutable('now'));
|
||||
}
|
||||
|
||||
public function getTld(): ?Tld
|
||||
{
|
||||
return $this->tld;
|
||||
}
|
||||
|
||||
public function setTld(?Tld $tld): static
|
||||
{
|
||||
$this->tld = $tld;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
160
src/Entity/Tld.php
Normal file
160
src/Entity/Tld.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\TldRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TldRepository::class)]
|
||||
class Tld
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(length: 63)]
|
||||
private ?string $tld = null;
|
||||
/**
|
||||
* @var Collection<int, RdapServer>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: RdapServer::class, mappedBy: 'tld', orphanRemoval: true)]
|
||||
private Collection $rdapServers;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $contractTerminated = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?DateTimeImmutable $dateOfContractSignature = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?DateTimeImmutable $delegationDate = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $registryOperator = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?DateTimeImmutable $removalDate = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $specification13 = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->rdapServers = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, RdapServer>
|
||||
*/
|
||||
public function getRdapServers(): Collection
|
||||
{
|
||||
return $this->rdapServers;
|
||||
}
|
||||
|
||||
public function addRdapServer(RdapServer $rdapServer): static
|
||||
{
|
||||
if (!$this->rdapServers->contains($rdapServer)) {
|
||||
$this->rdapServers->add($rdapServer);
|
||||
$rdapServer->setTld($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeRdapServer(RdapServer $rdapServer): static
|
||||
{
|
||||
if ($this->rdapServers->removeElement($rdapServer)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($rdapServer->getTld() === $this) {
|
||||
$rdapServer->setTld(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTld(): ?string
|
||||
{
|
||||
return $this->tld;
|
||||
}
|
||||
|
||||
public function setTld(string $tld): static
|
||||
{
|
||||
$this->tld = strtolower($tld);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isContractTerminated(): ?bool
|
||||
{
|
||||
return $this->contractTerminated;
|
||||
}
|
||||
|
||||
public function setContractTerminated(?bool $contractTerminated): static
|
||||
{
|
||||
$this->contractTerminated = $contractTerminated;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateOfContractSignature(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->dateOfContractSignature;
|
||||
}
|
||||
|
||||
public function setDateOfContractSignature(?DateTimeImmutable $dateOfContractSignature): static
|
||||
{
|
||||
$this->dateOfContractSignature = $dateOfContractSignature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelegationDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->delegationDate;
|
||||
}
|
||||
|
||||
public function setDelegationDate(?DateTimeImmutable $delegationDate): static
|
||||
{
|
||||
$this->delegationDate = $delegationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRegistryOperator(): ?string
|
||||
{
|
||||
return $this->registryOperator;
|
||||
}
|
||||
|
||||
public function setRegistryOperator(?string $registryOperator): static
|
||||
{
|
||||
$this->registryOperator = $registryOperator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRemovalDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->removalDate;
|
||||
}
|
||||
|
||||
public function setRemovalDate(?DateTimeImmutable $removalDate): static
|
||||
{
|
||||
$this->removalDate = $removalDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isSpecification13(): ?bool
|
||||
{
|
||||
return $this->specification13;
|
||||
}
|
||||
|
||||
public function setSpecification13(?bool $specification13): static
|
||||
{
|
||||
$this->specification13 = $specification13;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Throwable;
|
||||
|
||||
#[AsMessageHandler]
|
||||
final readonly class UpdateRdapServersHandler
|
||||
@ -25,10 +26,28 @@ final readonly class UpdateRdapServersHandler
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws ClientExceptionInterface|Throwable
|
||||
*/
|
||||
public function __invoke(UpdateRdapServers $message): void
|
||||
{
|
||||
/** @var Throwable[] $throws */
|
||||
$throws = [];
|
||||
try {
|
||||
$this->RDAPService->updateTldListIANA();
|
||||
} catch (Throwable $throwable) {
|
||||
$throws[] = $throwable;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->RDAPService->updateGTldListICANN();
|
||||
} catch (Throwable $throwable) {
|
||||
$throws[] = $throwable;
|
||||
}
|
||||
try {
|
||||
$this->RDAPService->updateRDAPServers();
|
||||
} catch (Throwable $throwable) {
|
||||
$throws[] = $throwable;
|
||||
}
|
||||
if (!empty($throwable)) throw $throws[0];
|
||||
}
|
||||
}
|
||||
|
||||
43
src/Repository/TldRepository.php
Normal file
43
src/Repository/TldRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Tld;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Tld>
|
||||
*/
|
||||
class TldRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Tld::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Tld[] Returns an array of Tld objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('t')
|
||||
// ->andWhere('t.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('t.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Tld
|
||||
// {
|
||||
// return $this->createQueryBuilder('t')
|
||||
// ->andWhere('t.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
@ -22,7 +22,7 @@ final readonly class UpdateRdapServersSchedule implements ScheduleProviderInterf
|
||||
{
|
||||
return (new Schedule())
|
||||
->add(
|
||||
RecurringMessage::every('1 month', new UpdateRdapServers()),
|
||||
RecurringMessage::every('30 seconds', new UpdateRdapServers()),
|
||||
)->stateful($this->cache);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ use App\Entity\EntityEvent;
|
||||
use App\Entity\Nameserver;
|
||||
use App\Entity\NameserverEntity;
|
||||
use App\Entity\RdapServer;
|
||||
use App\Entity\Tld;
|
||||
use App\Repository\DomainEntityRepository;
|
||||
use App\Repository\DomainEventRepository;
|
||||
use App\Repository\DomainRepository;
|
||||
@ -21,8 +22,10 @@ use App\Repository\EntityRepository;
|
||||
use App\Repository\NameserverEntityRepository;
|
||||
use App\Repository\NameserverRepository;
|
||||
use App\Repository\RdapServerRepository;
|
||||
use App\Repository\TldRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Exception\ORMException;
|
||||
use Exception;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
@ -44,6 +47,7 @@ readonly class RDAPService
|
||||
private EntityEventRepository $entityEventRepository,
|
||||
private DomainEntityRepository $domainEntityRepository,
|
||||
private RdapServerRepository $rdapServerRepository,
|
||||
private TldRepository $tldRepository,
|
||||
private EntityManagerInterface $em
|
||||
)
|
||||
{
|
||||
@ -66,9 +70,10 @@ readonly class RDAPService
|
||||
private function registerDomain(string $fqdn): void
|
||||
{
|
||||
$idnDomain = idn_to_ascii($fqdn);
|
||||
$tld = $this->getTld($idnDomain);
|
||||
|
||||
/** @var RdapServer|null $rdapServer */
|
||||
$rdapServer = $this->rdapServerRepository->findOneBy(["tld" => RDAPService::getTld($idnDomain)]);
|
||||
$rdapServer = $this->rdapServerRepository->findOneBy(["tld" => $tld], ["updatedAt" => "DESC"]);
|
||||
|
||||
if ($rdapServer === null) throw new Exception("Unable to determine which RDAP server to contact");
|
||||
|
||||
@ -84,6 +89,7 @@ readonly class RDAPService
|
||||
if ($domain === null) $domain = new Domain();
|
||||
|
||||
$domain
|
||||
->setTld($tld)
|
||||
->setLdhName($res['ldhName'])
|
||||
->setHandle($res['handle'])
|
||||
->setStatus($res['status']);
|
||||
@ -178,13 +184,15 @@ readonly class RDAPService
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function getTld($domain): string
|
||||
private function getTld($domain): ?object
|
||||
{
|
||||
$lastDotPosition = strrpos($domain, '.');
|
||||
if ($lastDotPosition === false) {
|
||||
throw new Exception("Domain must contain at least one dot");
|
||||
}
|
||||
return strtolower(substr($domain, $lastDotPosition + 1));
|
||||
$tld = strtolower(substr($domain, $lastDotPosition + 1));
|
||||
|
||||
return $this->tldRepository->findOneBy(["tld" => $tld]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,6 +248,7 @@ readonly class RDAPService
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws ORMException
|
||||
*/
|
||||
public function updateRDAPServers(): void
|
||||
{
|
||||
@ -250,11 +259,11 @@ readonly class RDAPService
|
||||
foreach ($dnsRoot['services'] as $service) {
|
||||
|
||||
foreach ($service[0] as $tld) {
|
||||
$tldReference = $this->em->getReference(Tld::class, $tld);
|
||||
foreach ($service[1] as $rdapServerUrl) {
|
||||
$server = $this->rdapServerRepository->findOneBy(["tld" => $tld, "url" => $rdapServerUrl]);
|
||||
$server = $this->rdapServerRepository->findOneBy(["tld" => $tldReference, "url" => $rdapServerUrl]); //ICI
|
||||
if ($server === null) $server = new RdapServer();
|
||||
|
||||
$server->setTld($tld)->setUrl($rdapServerUrl)->updateTimestamps();
|
||||
$server->setTld($tldReference)->setUrl($rdapServerUrl)->updateTimestamps();
|
||||
|
||||
$this->em->persist($server);
|
||||
}
|
||||
@ -263,4 +272,60 @@ readonly class RDAPService
|
||||
}
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function updateTldListIANA(): void
|
||||
{
|
||||
$tldList = array_map(
|
||||
fn($tld) => strtolower($tld),
|
||||
explode(PHP_EOL,
|
||||
$this->client->request(
|
||||
'GET', 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt'
|
||||
)->getContent()
|
||||
));
|
||||
array_shift($tldList);
|
||||
$storedTldList = array_map(fn($tld) => $tld->getTld(), $this->tldRepository->findAll());
|
||||
|
||||
|
||||
foreach (array_diff($tldList, $storedTldList) as $tld) {
|
||||
$this->em->persist((new Tld())->setTld($tld));
|
||||
}
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateGTldListICANN(): void
|
||||
{
|
||||
$gTldList = $this->client->request(
|
||||
'GET', 'https://www.icann.org/resources/registries/gtlds/v2/gtlds.json'
|
||||
)->toArray()['gTLDs'];
|
||||
|
||||
foreach ($gTldList as $gTld) {
|
||||
$gtTldEntity = $this->tldRepository->findOneBy(['tld' => $gTld['gTLD']]);
|
||||
if ($gtTldEntity === null) $gtTldEntity = new Tld();
|
||||
|
||||
$gtTldEntity
|
||||
->setTld($gTld['gTLD'])
|
||||
->setContractTerminated($gTld['contractTerminated'])
|
||||
->setRegistryOperator($gTld['registryOperator'])
|
||||
->setSpecification13($gTld['specification13']);
|
||||
if ($gTld['removalDate'] !== null) $gtTldEntity->setRemovalDate(new DateTimeImmutable($gTld['removalDate']));
|
||||
if ($gTld['delegationDate'] !== null) $gtTldEntity->setDelegationDate(new DateTimeImmutable($gTld['delegationDate']));
|
||||
if ($gTld['dateOfContractSignature'] !== null) $gtTldEntity->setDateOfContractSignature(new DateTimeImmutable($gTld['dateOfContractSignature']));
|
||||
$this->em->persist($gtTldEntity);
|
||||
}
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user