isLocalhostMode returns true if listen is only listening for the local host.
(c *config.Config)
| 492 | |
| 493 | // isLocalhostMode returns true if listen is only listening for the local host. |
| 494 | func isLocalhostMode(c *config.Config) bool { |
| 495 | if c.SetupRouter { |
| 496 | // The listen arg is irrelevant when in router mode. |
| 497 | return false |
| 498 | } |
| 499 | for _, listen := range c.Listens { |
| 500 | if host, _, err := net.SplitHostPort(listen); err == nil { |
| 501 | switch host { |
| 502 | case "localhost", "127.0.0.1", "::1": |
| 503 | continue |
| 504 | } |
| 505 | if ips := hosts.LookupHost(host); len(ips) > 0 { |
| 506 | for _, ip := range ips { |
| 507 | if !net.ParseIP(ip).IsLoopback() { |
| 508 | return false |
| 509 | } |
| 510 | } |
| 511 | } else if !net.ParseIP(host).IsLoopback() { |
| 512 | return false |
| 513 | } |
| 514 | } |
| 515 | } |
| 516 | return true |
| 517 | } |
| 518 | |
| 519 | func maybeUseResolvedCompatListen(c *config.Config, log host.Logger) { |
| 520 | if runtime.GOOS != "linux" || c.SetupRouter || !resolved.Available() { |
searching dependent graphs…