Created
December 24, 2014 05:33
-
-
Save kelseyhightower/545c71cc25a30deb4b7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cfg.lcurls, err = flags.URLsFromFlags(cfg.FlagSet, "listen-client-urls", "bind-addr", cfg.clientTLSInfo) | |
| if err != nil { | |
| return err | |
| } | |
| cfg.acurls, err = flags.URLsFromFlags(cfg.FlagSet, "advertise-client-urls", "addr", cfg.clientTLSInfo) | |
| if err != nil { | |
| return err | |
| } | |
| cfg.resolveUrls() | |
| return nil | |
| } | |
| func (cfg *config) resolveUrls() { | |
| for _, urls := range [][]url.URL{cfg.lpurls, cfg.apurls, cfg.lcurls, cfg.acurls} { | |
| rUrls := make([]url.URL, 0) | |
| for _, u := range urls { | |
| ip := net.ParseIP(u.Host) | |
| if ip != nil { | |
| rUrls = append(rUrls, u) | |
| continue | |
| } | |
| tcpAddr, err := net.ResolveTCPAddr("tcp", u.Host) | |
| if err != nil { | |
| log.Println("Couldn't resolve host" + u.Host) | |
| } | |
| log.Printf("etcd: Resolving DNS hostname %s to %s", u.Host, tcpAddr.String()) | |
| u.Host = tcpAddr.String() | |
| rUrls = append(rUrls, u) | |
| } | |
| urls = rUrls | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment