Perl: LWP - работаем с Socks'ами
Есть несколько вариантов работы LWP через Socks, вот некоторые из них.
- Задача: на сервере есть несколько внешних IP. Надо сделать запрос на сайт http://google.com через один из них, минуя основной
Решение:use LWP::UserAgent; my $ua = new LWP::UserAgent; my $req = HTTP::Request->new(GET => 'http://google.com'); @LWP::Protocol::http::EXTRA_SOCK_OPTS = (LocalAddr => IP-адрес, Reuse => 1 ); my $res = $ua->request($req); - Задача: есть внешний сокс, через который надо пустить запрос на сайт http://google.com
Решение: устанавливаем из cpan.org модуль LWP::Protocol::socksuse LWP::UserAgent; my $ua = new LWP::UserAgent; $ua->proxy([qw(http https)] => 'socks://IP-адрес:порт'); my $req = HTTP::Request->new(GET => 'http://google.com'); my $res = $ua->request($req);
- Задача: есть несколько внешних соксов, надо организовать запросы через цепочки
Решение: устанавливаем модуль LWP::Protocol::http::SocksChain (для протокола https надо будет установить LWP::Protocol::https::SocksChain)use LWP::UserAgent; use LWP::Protocol::http::SocksChain; my $ua = new LWP::UserAgent; my $req = HTTP::Request->new(GET => 'http://google.com'); LWP::Protocol::implementor(http => 'LWP::Protocol::http::SocksChain' );
@LWP::Protocol::http::SocksChain::EXTRA_SOCK_OPTS = (
Chain_Len => 1,
Debug => 0,
Random_Chain => 1,
Chain_File_Data => [
'IP-адрес:порт',
'IP-адрес:порт',
'IP-адрес:порт'
],
Auto_Save => 0,
Restore_Type => 1
); my $res = $ua->request($req);
Похожие материалы:
Комментарии:
22 Августа 2026 (08:26:40)
Somik33
(гость)
• ответить
Hello, recommended me please game casino?
My experience with PlayCroco CasinoPiggyBet Online was generally very good. The website has a fresh and modern appearance, while the navigation remains simple and intuitive. I could easily move between different sections without feeling confused, and the pages loaded smoothly on my phone. The content is presented clearly, and the overall structure feels practical for regular users. I appreciate platforms that focus on convenience and usability, and this one leaves a positive first impression. Overall, a comfortable and straightforward website to explore.