mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Try to protect against crash from dereferencing a NULL in go-proxy
Follow up toff8f385
Similar toc834c76
This commit is contained in:
parent
c834c76fc5
commit
f2abf5b60c
1 changed files with 6 additions and 2 deletions
|
@ -71,7 +71,9 @@ func (c *webRTCConn) Read(b []byte) (int, error) {
|
|||
func (c *webRTCConn) Write(b []byte) (int, error) {
|
||||
// log.Printf("webrtc Write %d %+q", len(b), string(b))
|
||||
log.Printf("Write %d bytes --> WebRTC", len(b))
|
||||
c.dc.Send(b)
|
||||
if c.dc != nil {
|
||||
c.dc.Send(b)
|
||||
}
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
|
@ -254,12 +256,15 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
|
|||
|
||||
pr, pw := io.Pipe()
|
||||
|
||||
conn := &webRTCConn{pc: pc, dc: dc, pr: pr}
|
||||
|
||||
dc.OnOpen = func() {
|
||||
log.Println("OnOpen channel")
|
||||
}
|
||||
dc.OnClose = func() {
|
||||
log.Println("OnClose channel")
|
||||
pw.Close()
|
||||
conn.dc = nil
|
||||
pc.DeleteDataChannel(dc)
|
||||
}
|
||||
dc.OnMessage = func(msg []byte) {
|
||||
|
@ -273,7 +278,6 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
|
|||
}
|
||||
}
|
||||
|
||||
conn := &webRTCConn{pc: pc, dc: dc, pr: pr}
|
||||
go datachannelHandler(conn, conn.RemoteAddr())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue