<?php
namespace App\Entity\VPN\V2ray;
use App\Entity\BaseEntity;
use App\Entity\Country;
use App\Repository\VPN\V2ray\ServerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: ServerRepository::class)]
class Server extends BaseEntity
{
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private ?string $id = null;
#[ORM\Column(length: 255)]
private ?string $ip = null;
#[ORM\Column(length: 255)]
private ?string $sshUsername = null;
#[ORM\Column(length: 255)]
private ?string $sshPassword = null;
#[ORM\Column(length: 255)]
private ?string $panelType = null;
#[ORM\Column(length: 255)]
private ?string $endpointAddress = null;
#[ORM\Column(length: 255)]
private ?string $panelUsername = null;
#[ORM\Column(length: 255)]
private ?string $panelPassword = null;
#[ORM\Column]
private ?int $panelPort = null;
#[ORM\Column(nullable: true)]
private ?int $totalServicesCount = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $dbAddress = null;
#[ORM\Column(length: 255)]
private ?string $usageScriptType = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $lastScriptUpdate = null;
#[ORM\Column]
private ?bool $isServerHasOwnerInfo = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $note = null;
#[ORM\ManyToOne(inversedBy: 'v2rayServers')]
#[ORM\JoinColumn(nullable: false)]
private ?Country $country = null;
/**
* @var Collection<int, Protocol>
*/
#[ORM\OneToMany(targetEntity: Protocol::class, mappedBy: 'server')]
private Collection $protocols;
#[ORM\Column(length: 255, nullable: true)]
private ?string $serverType = null;
public function __construct()
{
parent::__construct();
$this->protocols = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getIp(): ?string
{
return $this->ip;
}
public function setIp(string $ip): static
{
$this->ip = $ip;
return $this;
}
public function getSshUsername(): ?string
{
return $this->sshUsername;
}
public function setSshUsername(string $sshUsername): static
{
$this->sshUsername = $sshUsername;
return $this;
}
public function getSshPassword(): ?string
{
return $this->sshPassword;
}
public function setSshPassword(string $sshPassword): static
{
$this->sshPassword = $sshPassword;
return $this;
}
public function getPanelType(): ?string
{
return $this->panelType;
}
public function setPanelType(string $panelType): static
{
$this->panelType = $panelType;
return $this;
}
public function getEndpointAddress(): ?string
{
return $this->endpointAddress;
}
public function setEndpointAddress(string $endpointAddress): static
{
$this->endpointAddress = $endpointAddress;
return $this;
}
public function getPanelUsername(): ?string
{
return $this->panelUsername;
}
public function setPanelUsername(string $panelUsername): static
{
$this->panelUsername = $panelUsername;
return $this;
}
public function getPanelPassword(): ?string
{
return $this->panelPassword;
}
public function setPanelPassword(string $panelPassword): static
{
$this->panelPassword = $panelPassword;
return $this;
}
public function getPanelPort(): ?int
{
return $this->panelPort;
}
public function setPanelPort(int $panelPort): static
{
$this->panelPort = $panelPort;
return $this;
}
public function getTotalServicesCount(): ?int
{
return $this->totalServicesCount;
}
public function setTotalServicesCount(?int $totalServicesCount): static
{
$this->totalServicesCount = $totalServicesCount;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getDbAddress(): ?string
{
return $this->dbAddress;
}
public function setDbAddress(?string $dbAddress): static
{
$this->dbAddress = $dbAddress;
return $this;
}
public function getUsageScriptType(): ?string
{
return $this->usageScriptType;
}
public function setUsageScriptType(string $usageScriptType): static
{
$this->usageScriptType = $usageScriptType;
return $this;
}
public function getLastScriptUpdate(): ?\DateTimeInterface
{
return $this->lastScriptUpdate;
}
public function setLastScriptUpdate(?\DateTimeInterface $lastScriptUpdate): static
{
$this->lastScriptUpdate = $lastScriptUpdate;
return $this;
}
public function isServerHasOwnerInfo(): ?bool
{
return $this->isServerHasOwnerInfo;
}
public function setIsServerHasOwnerInfo(bool $isServerHasOwnerInfo): static
{
$this->isServerHasOwnerInfo = $isServerHasOwnerInfo;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): static
{
$this->note = $note;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): static
{
$this->country = $country;
return $this;
}
/**
* @return Collection<int, Protocol>
*/
public function getProtocols(): Collection
{
return $this->protocols;
}
public function addProtocol(Protocol $protocol): static
{
if (!$this->protocols->contains($protocol)) {
$this->protocols->add($protocol);
$protocol->setServer($this);
}
return $this;
}
public function removeProtocol(Protocol $protocol): static
{
if ($this->protocols->removeElement($protocol)) {
// set the owning side to null (unless already changed)
if ($protocol->getServer() === $this) {
$protocol->setServer(null);
}
}
return $this;
}
public function getServerType(): ?string
{
return $this->serverType;
}
public function setServerType(?string $serverType): static
{
$this->serverType = $serverType;
return $this;
}
}