mirror of
https://github.com/gnh1201/caterpillar.git
synced 2024-11-26 15:31:45 +00:00
Update worker.pl
This commit is contained in:
parent
e7137b0079
commit
1d665793bc
|
@ -1,5 +1,6 @@
|
|||
use JSON;
|
||||
use IO::Socket::INET;
|
||||
use IO::Socket::SSL;
|
||||
use Time::HiRes qw(time);
|
||||
|
||||
use constant DEFAULT_SOCKET_TIMEOUT => 1;
|
||||
|
@ -56,17 +57,23 @@ sub parse_headers {
|
|||
|
||||
sub read_from_remote_server {
|
||||
my ($remote_address, $remote_port, $scheme, $data, $conn, $buffer_size, $id) = @_;
|
||||
my $sock;
|
||||
if ($scheme ~~ ["https", "ssl", "tls"]) {
|
||||
$remote_address = "tls://" . $remote_address;
|
||||
$sock = IO::Socket::SSL->new(
|
||||
PeerAddr => $remote_address,
|
||||
PeerPort => $remote_port,
|
||||
SSL_verify_mode => 0, # You may adjust SSL options as needed
|
||||
Timeout => DEFAULT_SOCKET_TIMEOUT
|
||||
);
|
||||
} else {
|
||||
$sock = IO::Socket::INET->new(
|
||||
PeerAddr => $remote_address,
|
||||
PeerPort => $remote_port,
|
||||
Proto => 'tcp',
|
||||
Timeout => DEFAULT_SOCKET_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
my $sock = IO::Socket::INET->new(
|
||||
PeerAddr => $remote_address,
|
||||
PeerPort => $remote_port,
|
||||
Proto => 'tcp',
|
||||
Timeout => DEFAULT_SOCKET_TIMEOUT
|
||||
);
|
||||
|
||||
if (!$sock) {
|
||||
my $error = {
|
||||
status => 502,
|
||||
|
|
Loading…
Reference in New Issue
Block a user