MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / switchToNextNodeLocked

Method switchToNextNodeLocked

internal/home/client.go:477–498  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

475}
476
477func (c *Client) switchToNextNodeLocked() (bool, string) {
478 currentHost := strings.TrimSpace(c.homeCfg.Host)
479 currentPort := c.homeCfg.Port
480 candidates := append([]clusterNode(nil), c.clusterNodes...)
481 if strings.TrimSpace(c.seedHost) != "" && c.seedPort > 0 {
482 candidates = append(candidates, clusterNode{IP: c.seedHost, Port: c.seedPort})
483 }
484 for _, node := range candidates {
485 host := strings.TrimSpace(node.IP)
486 if host == "" || node.Port <= 0 {
487 continue
488 }
489 if host == currentHost && node.Port == currentPort {
490 continue
491 }
492 if c.switchToNodeLocked(clusterNode{IP: host, Port: node.Port}) {
493 addr, _ := c.addrLocked()
494 return true, addr
495 }
496 }
497 return false, ""
498}
499
500func (c *Client) markSubscriptionTimeout() {
501 switched, addr := c.failoverAfterSubscriptionTimeout()

Calls 2

switchToNodeLockedMethod · 0.95
addrLockedMethod · 0.95

Tested by

no test coverage detected