The test-tunnel network address discovery module
test_tunnel.addresses
Find addresses and ports for the tunnel testing library.
This module contains helper functions for obtaining the IPv4 and IPv6 addresses of the system's network interfaces, determining which port numbers are available for listening on each of those addresses, and then determining which pairs of addresses may be used as source and destination for TCP connections. Its purpose is to enable a testing tool to listen on one address and establish a client connection from another one, with the listener and the client possibly in separate processes (or even programs).
Data structures
test_tunnel.addresses.Address
dataclass
test_tunnel.addresses.AddrPort
dataclass
An address and two "free" ports to listen on during the test run.
Source code in src/test_tunnel/addresses.py
Exceptions
test_tunnel.addresses.UnsupportedAddressFamilyError
dataclass
Bases: Exception
An unsupported address family was specified.
Source code in src/test_tunnel/addresses.py
Address and port discovery routines
test_tunnel.addresses.get_addresses(cfg)
Get the IPv4 and IPv6 addresses on this system.
Source code in src/test_tunnel/addresses.py
test_tunnel.addresses.find_ports(cfg, addrs, first_port=6374)
Find two ports per network address to listen on.
The search starts from first_port + cfg.offset
as a port number.
Port numbers are never reused, even for different addresses.
Source code in src/test_tunnel/addresses.py
Address selection and combining routines
test_tunnel.addresses.find_pairs(cfg, ports)
Figure out which addresses can connect to which other addresses.
Source code in src/test_tunnel/addresses.py
test_tunnel.addresses.pick_pairs(cfg, apairs)
Pick two (maybe the same) addresses for each family.
Source code in src/test_tunnel/addresses.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
Utility functions
test_tunnel.addresses.family_id(family)
Return a '4' or '6' specification depending on the address family.
Source code in src/test_tunnel/addresses.py
test_tunnel.addresses.bind_to(cfg, addr, port)
Bind to the specified port on the specified address.