Skip to content

Commit

Permalink
Prevent nil LocalAddr or RemoteAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Dec 5, 2023
1 parent 50f5a76 commit 0ef2686
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion transport/v2raygrpclite/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (c *GunConn) LocalAddr() net.Addr {
}

func (c *GunConn) RemoteAddr() net.Addr {
return nil
return M.Socksaddr{}
}

func (c *GunConn) SetDeadline(t time.Time) error {
Expand Down
5 changes: 3 additions & 2 deletions transport/v2raywebsocket/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/sagernet/sing/common/buf"
"github.com/sagernet/sing/common/debug"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
"github.com/sagernet/ws"
"github.com/sagernet/ws/wsutil"
)
Expand Down Expand Up @@ -232,14 +233,14 @@ func (c *EarlyWebsocketConn) Close() error {

func (c *EarlyWebsocketConn) LocalAddr() net.Addr {
if c.conn == nil {
return nil
return M.Socksaddr{}
}
return c.conn.LocalAddr()
}

func (c *EarlyWebsocketConn) RemoteAddr() net.Addr {
if c.conn == nil {
return nil
return M.Socksaddr{}
}
return c.conn.RemoteAddr()
}
Expand Down

0 comments on commit 0ef2686

Please sign in to comment.