how to check what is the IP version (IPv4 or IPv6) of the flow in AppProxy

I need some reference on how to check what is the IP version (IPv4 or IPv6) of the flow we have received in AppProxy::handleNewFlow(). Based on this there are business logic which I need apply on the flow.
I checked the flow::metadata and other references in AppProxy documentation but couldn’t find anything. 
If you have the address of the flow you can use IPv4Address or IPv6Address to check the conformance of the address to see where it falls. That would be one option. Something like the following would work:

Code Block swift
import Network
let v4AddressLiteral = "192.168.1.1"
let v6AddressLiteral = "xxxx::xxxx:xxxx:xxxx:xxxx%en12"
/* IPv4Address creation will fail for an address that is not valid */
var v4Address = IPv4Address(v4AddressLiteral)
/* IPv6Address creation will fail for an address that is not valid */
/* Note that an IPv6 address may be scoped to an interface. */
var v6Address = IPv6Address(v6AddressLiteral)



Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
how to check what is the IP version (IPv4 or IPv6) of the flow in AppProxy
 
 
Q