Skip to content

Commit

Permalink
Proxy support fixed #53
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Dec 21, 2020
1 parent 2b0e812 commit 835373a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Connection/Protocols/Protocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ public function getProxy() {

/**
* Prepare socket options
* @var string $transport
*
* @return array
*/
private function defaultSocketOptions() {
private function defaultSocketOptions($transport) {
$options = [];
if ($this->encryption != false) {
$options["ssl"] = [
Expand All @@ -158,13 +159,13 @@ private function defaultSocketOptions() {
}

if ($this->proxy["socket"] != null) {
$options["proxy"] = $this->proxy["socket"];
$options["request_fulluri"] = $this->proxy["request_fulluri"];
$options[$transport]["proxy"] = $this->proxy["socket"];
$options[$transport]["request_fulluri"] = $this->proxy["request_fulluri"];

if ($this->proxy["username"] != null) {
$auth = base64_encode($this->proxy["username"].':'.$this->proxy["password"]);

$options["header"] = [
$options[$transport]["header"] = [
"Proxy-Authorization: Basic $auth"
];
}
Expand All @@ -188,7 +189,7 @@ protected function createStream($transport, $host, $port, $timeout) {
$socket = "$transport://$host:$port";
$stream = stream_socket_client($socket, $errno, $errstr, $timeout,
STREAM_CLIENT_CONNECT,
stream_context_create($this->defaultSocketOptions())
stream_context_create($this->defaultSocketOptions($transport))
);

if (!$stream) {
Expand Down

0 comments on commit 835373a

Please sign in to comment.