コード例 #1
0
func (t *relayListener) WANAddresses() []*url.URL {
	t.mut.RLock()
	client := t.client
	t.mut.RUnlock()

	if client == nil {
		return nil
	}

	curi := client.URI()
	if curi == nil {
		return nil
	}

	return []*url.URL{curi}
}
コード例 #2
0
ファイル: relay.go プロジェクト: KetanSingh11/syncthing
// RelayStatus returns the latency and OK status for a given relay.
func (s *Svc) RelayStatus(uri string) (time.Duration, bool) {
	if s == nil {
		// A nil client does not have a status, really. Yet we may be called
		// this way, for raisins...
		return time.Hour, false
	}

	s.mut.RLock()
	defer s.mut.RUnlock()

	for _, client := range s.clients {
		if client.URI().String() == uri {
			return client.Latency(), client.StatusOK()
		}
	}

	return time.Hour, false
}
コード例 #3
0
ファイル: relay.go プロジェクト: KetanSingh11/syncthing
// Relays return the list of relays that currently have an OK status.
func (s *Svc) Relays() []string {
	if s == nil {
		// A nil client does not have a status, really. Yet we may be called
		// this way, for raisins...
		return nil
	}

	s.mut.RLock()
	relays := make([]string, 0, len(s.clients))
	for _, client := range s.clients {
		relays = append(relays, client.URI().String())
	}
	s.mut.RUnlock()

	sort.Strings(relays)

	return relays
}