Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose connection info in responses (addresses and TLS)
- Loading branch information
Showing
5 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Amp\Artax; | ||
|
||
final class ConnectionInfo { | ||
private $localAddress; | ||
private $remoteAddress; | ||
private $tlsInfo; | ||
|
||
public function __construct(string $localAddress, string $remoteAddress, TlsInfo $tlsInfo = null) { | ||
$this->localAddress = $localAddress; | ||
$this->remoteAddress = $remoteAddress; | ||
$this->tlsInfo = $tlsInfo; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLocalAddress(): string { | ||
return $this->localAddress; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRemoteAddress(): string { | ||
return $this->remoteAddress; | ||
} | ||
|
||
/** | ||
* @return TlsInfo|null | ||
*/ | ||
public function getTlsInfo() { | ||
return $this->tlsInfo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Amp\Artax; | ||
|
||
final class TlsInfo { | ||
private $protocol; | ||
private $cipherName; | ||
private $cipherBits; | ||
private $cipherVersion; | ||
|
||
private function __construct(string $protocol, string $cipherName, int $cipherBits, string $cipherVersion) { | ||
$this->protocol = $protocol; | ||
$this->cipherName = $cipherName; | ||
$this->cipherBits = $cipherBits; | ||
$this->cipherVersion = $cipherVersion; | ||
} | ||
|
||
public static function fromMetaData(array $crypto): TlsInfo { | ||
return new self($crypto["protocol"], $crypto["cipher_name"], $crypto["cipher_bits"], $crypto["cipher_version"]); | ||
} | ||
|
||
public function getProtocol(): string { | ||
return $this->protocol; | ||
} | ||
|
||
public function getCipherName(): string { | ||
return $this->cipherName; | ||
} | ||
|
||
public function getCipherBits(): int { | ||
return $this->cipherBits; | ||
} | ||
|
||
public function getCipherVersion(): string { | ||
return $this->cipherVersion; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters