Merge pull request #614 from skrashevich/230905-fix-runtime-crash
Refactor LocalIP method to correctly handle non-TCP connections
This commit is contained in:
+9
-2
@@ -317,8 +317,15 @@ func (c *Client) GetImage(width, height int) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) LocalIP() string {
|
func (c *Client) LocalIP() string {
|
||||||
addr := c.Conn.LocalAddr().(*net.TCPAddr)
|
conn, ok := c.Conn.(*net.TCPConn)
|
||||||
return addr.IP.To4().String()
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
addr, ok := conn.LocalAddr().(*net.TCPAddr)
|
||||||
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return addr.IP.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecodeKey(s string) []byte {
|
func DecodeKey(s string) []byte {
|
||||||
|
|||||||
Reference in New Issue
Block a user