… | |
… | |
112 | |
112 | |
113 | if (open my $fh, "</dev/urandom") { |
113 | if (open my $fh, "</dev/urandom") { |
114 | sysread $fh, $nonce, $_[0]; |
114 | sysread $fh, $nonce, $_[0]; |
115 | } else { |
115 | } else { |
116 | # shit... |
116 | # shit... |
117 | our $nonce_init; |
|
|
118 | unless ($nonce_init++) { |
|
|
119 | srand time ^ $$ ^ unpack "%L*", qx"ps -edalf" . qx"ipconfig /all"; |
|
|
120 | } |
|
|
121 | $nonce = join "", map +(chr rand 256), 1 .. $_[0] |
117 | $nonce = join "", map +(chr rand 256), 1 .. $_[0] |
122 | } |
118 | } |
123 | |
119 | |
124 | $nonce |
120 | $nonce |
125 | } |
121 | } |
… | |
… | |
325 | |
321 | |
326 | require Net::Interface; |
322 | require Net::Interface; |
327 | |
323 | |
328 | for my $if (Net::Interface->interfaces) { |
324 | for my $if (Net::Interface->interfaces) { |
329 | # we statically lower-prioritise ipv6 here, TODO :() |
325 | # we statically lower-prioritise ipv6 here, TODO :() |
330 | for my $_ ($if->address (Net::Interface::AF_INET ())) { |
326 | for $_ ($if->address (Net::Interface::AF_INET ())) { |
331 | next if /^\x7f/; # skip localhost etc. |
327 | next if /^\x7f/; # skip localhost etc. |
332 | push @addr, $_; |
328 | push @addr, $_; |
333 | } |
329 | } |
334 | for ($if->address (Net::Interface::AF_INET6 ())) { |
330 | for ($if->address (Net::Interface::AF_INET6 ())) { |
335 | #next if $if->scope ($_) <= 2; |
331 | #next if $if->scope ($_) <= 2; |
… | |
… | |
378 | $profile = _nodename |
374 | $profile = _nodename |
379 | unless defined $profile; |
375 | unless defined $profile; |
380 | |
376 | |
381 | $CONFIG = AnyEvent::MP::Config::find_profile $profile, %kv; |
377 | $CONFIG = AnyEvent::MP::Config::find_profile $profile, %kv; |
382 | |
378 | |
|
|
379 | delete $NODE{$NODE}; # we do not support doing stuff before configure |
|
|
380 | |
383 | my $node = exists $CONFIG->{nodeid} ? $CONFIG->{nodeid} : $profile; |
381 | my $node = exists $CONFIG->{nodeid} ? $CONFIG->{nodeid} : $profile; |
384 | $NODE = $node |
382 | $NODE = $node |
385 | unless $node eq "anon/"; |
383 | unless $node eq "anon/"; |
386 | |
384 | |
387 | $NODE{$NODE} = $NODE{""}; |
385 | $NODE{$NODE} = $NODE{""}; |