… | |
… | |
152 | |
152 | |
153 | our %RMON; # local ports monitored by remote nodes ($RMON{nodeid}{portid} == cb) |
153 | our %RMON; # local ports monitored by remote nodes ($RMON{nodeid}{portid} == cb) |
154 | our %LMON; # monitored _local_ ports |
154 | our %LMON; # monitored _local_ ports |
155 | |
155 | |
156 | our $GLOBAL; # true if node is a global ("directory") node |
156 | our $GLOBAL; # true if node is a global ("directory") node |
157 | our %LISTENER; |
157 | our %BINDS; |
158 | our $LISTENER; # our listeners, as arrayref |
158 | our $BINDS; # our listeners, as arrayref |
159 | |
159 | |
160 | our $SRCNODE; # holds the sending node _object_ during _inject |
160 | our $SRCNODE; # holds the sending node _object_ during _inject |
161 | |
161 | |
162 | sub _init_names { |
162 | sub _init_names { |
163 | # ~54 bits, for local port names, lowercase $ID appended |
163 | # ~54 bits, for local port names, lowercase $ID appended |
… | |
… | |
917 | |
917 | |
918 | $binds ||= ["*"]; |
918 | $binds ||= ["*"]; |
919 | |
919 | |
920 | $WARN->(8, "node $NODE starting up."); |
920 | $WARN->(8, "node $NODE starting up."); |
921 | |
921 | |
922 | $LISTENER = []; |
922 | $BINDS = []; |
923 | %LISTENER = (); |
923 | %BINDS = (); |
924 | |
924 | |
925 | for (map _resolve $_, @$binds) { |
925 | for (map _resolve $_, @$binds) { |
926 | for my $bind ($_->recv) { |
926 | for my $bind ($_->recv) { |
927 | my ($host, $port) = AnyEvent::Socket::parse_hostport $bind |
927 | my ($host, $port) = AnyEvent::Socket::parse_hostport $bind |
928 | or Carp::croak "$bind: unparsable local bind address"; |
928 | or Carp::croak "$bind: unparsable local bind address"; |
… | |
… | |
934 | my (undef, $host, $port) = @_; |
934 | my (undef, $host, $port) = @_; |
935 | $bind = AnyEvent::Socket::format_hostport $host, $port; |
935 | $bind = AnyEvent::Socket::format_hostport $host, $port; |
936 | 0 |
936 | 0 |
937 | }, |
937 | }, |
938 | ; |
938 | ; |
939 | $LISTENER{$bind} = $listener; |
939 | $BINDS{$bind} = $listener; |
940 | push @$LISTENER, $bind; |
940 | push @$BINDS, $bind; |
941 | } |
941 | } |
942 | } |
942 | } |
943 | |
943 | |
944 | db_set "'l" => $NODE => $LISTENER; |
944 | db_set "'l" => $NODE => $BINDS; |
945 | |
945 | |
946 | $WARN->(8, "node listens on [@$LISTENER]."); |
946 | $WARN->(8, "node listens on [@$BINDS]."); |
947 | |
947 | |
948 | # connect to all seednodes |
948 | # connect to all seednodes |
949 | set_seeds map $_->recv, map _resolve $_, @$seeds; |
949 | set_seeds map $_->recv, map _resolve $_, @$seeds; |
950 | |
950 | |
951 | master_search; |
951 | master_search; |