func determineNetworkType(network string, ip net.IP) (NetworkType, error) {
	ipv4 := ip.To4() != nil
	switch {
	case strings.HasPrefix(strings.ToLower(network), udp):
		if ipv4 {
			return NetworkTypeUDP4, nil
		}
		return NetworkTypeUDP6, nil
	case strings.HasPrefix(strings.ToLower(network), tcp):
		if ipv4 {
			return NetworkTypeTCP4, nil
		}
		return NetworkTypeTCP6, nil
	}
	return NetworkType(0), fmt.Errorf("unable to determine networkType from %s %s", network, ip)
}
determineNetworkType determines the type of network based on
the short network string and an IP address.
package ice
import (
	"fmt"
	"net"
	"strings"
)
const (
	udp = "udp"
	tcp = "tcp"
)
var supportedNetworks = []string{
	udp,
}
var supportedNetworkTypes = []NetworkType{
	NetworkTypeUDP4,
	NetworkTypeUDP6,
}
type NetworkType int
const (
	NetworkTypeUDP4 NetworkType = iota + 1
	NetworkTypeUDP6
	NetworkTypeTCP4
	NetworkTypeTCP6
)
func (t NetworkType) String() string {
	switch t {
	case NetworkTypeUDP4:
		return "udp4"
	case NetworkTypeUDP6:
		return "udp6"
	case NetworkTypeTCP4:
		return "tcp4"
	case NetworkTypeTCP6:
		return "tcp6"
	default:
		return ErrUnknownType.Error()
	}
}
func (t NetworkType) NetworkShort() string {
	switch t {
	case NetworkTypeUDP4, NetworkTypeUDP6:
		return udp
	case NetworkTypeTCP4, NetworkTypeTCP6:
		return tcp
	default:
		return ErrUnknownType.Error()
	}
}
func (t NetworkType) IsReliable() bool {
	switch t {
	case NetworkTypeUDP4, NetworkTypeUDP6:
		return false
	case NetworkTypeTCP4, NetworkTypeTCP6:
		return true
	}
	return false
}
func (t NetworkType) IsIPv4() bool {
	switch t {
	case NetworkTypeUDP4, NetworkTypeTCP4:
		return true
	case NetworkTypeUDP6, NetworkTypeTCP6:
		return false
	}
	return false
}
func (t NetworkType) IsIPv6() bool {
	switch t {
	case NetworkTypeUDP4, NetworkTypeTCP4:
		return false
	case NetworkTypeUDP6, NetworkTypeTCP6:
		return true
	}
	return false
}