conn: change OutboundIP to return string

This commit is contained in:
nadoo 2018-01-13 14:34:49 +08:00
parent 950ed2b426
commit 21935fc6b9
2 changed files with 5 additions and 7 deletions

10
conn.go
View File

@ -3,7 +3,6 @@ package main
import (
"bufio"
"io"
"log"
"net"
"time"
)
@ -82,14 +81,13 @@ func timedCopy(dst net.PacketConn, target net.Addr, src net.PacketConn, timeout
}
// OutboundIP returns preferred outbound ip of this machine
func OutboundIP() net.IP {
func OutboundIP() string {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
log.Fatal(err)
logf("get outbound ip error: %s", err)
return ""
}
defer conn.Close()
localAddr := conn.LocalAddr().(*net.UDPAddr)
return localAddr.IP
return conn.LocalAddr().(*net.UDPAddr).IP.String()
}

View File

@ -37,7 +37,7 @@ func NewHTTP(addr, user, pass, rawQuery string, cDialer Dialer, sDialer Dialer)
user: user,
password: pass,
xff: false,
selfip: OutboundIP().String(),
selfip: OutboundIP(),
}
p, _ := url.ParseQuery(rawQuery)