瀏覽代碼

improve control connection isLocal detection

Chris Bannister 10 年之前
父節點
當前提交
ee0107f587
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      control.go

+ 6 - 1
control.go

@@ -291,7 +291,12 @@ func (c *controlConn) query(statement string, values ...interface{}) (iter *Iter
 func (c *controlConn) fetchHostInfo(addr net.IP, port int) (*HostInfo, error) {
 	// TODO(zariel): we should probably move this into host_source or atleast
 	// share code with it.
-	isLocal := c.addr() == addr.String()
+	hostname, _, err := net.SplitHostPort(c.addr())
+	if err != nil {
+		return nil, fmt.Errorf("unable to fetch host info, invalid conn addr: %q: %v", c.addr(), err)
+	}
+
+	isLocal := hostname == addr.String()
 
 	var fn func(*HostInfo) error