mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-11-29 10:53:31 +00:00
Update index.php
This commit is contained in:
parent
ee40d26ace
commit
84ea323b49
10
index.php
10
index.php
|
|
@ -57,7 +57,11 @@ function parse_headers($str) { // Parses HTTP headers into an array
|
||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_from_remote_server($remote_address, $remote_port, $conn = null, $buffer_size = 8192) {
|
function read_from_remote_server($remote_address, $remote_port, $scheme, $conn = null, $buffer_size = 8192) {
|
||||||
|
if (in_array($scheme, array("https", "ssl", "tls"))) {
|
||||||
|
$remote_address = "tls://" . $remote_address;
|
||||||
|
}
|
||||||
|
|
||||||
$sock = fsockopen($remote_address, $remote_port, $error_code, $error_message, 1);
|
$sock = fsockopen($remote_address, $remote_port, $error_code, $error_message, 1);
|
||||||
if (!$sock) {
|
if (!$sock) {
|
||||||
$error = array(
|
$error = array(
|
||||||
|
|
@ -117,7 +121,7 @@ function relay_request($params) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
read_from_remote_server($remote_address, $remote_port, null, $buffer_size);
|
read_from_remote_server($remote_address, $remote_port, $scheme, null, $buffer_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +147,7 @@ function relay_connect($params) {
|
||||||
echo "HTTP/1.1 400 Bad Request\r\n\r\n" . jsonrpc2_error_encode($error);
|
echo "HTTP/1.1 400 Bad Request\r\n\r\n" . jsonrpc2_error_encode($error);
|
||||||
} else {
|
} else {
|
||||||
fwrite($conn, jsonrpc2_result_encode(array("success" => true)));
|
fwrite($conn, jsonrpc2_result_encode(array("success" => true)));
|
||||||
read_from_remote_server($remote_address, $remote_port, $conn, $buffer_size);
|
read_from_remote_server($remote_address, $remote_port, $scheme, $conn, $buffer_size);
|
||||||
fclose($conn);
|
fclose($conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user