Results are written into a database. Now my question is if there's a way to find out what local port was used for the connection. I don't need to set the port, but would like to know afterwards what port was chosen.my $ua = LWP::UserAgent->new(ssl_opts => { SSL_verify_mode => 'SSL_VER +IFY_NONE'},); $ua->timeout(45); ... my $request = HTTP::Request->new(GET => $trg); $request->protocol('HTTP/1.0'); $request->header('Accept' => '*/*'); $request->header('Connection' => 'Close'); ... my $resp = $ua->request($request); ...
Background: I need some way to link connections the crawler makes in a unique way with data that a sniffer collects at the same time (which implements suricata rules and a passive SSL collector). As the crawler makes about 20 queries per second, the timestamp alone is not sufficient. As SSL connections are also used, I can't use the URL (because the sniffer doesn't see them). The destination IP would be an alternative, but might not be unique (the crawler migth access the same IP one after another for different URLs). So the local port number would be a good option, together with the timestamp of course. But for this to work, I must be able to figure out the port number the crawler uses (plus prevent shared connections, hence the Connection: close header). I could also try to set the local port in advance (I did read a posting that shows a way to do it), but that can cause errors (double used ports).
One way would be if I could somehow access the socket that LWP used/will use. Any suggestions are highly welcome :-)
Thanks, Andy
In reply to LWP: How to find out local port number? by klaymen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |