Update index.php

This commit is contained in:
Namhyeon Go 2024-02-26 14:12:57 +09:00 committed by GitHub
parent 7619ebbcaf
commit 05bc9ba978
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,9 +60,9 @@ function parse_headers($str) { // Parses HTTP headers into an array
// stateless mode // stateless mode
function relay_request($params) { function relay_request($params) {
$buffer_size = $params['buffer_size']; $buffer_size = $params['buffer_size'];
$data = base64_decode($params['data']); $request_data = base64_decode($params['request_data']);
$rawdata_length = intval($params['data_length']); $request_header = parse_headers($request_data);
$headers = parse_headers($data); $request_length = intval($params['request_length']);
$client_address = $params['client_address']; $client_address = $params['client_address'];
$client_port = intval($params['client_port']); $client_port = intval($params['client_port']);
$client_encoding = $params['client_encoding']; $client_encoding = $params['client_encoding'];
@ -76,9 +76,9 @@ function relay_request($params) {
$remote_address = "tls://" . $remote_address; $remote_address = "tls://" . $remote_address;
} }
switch ($relay_headers['@method'][0]) { switch ($request_header['@method'][0]) {
case "CONNECT": case "CONNECT":
echo sprintf("%s 200 Connection Established\r\n\r\n", $relay_headers['@method'][2]); echo sprintf("%s 200 Connection Established\r\n\r\n", $request_header['@method'][2]);
break; break;
default: default:
@ -91,7 +91,7 @@ function relay_request($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($fp, $data); fwrite($fp, $request_data);
$buf = null; $buf = null;
while (!feof($fp) && $buf !== false) { while (!feof($fp) && $buf !== false) {