mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-09-07 10:22:51 +00:00
Update worker.pl
This commit is contained in:
parent
e7137b0079
commit
1d665793bc
|
@ -1,5 +1,6 @@
|
||||||
use JSON;
|
use JSON;
|
||||||
use IO::Socket::INET;
|
use IO::Socket::INET;
|
||||||
|
use IO::Socket::SSL;
|
||||||
use Time::HiRes qw(time);
|
use Time::HiRes qw(time);
|
||||||
|
|
||||||
use constant DEFAULT_SOCKET_TIMEOUT => 1;
|
use constant DEFAULT_SOCKET_TIMEOUT => 1;
|
||||||
|
@ -56,17 +57,23 @@ sub parse_headers {
|
||||||
|
|
||||||
sub read_from_remote_server {
|
sub read_from_remote_server {
|
||||||
my ($remote_address, $remote_port, $scheme, $data, $conn, $buffer_size, $id) = @_;
|
my ($remote_address, $remote_port, $scheme, $data, $conn, $buffer_size, $id) = @_;
|
||||||
|
my $sock;
|
||||||
if ($scheme ~~ ["https", "ssl", "tls"]) {
|
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) {
|
if (!$sock) {
|
||||||
my $error = {
|
my $error = {
|
||||||
status => 502,
|
status => 502,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user