public static Multiaddress ToMultiaddress(this EndPoint ep, ProtocolType protocolType) { var ma = new Multiaddress(); var ip = (IPEndPoint)ep; if (ip != null) { if (ip.AddressFamily == AddressFamily.InterNetwork) { ma.Add <IP4>(ip.Address); } if (ip.AddressFamily == AddressFamily.InterNetworkV6) { ma.Add <IP6>(ip.Address); } if (protocolType == ProtocolType.Tcp) { ma.Add <TCP>((ushort)ip.Port); } if (protocolType == ProtocolType.Udp) { ma.Add <UDP>((ushort)ip.Port); } } return(ma); }
public static Multiaddress ToMultiaddress(this IPAddress ip) { var ma = new Multiaddress(); if (ip.AddressFamily == AddressFamily.InterNetwork) { ma.Add <IP4>(ip); } if (ip.AddressFamily == AddressFamily.InterNetworkV6) { ma.Add <IP6>(ip); } return(ma); }