---
# Example showing the IPv6 problem WITHOUT the explicit port parameters patch
#
# This playbook demonstrates why explicit source_port and destination_port
# parameters are needed for IPv6 support in pfsense_nat_port_forward.
#
# The old :port syntax is deprecated and incompatible with IPv6 addresses
# since IPv6 addresses already contain colons (e.g., 2001:db8::1).
#
# After the fix for issue #219, IPv6 addresses are parsed as single units
# without splitting on ':'. This means there's no way to specify ports
# using the old address:port syntax.

- name: Example NAT Port Forward with IPv6 (BROKEN without patch)
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Try to create IPv6 NAT port forward rule
      pfsensible.core.pfsense_nat_port_forward:
        descr: "Forward HTTPS to internal IPv6 server"
        interface: wan
        ipprotocol: inet6
        protocol: tcp
        source: any
        # PROBLEM: Cannot specify destination port with IPv6 address
        # The following will NOT work because:
        # 1. The :port syntax is deprecated
        # 2. IPv6 addresses contain colons, so 2001:db8::1:443 is ambiguous
        # 3. After #219 fix, IPv6 addresses are not split on ':'
        destination: "2001:db8:cafe::1"  # How do we specify port 443?
        target: "fd00::1:443"             # Target works because it's parsed separately
        state: present

      # ERROR: This rule cannot specify destination port!
      # The old syntax "2001:db8:cafe::1:443" doesn't work because:
      # - Is :443 a port or part of the IPv6 address?
      # - The parser treats the whole thing as an IPv6 address

      # WORKAROUND (before this patch): Create an alias first
      # But this is cumbersome and doesn't address the deprecation warning

    - name: The deprecated syntax still triggers warnings for IPv4
      pfsensible.core.pfsense_nat_port_forward:
        descr: "IPv4 example with deprecated syntax"
        interface: wan
        ipprotocol: inet
        protocol: tcp
        source: any
        destination: "192.168.1.1:443"  # DEPRECATED - triggers warning
        target: "10.0.0.5:8443"
        state: present

      # WARNING: "the :ports syntax at end of addresses is deprecated and
      # support will be removed soon. Please use source_port and
      # destination_port options."
