Skip to content

Instantly share code, notes, and snippets.

@hdp
Created May 21, 2011 13:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdp/984522 to your computer and use it in GitHub Desktop.
Save hdp/984522 to your computer and use it in GitHub Desktop.
diff --git a/lib/Starman/Server.pm b/lib/Starman/Server.pm
index c98af6f..a927e0d 100644
--- a/lib/Starman/Server.pm
+++ b/lib/Starman/Server.pm
@@ -21,6 +21,29 @@ my $null_io = do { open my $io, "<", \""; $io };
use Net::Server::SIG qw(register_sig);
+sub SSL_key_file {
+ my ($self, $host, $port, $proto) = @_;
+ my $file = $self->{proto}{$host}{$port}{key};
+ warn "$host:$port key=$file\n";
+ return $file;
+}
+
+sub SSL_cert_file {
+ my ($self, $host, $port, $proto) = @_;
+ my $file = $self->{proto}{$host}{$port}{cert};
+ warn "$host:$port crt=$file\n";
+ return $file;
+}
+
+sub SSL_error_callback {
+ my ($self, @rest) = @_;
+ use Data::Dumper;
+ warn Dumper \@rest;
+ return sub { die Dumper [@_] };
+}
+
+sub SSL_max_getline_length { 4096 }
+
sub run {
my($self, $app, $options) = @_;
@@ -45,9 +68,21 @@ sub run {
for my $listen (@{$options->{listen} || [ "$options->{host}:$options->{port}" ]}) {
if ($listen =~ /:/) {
my($h, $p) = split /:/, $listen, 2;
- push @$host, $h || '*';
+ ($p, my $rest) = split m{/}, $p, 2;
+ $rest ||= 'tcp';
+ $h ||= '*';
+ ($rest, my @opts) = split /,/, $rest;
+ my %opt;
+ for (@opts) {
+ my ($k, $v) = split /=/, $_, 2;
+ $opt{$k} = $v;
+ }
+ warn "h=$h, p=$p, proto=$rest\n";
+ $self->{proto}{$h}{$p} = \%opt;
+ use Data::Dumper; warn Dumper \%opt if %opt;
+ push @$host, $h;
push @$port, $p;
- push @$proto, 'tcp';
+ push @$proto, $rest;
} else {
push @$host, 'localhost';
push @$port, $listen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment