Skip to content

Commit

Permalink
fix ip compare
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Sturm committed Mar 9, 2016
1 parent 5b6e972 commit d7a47a5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gelf/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ func NewWriter(addr string) (*Writer, error) {

func (w *Writer) periodicDnsRefresh() {
go func() {
serverHost := strings.Split(w.server, ":")[0]
serverHostname := strings.Split(w.server, ":")[0]
for {
if w.DnsRefresh > 0 {
time.Sleep(time.Duration(w.DnsRefresh) * time.Second)
needReconnect := true
if serverIps, err := net.LookupHost(serverHost); err == nil {
for _, ip := range serverIps {
if ip == w.conn.RemoteAddr().String() {
serverIp := strings.Split(w.conn.RemoteAddr().String(), ":")[0]
if serverIps, err := net.LookupHost(serverHostname); err == nil {
for _, lookupIp := range serverIps {
if lookupIp == serverIp {
needReconnect = false
}
}
Expand Down

0 comments on commit d7a47a5

Please sign in to comment.