示例#1
0
        public ListenPortController()
        {
            settings               = SettingsManager.EngineSettings;
            devices                = new List <INatDevice> ();
            tcpMapping             = new Mapping(Protocol.Tcp, settings.ListenPort, settings.ListenPort);
            tcpMapping.Description = Defines.ApplicationName;

            udpMapping             = new Mapping(Protocol.Udp, settings.ListenPort, settings.ListenPort);
            udpMapping.Description = Defines.ApplicationName;

            IPAddress[] addresses = null;
            try
            {
                addresses = NatUtility.GetLocalAddresses(false);
            }
            catch (Exception)
            {
                logger.Warn("Could not resolve hostname, port forwarding may not work");
                addresses = new IPAddress[] { IPAddress.Loopback };
            }

            NatUtility.DeviceFound += OnDeviceFound;
        }