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.13 by root, Mon Aug 3 22:05:55 2009 UTC vs.
Revision 1.18 by root, Tue Aug 4 18:33:30 2009 UTC

280 280
281sub error { 281sub error {
282 my ($self, $msg) = @_; 282 my ($self, $msg) = @_;
283 283
284 if ($self->{node} && $self->{node}{transport} == $self) { 284 if ($self->{node} && $self->{node}{transport} == $self) {
285 $self->{node}->fail (transport_error => $msg);
285 $self->{node}->clr_transport; 286 $self->{node}->clr_transport;
286 } 287 }
287 $AnyEvent::MP::Base::WARN->("$self->{peerhost}:$self->{peerport}: $msg"); 288 $AnyEvent::MP::Base::WARN->("$self->{peerhost}:$self->{peerport}: $msg");
288 $self->destroy; 289 $self->destroy;
289} 290}
326The greeting consists of two text lines that are ended by either an ASCII 327The greeting consists of two text lines that are ended by either an ASCII
327CR LF pair, or a single ASCII LF (recommended). 328CR LF pair, or a single ASCII LF (recommended).
328 329
329=head2 GREETING 330=head2 GREETING
330 331
332All the lines until after authentication must not exceed 4kb in length,
333including delimiter. Afterwards there is no limit on the packet size that
334can be received.
335
336=head3 First Greeting Line
337
338Example:
339
340 aemp;0;fec.4a7720fc;127.0.0.1:1235,[::1]:1235;hmac_md6_64_256;json,storable;provider=AE-0.0
341
331The first line contains strings separated (not ended) by C<;> 342The first line contains strings separated (not ended) by C<;>
332characters. The first even ixtrings are fixed by the protocol, the 343characters. The first even ixtrings are fixed by the protocol, the
333remaining strings are C<KEY=VALUE> pairs. None of them may contain C<;> 344remaining strings are C<KEY=VALUE> pairs. None of them may contain C<;>
334characters themselves. 345characters themselves.
335 346
336All the lines until after authentication must not exceed 4kb in length, including delimiter.
337
338The fixed strings are: 347The fixed strings are:
339 348
340=over 4 349=over 4
341 350
342=item C<aemp> 351=item protocol identification
343 352
344The constant C<aemp> to identify the protocol. 353The constant C<aemp> to identify the protocol.
345 354
346=item protocol version 355=item protocol version
347 356
348The protocol version supported by this end, currently C<0>. If the 357The protocol version supported by this end, currently C<0>. If the
349versions don't match then no communication is possible. Minor extensions 358versions don't match then no communication is possible. Minor extensions
350are supposed to be handled by addign additional key-value pairs. 359are supposed to be handled through additional key-value pairs.
351 360
352=item a token uniquely identifying the current node instance 361=item a token uniquely identifying the current node instance
353 362
354This is a string that must change between restarts. It usually contains 363This is a string that must change between restarts. It usually contains
355things like the current time, the (OS) process id or similar values, but 364things like the current time, the (OS) process id or similar values, but
396 405
397Indicates that the other side supports TLS (version should be 1.0) and 406Indicates that the other side supports TLS (version should be 1.0) and
398wishes to do a TLS handshake. 407wishes to do a TLS handshake.
399 408
400=back 409=back
410
411=head3 Second Greeting Line
401 412
402After this greeting line there will be a second line containing a 413After this greeting line there will be a second line containing a
403cryptographic nonce, i.e. random data of high quality. To keep the 414cryptographic nonce, i.e. random data of high quality. To keep the
404protocol text-only, these are usually 32 base64-encoded octets, but 415protocol text-only, these are usually 32 base64-encoded octets, but
405it could be anything that doesn't contain any ASCII CR or ASCII LF 416it could be anything that doesn't contain any ASCII CR or ASCII LF
406characters. 417characters.
407 418
408Example of the two lines of greeting: 419I<< The two nonces B<must> be different, and an aemp implementation
420B<must> check and fail when they are identical >>.
409 421
410 aemp;0;fec.4a7720fc;127.0.0.1:1235,[::1]:1235;hmac_md6_64_256;json,storable;provider=AE-0.0 422Example of a nonce line:
423
411 p/I122ql7kJR8lumW3lXlXCeBnyDAvz8NQo3x5IFowE4 424 p/I122ql7kJR8lumW3lXlXCeBnyDAvz8NQo3x5IFowE4
412 425
413=head2 TLS handshake 426=head2 TLS handshake
414 427
415If, after the handshake, both sides indicate interest in TLS, then the 428I<< If, after the handshake, both sides indicate interest in TLS, then the
416connection I<must> use TLS, or fail. 429connection B<must> use TLS, or fail.>>
417 430
418Both sides compare their nonces, and the side who sent the lower nonce 431Both sides compare their nonces, and the side who sent the lower nonce
419value ("string" comparison on the raw octet values) becomes the client, 432value ("string" comparison on the raw octet values) becomes the client,
420and the one with the higher nonce the server. 433and the one with the higher nonce the server.
421 434
480This must be one of the framing protocols offered by the other side in the 493This must be one of the framing protocols offered by the other side in the
481greeting. Each side must accept the choice of the other side. 494greeting. Each side must accept the choice of the other side.
482 495
483=back 496=back
484 497
485Example: 498Example of an authentication reply:
486 499
487 hmac_md6_64_256;363d5175df38bd9eaddd3f6ca18aa1c0c4aa22f0da245ac638d048398c26b8d3;json 500 hmac_md6_64_256;363d5175df38bd9eaddd3f6ca18aa1c0c4aa22f0da245ac638d048398c26b8d3;json
488 501
489=head2 DATA PHASE 502=head2 DATA PHASE
490 503
491After this, packets get exchanged using the chosen framing protocol. It is 504After this, packets get exchanged using the chosen framing protocol. It is
492quite possible that both sides use a different framing protocol. 505quite possible that both sides use a different framing protocol.
493 506
507=head2 FULL EXAMPLE
508
509This is an actual protocol dump of a handshake, followed by a single data
510packet. The greater than/less than lines indicate the direction of the
511transfer only.
512
513 > aemp;0;nndKd+gn;10.0.0.1:4040;hmac_md6_64_256,cleartext;json,storable;provider=AE-0.0;peeraddr=127.0.0.1:1235
514 > sRG8bbc4TDbkpvH8FTP4HBs87OhepH6VuApoZqXXskuG
515 < aemp;0;nmpKd+gh;127.0.0.1:1235,[::1]:1235;hmac_md6_64_256,cleartext;json,storable;provider=AE-0.0;peeraddr=127.0.0.1:58760
516 < dCEUcL/LJVSTJcx8byEsOzrwhzJYOq+L3YcopA5T6EAo
517 > hmac_md6_64_256;9513d4b258975accfcb2ab7532b83690e9c119a502c612203332a591c7237788;json
518 < hmac_md6_64_256;0298d6ba2240faabb2b2e881cf86b97d70a113ca74a87dc006f9f1e9d3010f90;json
519 > ["","lookup","pinger","10.0.0.1:4040#nndKd+gn.a","resolved"]
520
494=head1 SEE ALSO 521=head1 SEE ALSO
495 522
496L<AnyEvent>. 523L<AnyEvent>.
497 524
498=head1 AUTHOR 525=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines