Skip to content

Instantly share code, notes, and snippets.

Created April 30, 2012 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2556372 to your computer and use it in GitHub Desktop.
Save anonymous/2556372 to your computer and use it in GitHub Desktop.
diff -ru perl/lib/perl5/Twiggy/Server/SS.pm Twiggy/lib/Twiggy/Server/SS.pm
--- perl/lib/perl5/Twiggy/Server/SS.pm 2012-04-30 08:24:53.554001546 +0300
+++ Twiggy/lib/Twiggy/Server/SS.pm 2012-04-30 07:49:43.440260764 +0300
@@ -18,9 +18,9 @@
my @listen;
my $ports = server_ports();
- while (my ($listen, $fd) = each %$ports ) {
- push @listen, $listen;
- $self->_create_ss_tcp_server($listen, $fd, $app);
+ while (my ($hostport, $fd) = each %$ports ) {
+ push @listen, $hostport;
+ $self->_create_ss_tcp_server($hostport, $fd, $app);
}
# overwrite, just in case somebody wants to refer to it afterwards
@@ -28,17 +28,17 @@
}
sub _create_ss_tcp_server {
- my ($self, $listen, $fd, $app) = @_;
+ my ($self, $hostport, $fd, $app) = @_;
- my($host, $port, $is_tcp);
- if ($listen =~ /:\d+$/) {
- ($host, $port) = split /:/, $listen;
- $host = undef if $host eq '';
- $port = undef if $port == 0;
- $is_tcp = 1;
+ my $is_tcp = 1; # currently no unix socket support
+
+ my ($host, $port);
+ if ($hostport =~ /(.*):(\d+)/) {
+ $host = $1;
+ $port = $2;
} else {
- $host = "unix/";
- $port = $listen;
+ $host ||= '0.0.0.0';
+ $port = $hostport;
}
# /WE/ don't care what the address family, type of socket we got, just
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment