Skip to content

Commit

Permalink
implement auth and header set option
Browse files Browse the repository at this point in the history
  • Loading branch information
codenoid committed Aug 20, 2024
1 parent ae4df85 commit 13cd23a
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/LokalSo/Lokal.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,74 @@ class Options implements JsonSerializable

public function __construct() {}

public function setBasicAuth(string $username, string $password): self
{
$auth = "{$username}:{$password}";
if (!in_array($auth, $this->basic_auth)) {
$this->basic_auth[] = $auth;
}
return $this;
}

public function setCIDRAllow(string $cidr): self
{
if (!in_array($cidr, $this->cidr_allow)) {
$this->cidr_allow[] = $cidr;
}
return $this;
}

public function setCIDRDeny(string $cidr): self
{
if (!in_array($cidr, $this->cidr_deny)) {
$this->cidr_deny[] = $cidr;
}
return $this;
}

public function addRequestHeader(string $key, string $value): self
{
$header = "{$key}:{$value}";
if (!in_array($header, $this->request_header_add)) {
$this->request_header_add[] = $header;
}
return $this;
}

public function removeRequestHeader(string $header): self
{
if (!in_array($header, $this->request_header_remove)) {
$this->request_header_remove[] = $header;
}
return $this;
}

public function addResponseHeader(string $key, string $value): self
{
$header = "{$key}:{$value}";
if (!in_array($header, $this->response_header_add)) {
$this->response_header_add[] = $header;
}
return $this;
}

public function removeResponseHeader(string $header): self
{
if (!in_array($header, $this->response_header_remove)) {
$this->response_header_remove[] = $header;
}
return $this;
}

public function setHeaderKey(string $key, string $value): self
{
$header = "{$key}:{$value}";
if (!in_array($header, $this->header_key)) {
$this->header_key[] = $header;
}
return $this;
}

public function jsonSerialize(): array
{
return get_object_vars($this);
Expand Down Expand Up @@ -153,6 +221,12 @@ public function setLocalAddress(string $local_address): Tunnel
return $this;
}

public function setOptions(Options $options): Tunnel
{
$this->options = $options;
return $this;
}

public function setTunnelType(string $tunnel_type): Tunnel
{
$this->tunnel_type = $tunnel_type;
Expand Down

0 comments on commit 13cd23a

Please sign in to comment.