PHP 代理服务器

发布于 2024-10-13 01:59:10 字数 207 浏览 2 评论 0原文


我想知道是否有任何方法可以将我的网站变成代理服务器.. 我发现很多使用 PHP 的脚本,但它们都需要导航到站点才能使用
代理,但我真正想要的是一个脚本,当您在选项对话框中输入 IP 和端口号时,它使我能够通过浏览器配置访问该站点,就像在 Firefox 中一样,是否有任何类型的脚本可以做到这一点?
欢迎任何可以帮助我快速了解该主题的链接..
谢谢你,
AB

i was wondering if there is any way to turn my website into a proxy server ..
i found plenty of scripts using PHP but they all require navigating to site in order to use
the proxy, but what i really want is a script that enables me to access the site via browser configuration like in firefox when you enter the IP and port number in the options dialog, is there any kind of scripts that does that ?
any links may help me get quick on the subject are welcomed ..
Thank you,
AB

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木有鱼丸 2024-10-20 01:59:10

(以及更多内容,请询问 google)

这是您正在寻找的代理软件吗?只是 PHP 中的普通 HTTP 代理。

(and more, ask google)

Is this the kind of proxy software you're looking for? Just plain HTTP proxies in PHP.

年华零落成诗 2024-10-20 01:59:10

将你的适配器重定向到这台计算机的 IP 和端口,虽然它是同步的,所以速度会很慢。

    $addr   = gethostbyname('0.0.0.0'); //ip sensitive :((
    $server = stream_socket_server("tcp://" . $addr . ":8000", $errno, $errorMessage);

    echo "connected to: $addr:8000";

    if ($server === false) {
            throw new UnexpectedValueException("Could not bind to socket: $errorMessage");
    }

    $conns      = array( $server ); // connections
    $connection = 0;

    // loop forever
    for (;;) {
            $reads = $conns;

            // get number of connections with new data
            $mod = stream_select($reads, $write, $except, 5);
            if ($mod===false) break;

            // I have no idea what this does but what im doing here is separating the client ip and port from server 1:1 only!
            foreach ($reads as $read) {
                    if ($read===$server) {

                            // if a client is connected
                            if ($client = @stream_socket_accept( $server )) {

                                    echo "\nconnection from " . stream_socket_get_name( $client, true ) . "\n";

                                    $recv = fread($client, 1024);
                                    $rec_arr = explode( ' ', $recv );

                                    echo hex_dump($recv);

                                    if(strpos($recv, "CONNECT ")!==0) {

                                            if( $src = @fopen( $rec_arr[ 1 ], 'rb') ) {
                                                    while ($chunk = fread($src, 1024000)) {
                                                            @fwrite( $client, $chunk );
                                                    }

                                                    $chunk = "";

                                                    fclose( $src );
                                            }
                                    }

                                    stream_socket_shutdown($client, STREAM_SHUT_RDWR);
                            }
                    }
            }
    }

    function hex_dump($data, $newline="\n")
    {
            $from = '';
            $to = '';

            $width = 16; # number of bytes per line

            $pad = '.'; # padding for non-visible characters

            if ($from==='')
            {
                            for ($i=0; $i<=0xFF; $i++)
                            {
                                            $from .= chr($i);
                                            $to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad;
                            }
            }

            $hex = str_split(bin2hex($data), $width*2);
            $chars = str_split(strtr($data, $from, $to), $width);

            $offset = 0;
            foreach ($hex as $i => $line)
            {
                            $line = strtoupper( $line );

                            echo sprintf('%6X',$offset).' : '.implode(' ', str_split($line,2)) . ' [' . $chars[$i] . ']' . $newline;

                            $offset += $width;
            }
    }

Redirect your adapter to this computer's ip and port, its synchronous though so it'll be slow.

    $addr   = gethostbyname('0.0.0.0'); //ip sensitive :((
    $server = stream_socket_server("tcp://" . $addr . ":8000", $errno, $errorMessage);

    echo "connected to: $addr:8000";

    if ($server === false) {
            throw new UnexpectedValueException("Could not bind to socket: $errorMessage");
    }

    $conns      = array( $server ); // connections
    $connection = 0;

    // loop forever
    for (;;) {
            $reads = $conns;

            // get number of connections with new data
            $mod = stream_select($reads, $write, $except, 5);
            if ($mod===false) break;

            // I have no idea what this does but what im doing here is separating the client ip and port from server 1:1 only!
            foreach ($reads as $read) {
                    if ($read===$server) {

                            // if a client is connected
                            if ($client = @stream_socket_accept( $server )) {

                                    echo "\nconnection from " . stream_socket_get_name( $client, true ) . "\n";

                                    $recv = fread($client, 1024);
                                    $rec_arr = explode( ' ', $recv );

                                    echo hex_dump($recv);

                                    if(strpos($recv, "CONNECT ")!==0) {

                                            if( $src = @fopen( $rec_arr[ 1 ], 'rb') ) {
                                                    while ($chunk = fread($src, 1024000)) {
                                                            @fwrite( $client, $chunk );
                                                    }

                                                    $chunk = "";

                                                    fclose( $src );
                                            }
                                    }

                                    stream_socket_shutdown($client, STREAM_SHUT_RDWR);
                            }
                    }
            }
    }

    function hex_dump($data, $newline="\n")
    {
            $from = '';
            $to = '';

            $width = 16; # number of bytes per line

            $pad = '.'; # padding for non-visible characters

            if ($from==='')
            {
                            for ($i=0; $i<=0xFF; $i++)
                            {
                                            $from .= chr($i);
                                            $to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad;
                            }
            }

            $hex = str_split(bin2hex($data), $width*2);
            $chars = str_split(strtr($data, $from, $to), $width);

            $offset = 0;
            foreach ($hex as $i => $line)
            {
                            $line = strtoupper( $line );

                            echo sprintf('%6X',$offset).' : '.implode(' ', str_split($line,2)) . ' [' . $chars[$i] . ']' . $newline;

                            $offset += $width;
            }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文