Changeset 8679 for lang/perl/Punc

Show
Ignore:
Timestamp:
04/02/08 23:29:42 (8 months ago)
Author:
mizzy
Message:

lang/perl/Punc: puncmasterd 実装開始。自己署名証明書作成まで。

Location:
lang/perl/Punc/branches/ssl
Files:
5 added
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Punc/branches/ssl/bin/punc

    r8644 r8679  
    33use strict; 
    44use warnings; 
     5use FindBin; 
     6use File::Spec; 
     7use lib File::Spec->catdir("$FindBin::Bin/..", 'lib'); 
    58use Punc::Client; 
    69use JSON; 
  • lang/perl/Punc/branches/ssl/bin/puncd

    r8644 r8679  
    33use strict; 
    44use warnings; 
     5use FindBin; 
     6use File::Spec; 
     7use lib File::Spec->catdir("$FindBin::Bin/..", 'lib'); 
     8use Punc::Slave::Daemon; 
     9use Getopt::Long; 
    510 
    6 use Punc::Slave::Daemon; 
     11my $port = 7080; 
    712 
    8 Punc::Slave::Daemon->start_daemon; 
     13GetOptions( 
     14    '--port=s' => $port, 
     15); 
    916 
     17my $daemon = Punc::Slave::Daemon->new({ port => $port }); 
     18$daemon->run; 
     19 
     20 
     21 
  • lang/perl/Punc/branches/ssl/lib/Punc/Slave/Daemon.pm

    r8644 r8679  
    44use warnings; 
    55 
    6 use HTTP::Daemon; 
    7 use HTTP::Status; 
    8 use JSON; 
    9 use UNIVERSAL::require; 
     6use base qw( Punc::Daemon ); 
    107 
    11 sub start_daemon { 
    12     my $d = HTTP::Daemon->new( LocalPort => 7080, ReuseAddr => 1 ) || die; 
    13  
    14     print "Please contact me at: <URL:", $d->url, ">\n"; 
    15     while ( my $c = $d->accept ) { 
    16         while ( my $r = $c->get_request ) { 
    17             my $module = $r->url->path; 
    18             $module =~ s!^/!!; 
    19             my $content = JSON::from_json($r->content); 
    20             my $result  = dispatch_request($module, $content->{method}, $content->{params}); 
    21  
    22             my $json = to_json({ 
    23                 result => $result, 
    24                 error  => undef, 
    25             }); 
    26  
    27             my $response = HTTP::Response->new; 
    28             $response->content($json); 
    29             $c->send_response($response); 
    30         } 
    31         $c->close; 
    32         undef($c); 
    33     } 
    34 } 
    35  
    36 sub dispatch_request { 
    37     my ( $module, $method, $args ) = @_; 
     8sub handle_request { 
     9    my ( $self, $module, $method, $args ) = @_; 
    3810 
    3911    $module = ucfirst $module;