Beispiel #1
0
        /// <param name="socket">A UDP <see cref="Socket"/> that will use for query. You can also use <see cref="UdpClient.Client"/></param>
        /// <param name="server">Server address</param>
        /// <param name="queryType">Query type</param>
        /// <param name="natTypeDetectionRfc">Rfc algorithm type</param>
        public static STUNQueryResult Query(Socket socket, IPEndPoint server, STUNQueryType queryType,
                                            IPAddress[] localIPs, NATTypeDetectionRFC natTypeDetectionRfc)
        {
            if (natTypeDetectionRfc == NATTypeDetectionRFC.Rfc3489)
            {
                return(STUNRfc3489.Query(socket, server, queryType, localIPs, ReceiveTimeout));
            }

            if (natTypeDetectionRfc == NATTypeDetectionRFC.Rfc5780)
            {
                return(STUNRfc5780.Query(socket, server, queryType, localIPs, ReceiveTimeout));
            }

            return(new STUNQueryResult());
        }
Beispiel #2
0
        private static STUNQueryFullResult QueryInternal(Socket socket, IPEndPoint server, STUNQueryType queryType,
                                                         NATTypeDetectionRFC natTypeDetectionRfc)
        {
            if (natTypeDetectionRfc == NATTypeDetectionRFC.Rfc3489)
            {
                return(STUNRfc3489.Query(socket, server, queryType, ReceiveTimeout));
            }

            if (natTypeDetectionRfc == NATTypeDetectionRFC.Rfc5780)
            {
                return(STUNRfc5780.Query(socket, server, queryType, ReceiveTimeout));
            }

            throw new Exception($"Unexpected RFC type {natTypeDetectionRfc}");
        }