我想知道是否有办法将我的网站变成代理服务器..
我发现有很多使用PHP的脚本,但它们都需要导航到站点才能使用
代理,但我真正想要的是一个脚本,当我在选项对话框中输入IP和端口号时,我可以通过Firefox中的浏览器配置访问网站,是否有任何类型的脚本可以做到这一点?>
任何链接都可以帮助我快速了解这个主题,欢迎光临。
谢谢,
AB
答案 0 :(得分:0)
(还有更多,请问google)
这是您正在寻找的代理软件吗?只是PHP中的普通HTTP代理。
答案 1 :(得分:0)
将你的适配器重定向到这台计算机的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;
}
}