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

Comparing AnyEvent-MP/MP/Kernel.pm (file contents):
Revision 1.82 by root, Sat Mar 3 19:55:56 2012 UTC vs.
Revision 1.83 by root, Sat Mar 3 20:35:10 2012 UTC

137 (int $now * 10000) % 62, 137 (int $now * 10000) % 62,
138 ) . nonce62 4; 138 ) . nonce62 4;
139} 139}
140 140
141our $CONFIG; # this node's configuration 141our $CONFIG; # this node's configuration
142our $SECURE = sub { 1 };
142 143
143our $RUNIQ; # remote uniq value 144our $RUNIQ; # remote uniq value
144our $UNIQ; # per-process/node unique cookie 145our $UNIQ; # per-process/node unique cookie
145our $NODE; 146our $NODE;
146our $ID = "a"; 147our $ID = "a";
405} 406}
406 407
407sub _unmonitor { 408sub _unmonitor {
408 delete $LMON{$_[1]}{$_[2]+0} 409 delete $LMON{$_[1]}{$_[2]+0}
409 if exists $LMON{$_[1]}; 410 if exists $LMON{$_[1]};
411}
412
413sub _secure_check {
414 $SECURE->($SRCNODE->{id})
415 or die "remote execution attempt by insecure node\n";
410} 416}
411 417
412our %NODE_REQ = ( 418our %NODE_REQ = (
413 # internal services 419 # internal services
414 420
445 snd @$_ for @_ 451 snd @$_ for @_
446 }, 452 },
447 453
448 # random utilities 454 # random utilities
449 eval => sub { 455 eval => sub {
450 #d#SECURE 456 &_secure_check;
451 my @res = do { package main; eval shift }; 457 my @res = do { package main; eval shift };
452 snd @_, "$@", @res if @_; 458 snd @_, "$@", @res if @_;
453 }, 459 },
454 time => sub { 460 time => sub {
455 snd @_, AE::now; 461 snd @_, AE::now;
463); 469);
464 470
465$NODE{""} = $NODE{$NODE} = new AnyEvent::MP::Node::Self $NODE; 471$NODE{""} = $NODE{$NODE} = new AnyEvent::MP::Node::Self $NODE;
466$PORT{""} = sub { 472$PORT{""} = sub {
467 my $tag = shift; 473 my $tag = shift;
468 #d#SECURE (load_func)
469 eval { &{ $NODE_REQ{$tag} ||= load_func $tag } }; 474 eval { &{ $NODE_REQ{$tag} ||= do { &_secure_check; load_func $tag } } };
470 $WARN->(2, "error processing node message: $@") if $@; 475 $WARN->(2, "error processing node message from $SRCNODE->{id}: $@") if $@;
471}; 476};
472 477
473############################################################################# 478#############################################################################
474# seed management, try to keep connections to all seeds at all times 479# seed management, try to keep connections to all seeds at all times
475 480
868 $profile = nodename 873 $profile = nodename
869 unless defined $profile; 874 unless defined $profile;
870 875
871 $CONFIG = AnyEvent::MP::Config::find_profile $profile, %kv; 876 $CONFIG = AnyEvent::MP::Config::find_profile $profile, %kv;
872 877
878 if (exists $CONFIG->{secure}) {
879 my $pass = !$CONFIG->{secure};
880 $SECURE = sub { $pass };
881 }
882
873 my $node = exists $CONFIG->{nodeid} ? $CONFIG->{nodeid} : "$profile/"; 883 my $node = exists $CONFIG->{nodeid} ? $CONFIG->{nodeid} : "$profile/";
874 884
875 $node or Carp::croak "$node: illegal node ID (see AnyEvent::MP manpage for syntax)\n"; 885 $node or Carp::croak "$node: illegal node ID (see AnyEvent::MP manpage for syntax)\n";
876 886
877 $NODE = $node; 887 $NODE = $node;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines