Skip to content

Conversation

@Riventh
Copy link

@Riventh Riventh commented Nov 13, 2025

Summary

Adds support for IPv6 addresses in WinRM endpoint URLs, enabling pywinrm to work in IPv6-only and dual-stack environments.

Problem

The Session._build_url() method could not parse IPv6 addresses in bracket notation (RFC 3986 format). The existing regex pattern only matched
IPv4 addresses and hostnames, causing URLs like http://[2a05:d018:1961:ba00:ff5b:37ba:20c7:726a]:5985/wsman to fail parsing.

Solution

Implemented dual-pattern regex matching:

  1. First attempts to match IPv6 addresses in bracket notation: [[0-9a-f:]+]
  2. Falls back to the original IPv4/hostname pattern if IPv6 doesn't match
  3. Maintains full backward compatibility with existing functionality

Changes

  • Updated Session._build_url() to support IPv6 bracket notation per RFC 3986
  • Added 8 comprehensive test cases covering various IPv6 URL formats
  • All existing tests pass without modification

Test Coverage

  • Basic IPv6: [2a05:d018:1961:ba00:ff5b:37ba:20c7:726a] → http://[2a05:d018:1961:ba00:ff5b:37ba:20c7:726a]:5985/wsman
  • IPv6 with port: [::1]:8080 → http://[::1]:8080/wsman
  • IPv6 with scheme: https://[fe80::1] → https://[fe80::1]:5985/wsman
  • IPv6 localhost: [::1] → http://[::1]:5985/wsman
  • IPv6 with SSL transport
  • Full URLs with IPv6 addresses

Validation

  • ✅ All 77 existing tests pass
  • ✅ All 8 new IPv6 tests pass
  • ✅ Type checking passes (mypy)
  • ✅ Code formatting passes (black, isort)
  • ✅ No breaking changes

Fixes #400

@Riventh Riventh marked this pull request as ready for review November 13, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPv6 Address Support in WinRM URLs

1 participant