Что нужно для работы SOCKS прокси на хостинге?
Добрый вечер. Столкнулся с такой проблемой, не работают SOCKS прокси на хостинге через CURL. На домашнем сервере все нормально, однако на хостинге возникает ошибка «Failed to resolve «сайт» for SOCKS4 connect.
Собственно, сам код:
if ( !$ip || !$port ) continue; if(isset($proxy[2]))< $proxy = $ip . ':' . $port. ':' . $type; >else < $proxy = $ip . ':' . $port; >$curlh[$proxy]= curl_init(); curl_setopt($curlh[$proxy],CURLOPT_TIMEOUT, 10); curl_setopt($curlh[$proxy], CURLOPT_URL, 'https://www.google.com'); curl_setopt($curlh[$proxy], CURLOPT_FOLLOWLOCATION, true); curl_setopt($curlh[$proxy], CURLOPT_RETURNTRANSFER, true); curl_setopt($curlh[$proxy], CURLOPT_NOBODY, true); curl_setopt($curlh[$proxy], CURLOPT_HEADER, true); curl_setopt($curlh[$proxy], CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36'); curl_setopt($curlh[$proxy], CURLOPT_PROXY, $ip . ":" . $port ); if(isset($type)) < if(stripos($type,"SOCKS5")!==false)< curl_setopt ($curlh[$proxy], CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); >if (stripos($type, "SOCKS4") !== false) < curl_setopt($curlh[$proxy], CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); >if (stripos($type, "HTTP") !== false) < curl_setopt($curlh[$proxy], CURLOPT_PROXYTYPE, CURLPROXY_HTTP); >> curl_setopt($curlh[$proxy], CURLOPT_HTTPPROXYTUNNEL, true); curl_multi_add_handle($mh, $curlh[$proxy]); > $running = null; do < curl_multi_exec($mh, $running); >while ($running); foreach ($curlh as $key => $value) < curl_multi_remove_handle($mh, $curlh[$key]); echo curl_error ($curlh[$key]) . "
"; > foreach ($curlh as $key => $value) < $response[$key] = curl_multi_getcontent($curlh[$key]); >foreach($response as $key=> $out) < if ( strpos($out, 'Forbidden') == true )< continue;>if ( strpos($out, '200 OK') == true ) < array_push($proxyList,$key);>> if ( count($proxyList) ) < unlink($file); if ($fp = fopen ($file, "w")) < for ($i=0;$i> echo ' '; print_r($proxyList); echo ''; $time = microtime(true) - $start; printf('Скрипт выполнялся %.4F сек.', $time);
Собственно, проблема заключается в хостинге. Что именно необходимо для использования SOCKS прокси? Какие технологии, библиотеки? Благодарю за внимание.
P.S. прокси использую исключительно для сбора и анализа информации, никаких DDOS, воровства данных и прочего.UPD SOCKS5 тоже не работает, соответственно возникает ошибка Failed to resolve «сайт» for SOCKS5 connect. HTTP прокси работают.
- Вопрос задан более трёх лет назад
- 1053 просмотра
12 комментариев
Оценить 12 комментариев
Как правильно делать запросы чреез сокеты и прокси к wss (websocket)?
Соединение с прокси устанавливается, а далее получаю «400 The plain HTTP request was sent to HTTPS port»
Понимаю что запрос идёт не кодированый и просто текстом, но как по другому?
Всё тоже самое пробовал на node js, там всё завелось сразу, но ОЧЕНЬ желательно на PHP
Готовых решений для работы с wss не много
- Вопрос задан более трёх лет назад
- 581 просмотр
Socks 4 bind in php example
I’d like to bind a socks 4 proxy server to connect an another proxy. This example the secound proxy is a http proxy. When connect the first is normally connected the server answer is Granted, but the communication at this time is finished. How continued the communication this example?
asked Nov 5, 2015 at 9:12
user3243893 user3243893
33 3 3 bronze badges
1 Answer 1
You are lucky that you get a ‘Granted’ reply — I do not get any reply from SOCKS server in OpenSSH, it just closes the connection.
As I understand the SOCKS4 description, the answer for type 2 (BIND) request contains a port number and an IP address; when a connection arrives to them, your program will be able to read next status packet, which tells about the connection. There is a limited time (seems 2 minutes) of waiting for the connection. This is mainly for an FTP client — an FTP server needs back connection to the client and the BIND allows the connection to be passed.
If you want to initiate a connection from your side, use type 1 (CONNECT) request. Also, make sure the port and the IP address in the request are correct — seems in your code they are 80 and 192.240.30.126.
Bablosoft
Эта тема была удалена. Только пользователи с правом управления темами могут её видеть.
написал в отредактировано Бывший пользователь
Привет всем. В басе нет socks4, только 5, как использовать 4? P.S не пишите использую http или socks5, нужен именно 4)
написал в отредактировано
@Pavlo14 http://wiki.bablosoft.com/doku.php?id=ru:how_to_set_proxy
ответил Fox в отредактировано
@fox Чо нет никакого выхода?)
написал в отредактировано Fox
@Pavlo14 В принципе можно подключить модуль для ноды для прокси socks4, и модуль для отправки запросов и работать так. Это всё очень не просто, а что для браузера, там совсем ни как.
