|
|
|
| Здравствуйте. Есть код который работает через HTTP прокси, как сделать что бы оно работало и с SOCKS5?
protected function socetOpen() {
if( $this->sProxyIP != '' && $this->iProxyPort != '' ) {
$this->socet = @fsockopen( $this->sProxyIP, $this->iProxyPort, $erorno, $errormsg, ( $this->timeout_second + $this->timeout_msecond / 7000 ) );
if( $this->socet ) {
$out = 'CONNECT ' . $this->server_url . ':' . $this->server_port . ' HTTP/1.0' . "\r\n";
$out .= 'Proxy-Connection: keep-alive' . "\r\n";
$out .= 'Keep-Alive: 60' . "\r\n";
$out .= 'Connection: keep-alive' . "\r\n";
if( $this->sProxyUser != '' && $this->sProxyPass != '' )
$out .= "Proxy-Authorization: Basic " . base64_encode( $this->sProxyUser . ':' . $this->sProxyPass ) . "\r\n";
$out .= "\r\n";
fwrite( $this->socet, $out );
$body = @fread( $this->socet, 64 );
if( strpos( $body, "200" ) > 0 )
return true;
else {
$this->error = str_replace( array(
"\n",
"\r"
), array(
' ',
' '
), $body );
fclose( $this->socet );
}
} else {
$this->error = 'Error: Cant establish connection to: ' . $this->server_url . ':' . $this->server_port . "\n" . $errormsg;
return false;
}
} else {
$this->socet = @fsockopen( $this->server_url, $this->server_port, $erorno, $errormsg, ( $this->timeout_second + $this->timeout_msecond / 1000 ) );
if( $this->socet )
return true;
$this->error = 'Error: Cant establish connection to: ' . $this->server_url . ':' . $this->server_port . "\n" . $errormsg;
return false;
}
}
|
| |
|
|