ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Transport.pm
(Generate patch)

Comparing AnyEvent-MP/MP/Transport.pm (file contents):
Revision 1.8 by root, Mon Aug 3 14:58:13 2009 UTC vs.
Revision 1.10 by root, Mon Aug 3 15:02:42 2009 UTC

43Creates a listener on the given host/port using 43Creates a listener on the given host/port using
44C<AnyEvent::Socket::tcp_server>. 44C<AnyEvent::Socket::tcp_server>.
45 45
46See C<new>, below, for constructor arguments. 46See C<new>, below, for constructor arguments.
47 47
48Defaults for peerhost, peerport, fh and tls are provided. 48Defaults for peerhost, peerport and fh are provided.
49 49
50=cut 50=cut
51 51
52sub mp_server($$@) { 52sub mp_server($$@) {
53 my $cb = pop; 53 my $cb = pop;
58 58
59 $cb->(new AnyEvent::MP::Transport 59 $cb->(new AnyEvent::MP::Transport
60 fh => $fh, 60 fh => $fh,
61 peerhost => $host, 61 peerhost => $host,
62 peerport => $port, 62 peerport => $port,
63 tls => "accept",
64 @args, 63 @args,
65 ); 64 );
66 } 65 }
67} 66}
68 67
82 $cb->(new AnyEvent::MP::Transport 81 $cb->(new AnyEvent::MP::Transport
83 fh => $fh, 82 fh => $fh,
84 peername => $host, 83 peername => $host,
85 peerhost => $nhost, 84 peerhost => $nhost,
86 peerport => $nport, 85 peerport => $nport,
87 tls => "accept",
88 @args, 86 @args,
89 ); 87 );
90 } 88 }
91} 89}
92 90
105 on_eof => sub { clean-close-callback }, 103 on_eof => sub { clean-close-callback },
106 on_connect => sub { successful-connect-callback }, 104 on_connect => sub { successful-connect-callback },
107 greeting => { key => value }, 105 greeting => { key => value },
108 106
109 # tls support 107 # tls support
110 tls => "accept|connect",
111 tls_ctx => AnyEvent::TLS, 108 tls_ctx => AnyEvent::TLS,
112 peername => $peername, # for verification 109 peername => $peername, # for verification
113 ; 110 ;
114 111
115=cut 112=cut
129 $self->{queue} = []; 126 $self->{queue} = [];
130 127
131 { 128 {
132 Scalar::Util::weaken (my $self = $self); 129 Scalar::Util::weaken (my $self = $self);
133 130
134 if (exists $arg{connect}) {
135 $arg{tls_ctx} ||= { sslv2 => 0, sslv3 => 0, tlsv1 => 1, verify => 1 }; 131 #$arg{tls_ctx} ||= { sslv2 => 0, sslv3 => 0, tlsv1 => 1, verify => 1 };
136 }
137 132
138 $arg{secret} = AnyEvent::MP::Base::default_secret () 133 $arg{secret} = AnyEvent::MP::Base::default_secret ()
139 unless exists $arg{secret}; 134 unless exists $arg{secret};
140 135
141 $self->{hdl} = new AnyEvent::Handle 136 $self->{hdl} = new AnyEvent::Handle
213 208
214 # read nonce 209 # read nonce
215 $self->{hdl}->push_read (line => sub { 210 $self->{hdl}->push_read (line => sub {
216 my $rgreeting2 = $_[1]; 211 my $rgreeting2 = $_[1];
217 212
218 if ($self->{tls_ctx} and 1 == int $self->{remote_greeting}{"tls"}) { 213 if ($self->{tls_ctx} and 1 == int $self->{remote_greeting}{tls}) {
219 $self->{tls} = $lgreeting2 lt $rgreeting2 ? "connect" : "accept"; 214 $self->{tls} = $lgreeting2 lt $rgreeting2 ? "connect" : "accept";
220 $self->{hdl}->starttls ($self->{tls}, $self->{tls_ctx}); 215 $self->{hdl}->starttls ($self->{tls}, $self->{tls_ctx});
221 } 216 }
222 217
223 # auth 218 # auth
366 361
367A comma-separated list of packet encoding/framign formats understood. The 362A comma-separated list of packet encoding/framign formats understood. The
368receiving side should choose the first framing format it supports for 363receiving side should choose the first framing format it supports for
369sending packets (which might be different from the format it has to accept). 364sending packets (which might be different from the format it has to accept).
370 365
371=cut 366=back
372 367
373The remaining arguments are C<KEY=VALUE> pairs. The following key-value 368The remaining arguments are C<KEY=VALUE> pairs. The following key-value
374pairs are known at this time: 369pairs are known at this time:
375 370
376=over 4 371=over 4
436This must be one of the framing protocols offered by the other side in the 431This must be one of the framing protocols offered by the other side in the
437greeting. Each side must accept the choice of the other side. 432greeting. Each side must accept the choice of the other side.
438 433
439=back 434=back
440 435
436Example (the actual reply matching the previous example):
437
438 hmac_md6_64_256;wIlLedBY956UCGSISG9mBZRDTG8xUi73/sVse2DSQp0;json
439
441=head2 DATA PHASE 440=head2 DATA PHASE
442 441
443After this, packets get exchanged using the chosen framing protocol. It is 442After this, packets get exchanged using the chosen framing protocol. It is
444quite possible that both sides use a different framing protocol. 443quite possible that both sides use a different framing protocol.
445 444

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines