go-libp2p-autonat
                                
                                 go-libp2p-autonat copied to clipboard
                                
                                    go-libp2p-autonat copied to clipboard
                            
                            
                            
                        EventBus `EvtLocalReachabilityChanged` emits conflicting measurements
Hi all,
We have a background worker that taps onto the events from the autonat service and propagates them to the necessary components, like so:
func (s *Service) reachabilityWorker() error {
	sub, err := s.host.EventBus().Subscribe([]interface{}{new(event.EvtLocalReachabilityChanged)})
	if err != nil {
		return fmt.Errorf("failed subscribing to reachability event %w", err)
	}
	go func() {
		defer sub.Close()
		for {
			select {
			case <-s.ctx.Done():
				return
			case e := <-sub.Out():
				if r, ok := e.(event.EvtLocalReachabilityChanged); ok {
					select {
					case <-s.ready:
					case <-s.halt:
						return
					}
					s.logger.Debugf("reachability changed to %s", r.Reachability.String())
					s.notifier.UpdateReachability(p2p.ReachabilityStatus(r.Reachability))
				}
			}
		}
	}()
	return nil
}
Now, looking at the measurements on a local node (which was behind NAT) I managed to see multiple events constantly being emitted, even after the initial status was emitted. So the node pivots between Private and Public intermittently.
Having looked at the issues in this repo (and from our experience within the team) I know that this issue is not trivial to assume, but in the meanwhile, I'd like to ask if we can rely on this data somehow, and if we could apply some sort of a heuristic on top of this, so that the measurement becomes more credible (assuming we are only dealing with public CIDRs).
Many thanks in advance!
Do you have any idea where the Public measurement is coming from? Is there any address that the node is dialable at?
No clue whatsoever @marten-seemann. Would you have an idea on how to actually check that? would I have to check the bind addresses for libp2p then try to telnet from another host?