mirror of
https://github.com/ValveSoftware/GameNetworkingSockets.git
synced 2026-05-29 16:20:34 +00:00
Setup loopback aliases for p2p tests properly
This commit is contained in:
@@ -74,6 +74,8 @@ jobs:
|
||||
run: |
|
||||
sudo -E bash .github/install.sh
|
||||
sudo -E bash .github/install-post.sh
|
||||
- name: Setup mock IPs
|
||||
run: sudo python3 tests/test_p2p.py --setup-mock-ips
|
||||
- name: Build and test (RelWithDebInfo)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -186,6 +188,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
|
||||
- name: Setup mock IPs
|
||||
run: py -3 tests/test_p2p.py --setup-mock-ips
|
||||
shell: cmd
|
||||
|
||||
# Mark all directories as safe so checkouts performed in CMakeLists.txt don't cause "unsafe repository" errors.
|
||||
# See https://github.com/actions/checkout/issues/766
|
||||
- name: Configure Git
|
||||
|
||||
@@ -14,6 +14,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup mock IPs
|
||||
run: sudo python3 tests/test_p2p.py --setup-mock-ips
|
||||
shell: bash
|
||||
|
||||
- name: Ensure vcpkg cache directories exist
|
||||
run: |
|
||||
mkdir -p "${VCPKG_DOWNLOADS}"
|
||||
@@ -61,21 +65,11 @@ jobs:
|
||||
run: ./test_connection suite-quick
|
||||
shell: bash
|
||||
|
||||
- name: Setup mock IPs
|
||||
working-directory: ${{github.workspace}}/build/bin
|
||||
run: sudo python3 test_p2p.py --setup-mock-ips
|
||||
shell: bash
|
||||
|
||||
- name: Test p2p
|
||||
working-directory: ${{github.workspace}}/build/bin
|
||||
run: python3 test_p2p.py --spewlevel=debug --loglevel-p2prendezvous=debug
|
||||
shell: bash
|
||||
|
||||
- name: Cleanup mock IPs
|
||||
working-directory: ${{github.workspace}}/build/bin
|
||||
run: sudo python3 test_p2p.py --cleanup-mock-ips
|
||||
shell: bash
|
||||
|
||||
- name: Configure CMake (Release)
|
||||
run: cmake -B ${{github.workspace}}/build-release
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
+18
-3
@@ -208,6 +208,8 @@ def _IsAddressBindable( addr ):
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
_WINDOWS_LOOPBACK_IFACE = 'Loopback Pseudo-Interface 1'
|
||||
|
||||
def _AddLoopbackAddr( addr ):
|
||||
is_ipv6 = ':' in addr
|
||||
sys_name = platform.system()
|
||||
@@ -223,7 +225,12 @@ def _AddLoopbackAddr( addr ):
|
||||
print( "Running 'ip -6 addr add %s/112 dev lo'" % addr )
|
||||
subprocess.run( [ 'ip', '-6', 'addr', 'add', addr + '/112', 'dev', 'lo' ], check=True )
|
||||
# IPv4 on Linux: the entire 127/8 block is routable on lo, nothing to do.
|
||||
# Windows: TBD when needed
|
||||
elif sys_name == 'Windows':
|
||||
if is_ipv6:
|
||||
print( "Running 'netsh interface ipv6 add address \"%s\" %s'" % ( _WINDOWS_LOOPBACK_IFACE, addr ) )
|
||||
subprocess.run( [ 'netsh', 'interface', 'ipv6', 'add', 'address',
|
||||
_WINDOWS_LOOPBACK_IFACE, addr ], check=True )
|
||||
# IPv4 on Windows: the entire 127/8 block is routable on the loopback adapter, nothing to do.
|
||||
|
||||
def _RemoveLoopbackAddr( addr ):
|
||||
is_ipv6 = ':' in addr
|
||||
@@ -240,7 +247,12 @@ def _RemoveLoopbackAddr( addr ):
|
||||
print( "Running 'ip -6 addr del %s/112 dev lo'" % addr )
|
||||
subprocess.run( [ 'ip', '-6', 'addr', 'del', addr + '/112', 'dev', 'lo' ], check=False )
|
||||
# IPv4 on Linux: nothing was added, nothing to remove.
|
||||
# Windows: TBD when needed
|
||||
elif sys_name == 'Windows':
|
||||
if is_ipv6:
|
||||
print( "Running 'netsh interface ipv6 delete address \"%s\" %s'" % ( _WINDOWS_LOOPBACK_IFACE, addr ) )
|
||||
subprocess.run( [ 'netsh', 'interface', 'ipv6', 'delete', 'address',
|
||||
_WINDOWS_LOOPBACK_IFACE, addr ], check=False )
|
||||
# IPv4 on Windows: nothing was added, nothing to remove.
|
||||
|
||||
def SetupMockIPs():
|
||||
"""Add loopback aliases for every mock address that is not already bindable."""
|
||||
@@ -264,7 +276,10 @@ def CheckMockIPsBindable():
|
||||
print( "ERROR: the following addresses required by the mock network are not bindable:" )
|
||||
for addr in missing:
|
||||
print( " " + addr )
|
||||
print( "Run 'sudo %s --setup-mock-ips' to add the required loopback aliases." % sys.argv[0] )
|
||||
if platform.system() == 'Windows':
|
||||
print( "Run '%s --setup-mock-ips' from an elevated (Administrator) prompt." % sys.argv[0] )
|
||||
else:
|
||||
print( "Run 'sudo %s --setup-mock-ips' to add the required loopback aliases." % sys.argv[0] )
|
||||
sys.exit(1)
|
||||
|
||||
def _nat( internal, gateway, nat_type ):
|
||||
|
||||
Reference in New Issue
Block a user