]> Cypherpunks repositories - gostls13.git/commit
net: fix panic when calling net.Listen or net.Dial on wasip1
authorAchille Roussel <achille.roussel@gmail.com>
Sat, 10 Jun 2023 18:31:43 +0000 (11:31 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 14 Jun 2023 01:36:27 +0000 (01:36 +0000)
commitc3db64c0f45e8f2d75c5b59401e0fc925701b6f4
tree766bc81e500dc892135bba53182834fd22968165
parent711ef8bc725037e95ad78ce61b8679fdd2657897
net: fix panic when calling net.Listen or net.Dial on wasip1

Address a panic that was caused by net.Dial/net.Listen entering the fake
network stack and assuming that the addresses would be of type *TCPAddr,
where in fact they could have been *UDPAddr or *UnixAddr as well.

The fix consist in implementing the fake network facility for udp and
unix addresses, preventing the assumed type assertion to TCPAddr from
triggering a panic. New tests are added to verify that using the fake
network from the exported functions of the net package satisfies the
minimal requirement of being able to create a listener and establish a
connection for all the supported network types.

Fixes #60012
Fixes #60739

Change-Id: I2688f1a0a7c6c9894ad3d137a5d311192c77a9b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/502315
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
src/net/net_fake.go
src/net/net_fake_test.go [new file with mode: 0644]