Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

https+wss proxy #13

Open
Open
@xenion54

Description

Hi @walkor. In my project, i'm using this awesome example of http proxy server. And its work fine. Btw its work for http+websocket proxy.
But when i try to use it with https and wss its fail.
I see, that this is because in method "onMessage" i have encrypted data. Can you pls help me to solve this task?

Of cource, when i do this

$remote_connection->pipe($connection); 
$connection->pipe($remote_connection);
$remote_connection->connect();

data passing encrypted to destination and its not what he expects.

I try to replace tcp://0.0.0.0:xxx to http://0.0.0.0:xxx, but it still not working. Pls, help me.

Here is my minimal code, for reproduce

<?php
$context = array(
 'ssl' => array(
 'local_cert' => app_paths['ssl_public_key'], // Alternatively, it can be a crt file
 'local_pk' => app_paths['ssl_private_key'],
 'verify_peer' => false,
 'allow_self_signed' => true,
 )
);
$worker = new Worker('tcp://0.0.0.0:' . $args['port'], $context);
$worker->transport = 'ssl';
$worker->onMessage = function ($connection, $buffer) use ($args) {
 list($method, $addr, $http_version) = explode('', $buffer);
 $remote_connection = new AsyncTcpConnection("tcp://{$args['proxy-ip']}:{$args['port']}");
 if ($method !== 'CONNECT') {
 $remote_connection->send($buffer);
 } else {
 $connection->send("HTTP/1.1 200 Connection Established\r\n\r\n");
 }
 $remote_connection->pipe($connection);
 $connection->pipe($remote_connection);
 $remote_connection->connect();
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /