AllowNatTraversal is properly set for stopped socket (#32603)
authorAlexander Nikolaev <55398552+alnikola@users.noreply.github.com>
Fri, 21 Feb 2020 18:44:22 +0000 (19:44 +0100)
committerGitHub <noreply@github.com>
Fri, 21 Feb 2020 18:44:22 +0000 (19:44 +0100)
commit7e398ff3a00081b5a238b282ba5e44ad42869bb7
tree8babf4d8a165f98ee64fb083e48fb488043ce8cb
parent857529d5eb5f58e70ad7ffda0676d9e866a67d81
AllowNatTraversal is properly set for stopped socket (#32603)

If AllowNatTraversal is called on a stopped TcpListener when ```_serverSocket``` is null, ```allow``` value gets stored in a field. Subsequently, if a new socket is created on Start call, the saved value is read and the corresponding argument is passed to SetIPProtectionLevel call after which the value is reset to preserve the current IPProtectionLevel propagation logic. The follow-up issue is #32653
Fixes #32551
src/libraries/System.Net.Sockets/src/System/Net/Sockets/TCPListener.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/TcpListenerTest.cs