Пример #1
0
 public Task <StunResult> StunQuery(string host, int port, TimeSpan timeout)
 {
     if (m_StunQuery != null && !m_StunQuery.IsCompleted)
     {
         throw new Exception("already StunQuery.Run");
     }
     m_StunQuery = new StunQuery(m_Socket, host, port, timeout);
     return(m_StunQuery.Run(System.Threading.CancellationToken.None));
 }
Пример #2
0
        private bool PerformNatQueryOn(string host, int port)
        {
            Logger.Debug($"Performing STUN query to {host}:{port}");
            _stunQuery = StunQuery.Perform(_socket, host, port);
            if (_stunQuery == null || _stunQuery.NetworkType == StunNetworkType.CommunicationError)
            {
                _stunQuery = null;
                Logger.Debug($"STUN query to {host}:{port} failed with communication error");
                return(false);
            }

            return(true);
        }