Ejemplo n.º 1
0
        public static void DeviceFound(object sender, DeviceEventArgs args)
        {
            if (args.Device == null)
                return;

            Log.Write("server", "NAT device discovered.");

            Game.Settings.Server.NatDeviceAvailable = true;
            Game.Settings.Server.AllowPortForward = true;

            try
            {
                NatDevice = args.Device;
                Log.Write("server", "Type: {0}", NatDevice.GetType());
                Log.Write("server", "Your external IP is: {0}", NatDevice.GetExternalIP());

                foreach (var mp in NatDevice.GetAllMappings())
                    Log.Write("server", "Existing port mapping: protocol={0}, public={1}, private={2}",
                              mp.Protocol, mp.PublicPort, mp.PrivatePort);
            }
            catch (Exception e)
            {
                Log.Write("server", "Can't fetch information from NAT device: {0}", e);

                Game.Settings.Server.NatDeviceAvailable = false;
                Game.Settings.Server.AllowPortForward = false;
            }
        }
Ejemplo n.º 2
0
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            try
            {
                INatDevice device = args.Device;

                //remove existing port maps that exist on the ports we want
                foreach (Mapping portMap in device.GetAllMappings())
                {
                    if (externalPorts.Contains(portMap.PublicPort))
                    {
                        Console.WriteLine("Deleting " + portMap.PublicPort.ToString());
                        device.DeletePortMap(portMap);
                    }
                }

                //add the ports we want for our IP
                for (int i = 0; i <= 2; i++)
                {
                    Console.WriteLine("Creating IP: " + device.LocalAddress.ToString() + " port: " + i.ToString());
                    device.CreatePortMap(new Mapping(Protocol.Tcp, internalPorts[i], externalPorts[i]));
                }
            }
            catch (Exception e)
            {
            }
        }
Ejemplo n.º 3
0
        private void CreateRules(INatDevice device)
        {
            // On some systems the device discovered event seems to fire repeatedly
            // This check will help ensure we're not trying to port map the same device over and over

            List <Mapping> currentMappings = null;

            try
            {
                currentMappings = device.GetAllMappings().ToList();
            }
            catch (NotSupportedException)
            {
            }

            var address = device.LocalAddress.ToString();

            if (!_createdRules.Contains(address))
            {
                _createdRules.Add(address);

                CreatePortMap(device, currentMappings, _appHost.HttpPort, _config.Configuration.PublicPort);
                CreatePortMap(device, currentMappings, _appHost.HttpsPort, _config.Configuration.PublicHttpsPort);
            }
        }
Ejemplo n.º 4
0
        void refresh()
        {
            if (devices.Count == 0)
            {
                MessageBox.Show("Devices not yet found.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Invoke((MethodInvoker) delegate
            {
                lstPorts.Items.Clear();

                for (int i = 0; i < devices.Count; i++)
                {
                    INatDevice device = devices[i];
                    Mapping[] maps    = device.GetAllMappings();
                    foreach (Mapping map in maps)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text         = map.PrivatePort.ToString();
                        item.SubItems.Add(map.PublicPort.ToString());
                        item.SubItems.Add(map.Protocol.ToString());
                        item.Tag = device;
                        lstPorts.Items.Add(item);
                    }
                }
            });
        }
Ejemplo n.º 5
0
        public static void DeviceFound(object sender, DeviceEventArgs args)
        {
            if (args.Device == null)
            {
                return;
            }

            Log.Write("server", "NAT device discovered.");

            Game.Settings.Server.NatDeviceAvailable = true;
            Game.Settings.Server.AllowPortForward   = true;

            try
            {
                NatDevice = args.Device;
                Log.Write("server", "Type: {0}", NatDevice.GetType());
                Log.Write("server", "Your external IP is: {0}", NatDevice.GetExternalIP());

                foreach (var mp in NatDevice.GetAllMappings())
                {
                    Log.Write("server", "Existing port mapping: protocol={0}, public={1}, private={2}",
                              mp.Protocol, mp.PublicPort, mp.PrivatePort);
                }
            }
            catch (Exception e)
            {
                Log.Write("server", "Can't fetch information from NAT device: {0}", e);

                Game.Settings.Server.NatDeviceAvailable = false;
                Game.Settings.Server.AllowPortForward   = false;
            }
        }
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            if (btnOpenWasClicked == true)
            {
                INatDevice device       = args.Device;
                Mapping    minecraftTCP = new Mapping(Protocol.Tcp, 25565, 25565);
                Mapping    minecraftUDP = new Mapping(Protocol.Udp, 25565, 25565);
                minecraftTCP.Description = "MinecraftTCP";
                minecraftUDP.Description = "MinecraftUDP";
                device.CreatePortMap(minecraftTCP);
                device.CreatePortMap(minecraftUDP);


                foreach (Mapping portMap in device.GetAllMappings())
                {
                    Debug.Print(portMap.ToString());
                }

                MessageBox.Show("Port 25565 has been opened.");
                MessageBoxResult diag = MessageBox.Show("This is the IP you will give to your friends: " + device.GetExternalIP().ToString() + ":25565" + " Do you wanna copy the IP? ",
                                                        "Success", MessageBoxButton.YesNo, MessageBoxImage.Information);

                if (diag == MessageBoxResult.Yes)
                {
                    Thread thread = new Thread(() => Clipboard.SetText(device.GetExternalIP() + ":25565"));
                    thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
                    thread.Start();
                    thread.Join();                                //Wait for the thread to end
                }
            }
        }
Ejemplo n.º 7
0
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            try {
                INatDevice device = args.Device;

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Device found");
                Console.ResetColor();
                Console.WriteLine("Type: {0}", device.GetType().Name);
                Console.WriteLine("Service Type: {0}", (device as UpnpNatDevice).ServiceType);

                Console.WriteLine("IP: {0}", device.GetExternalIP());
                device.CreatePortMap(new Mapping(Protocol.Tcp, 15001, 15001));
                Console.WriteLine("---");

                //return;
                /******************************************/
                /*         Advanced test suite.           */
                /******************************************/

                // Try to create a new port map:
                var mapping = new Mapping(Protocol.Tcp, 6001, 6001);
                device.CreatePortMap(mapping);
                Console.WriteLine("Create Mapping: protocol={0}, public={1}, private={2}", mapping.Protocol, mapping.PublicPort,
                                  mapping.PrivatePort);

                // Try to retrieve confirmation on the port map we just created:
                try {
                    Mapping m = device.GetSpecificMapping(Protocol.Tcp, 6001);
                    Console.WriteLine("Specific Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort,
                                      m.PrivatePort);
                } catch {
                    Console.WriteLine("Couldn't get specific mapping");
                }

                // Try deleting the port we opened before:
                try {
                    device.DeletePortMap(mapping);
                    Console.WriteLine("Deleting Mapping: protocol={0}, public={1}, private={2}", mapping.Protocol, mapping.PublicPort,
                                      mapping.PrivatePort);
                } catch {
                    Console.WriteLine("Couldn't delete specific mapping");
                }

                // Try retrieving all port maps:
                foreach (Mapping mp in device.GetAllMappings())
                {
                    Console.WriteLine("Existing Mapping: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort,
                                      mp.PrivatePort);
                }

                Console.WriteLine("External IP: {0}", device.GetExternalIP());
                Console.WriteLine("Done...");
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 8
0
        private void ShowMappedPorts(object sender, DeviceEventArgs args)
        {
            INatDevice device = args.Device;

            foreach (Mapping portMap in device.GetAllMappings())
            {
                MessageBox.Show(portMap.ToString());
            }
        }
Ejemplo n.º 9
0
 private void NatUtility_DeviceFound(object sender, DeviceEventArgs e)
 {
     natDevice   = e.Device;
     EnabledUpnp = true;
     Debug.Log("Enabled UPnP.\nexisting maps:");
     foreach (Mapping portMap in natDevice.GetAllMappings())
     {
         Debug.Log(portMap.ToString());
     }
 }
Ejemplo n.º 10
0
        private static Mapping GetMappingFromDevice(INatDevice device, Mapping mapping)
        {
            //Récupere la liste actuelle
            var routerTableMapping = device.GetAllMappings();

            //On check si le port y est
            return(routerTableMapping.Where(m => m.Protocol == mapping.Protocol &&
                                            m.PrivatePort == mapping.PrivatePort &&
                                            m.PublicPort == mapping.PublicPort)
                   .FirstOrDefault());
        }
Ejemplo n.º 11
0
        /*
         * When device is found, forward the port set up in App.config.
         */
        public static void OnDeviceFound(object sender, DeviceEventArgs args)
        {
            Console.WriteLine("Port Forwarding Device Found");
            device = args.Device;
            device.CreatePortMap(new Mapping(Protocol.Tcp, PORT, PORT)); // Forward Port
            Clog("Port - " + PORT.ToString() + " - Forwarded Successfully");

            foreach (Mapping portMap in device.GetAllMappings())   // Log all portmaps
            {
                Clog("Port Map - " + portMap.ToString());
            }
        }
Ejemplo n.º 12
0
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            INatDevice device = device = args.Device;

            device.CreatePortMap(new Mapping(Mono.Nat.Protocol.Tcp, this.port, this.port));

            foreach (Mapping portMap in device.GetAllMappings())
            {
                Console.WriteLine(portMap.ToString());
            }

            Console.WriteLine(device.GetExternalIP().ToString());
        }
Ejemplo n.º 13
0
 private void btUpdate_Click(object sender, EventArgs e)
 {
     if (lvDevices.SelectedItems.Count > 0)
     {
         INatDevice device = GetDeviceByUUID(lvDevices.SelectedItems[0].SubItems[3].Text);
         Mapping[]  maps   = device.GetAllMappings();
         if (maps.Length != Convert.ToInt32(lvDevices.SelectedItems[0].SubItems[2].Text))
         {
             lvDevices.SelectedItems[0].SubItems[2].Text = maps.Length.ToString();
             UpdateMappings(lvDevices.SelectedItems[0].SubItems[3].Text);
         }
     }
 }
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            try {
                INatDevice device = args.Device;

                fLogger.WriteInfo("Device found, type: {0}", device.GetType().Name);
                if (device.GetType().Name == "PmpNatDevice")
                {
                    fLogger.WriteInfo("Device skipped");
                    return;
                }

                fLogger.WriteInfo("External IP: {0}", device.GetExternalIP());

                try {
                    Mapping m;

                    /*Mapping m = device.GetSpecificMapping(Mono.Nat.Protocol.Tcp, ProtocolHelper.PublicTCPPort);
                     * if (m != null) {
                     *  fLogger.WriteInfo("Specific Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);
                     * } else {*/
                    /*m = new Mapping(Protocol.Tcp, ProtocolHelper.PublicTCPPort, ProtocolHelper.PublicTCPPort);
                     * device.CreatePortMap(m);
                     * fLogger.WriteInfo("Create Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);*/
                    //}

                    m = device.GetSpecificMapping(Protocol.Udp, DHTClient.PublicDHTPort);
                    if (m != null)
                    {
                        try {
                            device.DeletePortMap(m);
                        } catch {
                        }
                    }
                    m = new Mapping(Protocol.Udp, DHTClient.PublicDHTPort, DHTClient.PublicDHTPort);
                    device.CreatePortMap(m);
                    fLogger.WriteInfo("Create Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);
                } catch (Exception ex) {
                    fLogger.WriteError("Couldn't create specific mapping", ex);
                }

                foreach (Mapping mp in device.GetAllMappings())
                {
                    fLogger.WriteInfo("Existing Mapping: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort, mp.PrivatePort);
                }

                fUPnPSem.Release();
            } catch (Exception ex) {
                fLogger.WriteError("NATMapper.DeviceFound()", ex);
            }
        }
Ejemplo n.º 15
0
 private void btRemoveAll_Click(object sender, EventArgs e)
 {
     if (lvDevices.SelectedItems.Count > 0)
     {
         if (MessageBox.Show("Are you sure you want to remove all mappings?", "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             INatDevice device = GetDeviceByUUID(lvDevices.SelectedItems[0].SubItems[3].Text);
             foreach (Mapping mp in device.GetAllMappings())
             {
                 device.DeletePortMap(mp);
             }
             UpdateMappings(lvDevices.SelectedItems[0].SubItems[3].Text);
         }
     }
 }
Ejemplo n.º 16
0
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            INatDevice device = device = args.Device;

            device.CreatePortMap(new Mapping(Protocol.Tcp, Epicoin.getport, Epicoin.getport));
            device.CreatePortMap(new Mapping(Protocol.Tcp, Epicoin.mineport, Epicoin.mineport));
            device.CreatePortMap(new Mapping(Protocol.Tcp, Epicoin.peerport, Epicoin.peerport));
            device.CreatePortMap(new Mapping(Protocol.Tcp, Epicoin.transport, Epicoin.transport));

            foreach (Mapping portMap in device.GetAllMappings())
            {
                Console.WriteLine(portMap.ToString());
            }

            Console.WriteLine(device.GetExternalIP().ToString());
        }
Ejemplo n.º 17
0
        private static void DeviceFound(object sender, DeviceEventArgs args)
        {
            INatDevice device = args.Device;

            foreach (var port in UPnP._port)
            {
                device.CreatePortMap(new Mapping(Mono.Nat.Protocol.Tcp, port, port));
            }

            foreach (Mapping portMap in device.GetAllMappings())
            {
                Console.WriteLine(portMap.ToString());
            }

            Console.WriteLine(device.GetExternalIP().ToString());
        }
Ejemplo n.º 18
0
        private static void DeviceFound(object sender, DeviceEventArgs args)
        {
            try {
                INatDevice device = args.Device;

                fLogger.WriteInfo("Device found");
                fLogger.WriteInfo("Type: {0}", device.GetType().Name);
                fLogger.WriteInfo("External IP: {0}", device.GetExternalIP());

                try {
                    Mapping m = device.GetSpecificMapping(Mono.Nat.Protocol.Tcp, ProtocolHelper.PublicTCPPort);
                    if (m != null)
                    {
                        fLogger.WriteInfo("Specific Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);
                    }
                    else
                    {
                        m = new Mapping(Mono.Nat.Protocol.Tcp, ProtocolHelper.PublicTCPPort, ProtocolHelper.PublicTCPPort);
                        device.CreatePortMap(m);
                        fLogger.WriteInfo("Create Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);
                    }

                    m = device.GetSpecificMapping(Mono.Nat.Protocol.Udp, DHTClient.PublicDHTPort);
                    if (m != null)
                    {
                        fLogger.WriteInfo("Specific Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);
                    }
                    else
                    {
                        m = new Mapping(Mono.Nat.Protocol.Udp, DHTClient.PublicDHTPort, DHTClient.PublicDHTPort);
                        device.CreatePortMap(m);
                        fLogger.WriteInfo("Create Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);
                    }
                } catch {
                    fLogger.WriteInfo("Couldnt get specific mapping");
                }

                foreach (Mapping mp in device.GetAllMappings())
                {
                    fLogger.WriteInfo("Existing Mapping: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort, mp.PrivatePort);
                }

                fLogger.WriteInfo("Done...");
            } catch (Exception ex) {
                fLogger.WriteError("NATMapper.DeviceFound()", ex);
            }
        }
Ejemplo n.º 19
0
    void DeviceFound(object sender, DeviceEventArgs args)
    {
        // This is the upnp enabled router
        INatDevice device = args.Device;

        // Create a mapping to forward external port 3000 to local port 1500
        device.CreatePortMap(new Mapping(Protocol.Tcp, 1500, 3000));
        // Retrieve the details for the port map for external port 3000
        Mapping m = device.GetSpecificMapping(Protocol.Tcp, 3000);

        // Get all the port mappings on the device and delete them
        foreach (Mapping mp in device.GetAllMappings())
        {
            device.DeletePortMap(mp);
        }
        // Get the external IP address
        IPAddress externalIP = device.GetExternalIP();
    }
Ejemplo n.º 20
0
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            try
            {
                INatDevice device = args.Device;

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Device found");
                Console.ResetColor();
                Console.WriteLine("Type: {0}", device.GetType().Name);

                Console.WriteLine("IP: {0}", device.GetExternalIP());
                device.CreatePortMap(new Mapping(Protocol.Tcp, 1500, 1500));
                Console.WriteLine("---");

                return;

                Mapping mapping = new Mapping(Protocol.Tcp, 6001, 6001);
                device.CreatePortMap(mapping);
                Console.WriteLine("Create Mapping: protocol={0}, public={1}, private={2}", mapping.Protocol, mapping.PublicPort, mapping.PrivatePort);

                try
                {
                    Mapping m = device.GetSpecificMapping(Protocol.Tcp, 6001);
                    Console.WriteLine("Specific Mapping: protocol={0}, public={1}, private={2}", m.Protocol, m.PublicPort, m.PrivatePort);
                }
                catch
                {
                    Console.WriteLine("Couldnt get specific mapping");
                }
                foreach (Mapping mp in device.GetAllMappings())
                {
                    Console.WriteLine("Existing Mapping: protocol={0}, public={1}, private={2}", mp.Protocol, mp.PublicPort, mp.PrivatePort);
                    device.DeletePortMap(mp);
                }

                Console.WriteLine("External IP: {0}", device.GetExternalIP());
                Console.WriteLine("Done...");
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 21
0
        public void Unmap(Protocol protocol, int port)
        {
            if (router == null)
            {
                Start();
                Thread.Sleep(5000);
            }

            if (router == null)
            {
                return;
            }

            foreach (Mapping mapping in router.GetAllMappings())
            {
                if (mapping.PublicPort == port && mapping.Protocol == protocol)
                {
                    router.DeletePortMap(mapping);
                }
            }
        }
Ejemplo n.º 22
0
        private void UpdateMappings(string uuid)
        {
            INatDevice device = null;

            for (int i = 0; i < devices.Count; i++)
            {
                if (devices[i].ToString().Contains(lvDevices.SelectedItems[0].SubItems[3].Text))
                {
                    device = devices[i];
                }
            }

            lvMappings.Items.Clear();
            foreach (Mapping mp in device.GetAllMappings())
            {
                lvMappings.Items.Add(mp.Description);
                lvMappings.Items[lvMappings.Items.Count - 1].SubItems.Add(mp.PrivatePort.ToString());
                lvMappings.Items[lvMappings.Items.Count - 1].SubItems.Add(mp.PublicPort.ToString());
                lvMappings.Items[lvMappings.Items.Count - 1].SubItems.Add(mp.Protocol.ToString());
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Adding devices to the list and listbox
        /// </summary>
        /// <param name="device"></param>
        private void AddDevice(INatDevice device)
        {
            if (!devices.Contains(device))
            {
                devices.Add(device);
                //listBoxDevices.Items.Add(device.ToString());
                IPAddress external = device.GetExternalIP();
                Mapping[] maps = device.GetAllMappings();

                //complicated stuff because the library only allows to display some data via .ToString() as far as I know
                string str = device.ToString();
                lvDevices.Items.Add(ReadBetween("EndPoint:", ",", str));
                lvDevices.Items[lvDevices.Items.Count-1].SubItems.Add(external.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(maps.Length.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(ReadBetween("/dyndev/uuid:", ",", str));

                //if it's the first added, select it
                if (lvDevices.Items.Count == 1)
                    lvDevices.Items[0].Selected = true;
            }
        }
Ejemplo n.º 24
0
 private void btRemove_Click(object sender, EventArgs e)
 {
     if (lvDevices.SelectedItems.Count > 0)
     {
         INatDevice device = GetDeviceByUUID(lvDevices.SelectedItems[0].SubItems[3].Text);
         for (int i = 0; i < lvMappings.SelectedItems.Count; i++)
         {
             foreach (Mapping mp in device.GetAllMappings())
             {
                 if (mp.PrivatePort == Convert.ToInt32(lvMappings.SelectedItems[i].SubItems[1].Text) &&
                     mp.PublicPort == Convert.ToInt32(lvMappings.SelectedItems[i].SubItems[2].Text) &&
                     mp.Protocol.ToString() == lvMappings.SelectedItems[i].SubItems[3].Text &&
                     mp.Description == lvMappings.SelectedItems[i].SubItems[0].Text)
                 {
                     device.DeletePortMap(mp);
                 }
             }
         }
         UpdateMappings(lvDevices.SelectedItems[0].SubItems[3].Text);
     }
 }
        private void DeviceFound(object sender, DeviceEventArgs args)
        {
            device = args.Device;

            // on device found code
            Console.WriteLine(device.GetExternalIP().ToString());


            device.CreatePortMap(new Mapping(Protocol.Tcp, obj.Client_Port, obj.Client_Port, 100000));
            device.CreatePortMap(new Mapping(Protocol.Udp, obj.Client_Port, obj.Client_Port, 100000));



            obj.Public_IP = device.GetExternalIP();
            Console.WriteLine(device.GetExternalIP().ToString());


            foreach (Mapping portMap in device.GetAllMappings())
            {
                Console.WriteLine(portMap.ToString());
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Adding devices to the list and listbox
        /// </summary>
        /// <param name="device"></param>
        private void AddDevice(INatDevice device)
        {
            if (!devices.Contains(device))
            {
                devices.Add(device);
                //listBoxDevices.Items.Add(device.ToString());
                IPAddress external = device.GetExternalIP();
                Mapping[] maps     = device.GetAllMappings();

                //complicated stuff because the library only allows to display some data via .ToString() as far as I know
                string str = device.ToString();
                lvDevices.Items.Add(ReadBetween("EndPoint:", ",", str));
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(external.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(maps.Length.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(ReadBetween("/dyndev/uuid:", ",", str));

                //if it's the first added, select it
                if (lvDevices.Items.Count == 1)
                {
                    lvDevices.Items[0].Selected = true;
                }
            }
        }
Ejemplo n.º 27
0
        private static void DeviceFound(object sender, DeviceEventArgs args)
        {
            INatDevice       device = args.Device;
            IGamePortMapping gamePortMapping;

            switch (Mode)
            {
            case Mode.ADD:
            case Mode.REMOVE:
                if (GameName == "TestGame")
                {
                    //Tweak pour load l'assembly
                    gamePortMapping = new TestGame();
                }
                else
                {
                    gamePortMapping = (IGamePortMapping)AssemblyLoader.GetInstanceOfGameMapping(GameName);
                }

                if (gamePortMapping == null)
                {
                    Console.WriteLine("Le jeu " + GameName + " n'a pas été trouvé, veuillez réessayer.");
                    System.Environment.Exit(1);
                }

                Console.WriteLine(gamePortMapping.Description());

                if (Mode == Mode.REMOVE)
                {
                    Console.WriteLine("Le système va tenter de supprimer ces ports de la table NAT");
                }
                else
                {
                    Console.WriteLine("Le système va tenter d'ajouter ces ports de la table NAT");
                }

                Console.WriteLine("Appliquer ? [O]/N");
                String res = Console.ReadLine();

                if (res.ToLower().Equals("n"))
                {
                    System.Environment.Exit(0);
                }

                GamePortMappingApplier applier = new GamePortMappingApplier(gamePortMapping);

                if (Mode == Mode.ADD)
                {
                    applier.AddRules(device);
                    Console.WriteLine("Les ports sont bien ajoutés, le système reste ouvert et va se relancer toutes les 500 secondes");
                    Console.WriteLine("CTRL+C pour quitter");
                }
                else
                {
                    applier.RemoveRules(device);
                    Environment.Exit(0);
                }
                break;

            case Mode.LISTPORT:
                var routerTable = device.GetAllMappings();
                foreach (Mapping m in routerTable)
                {
                    Console.WriteLine(m.ToString());
                }
                Environment.Exit(0);
                break;


            default:
                break;
            }
        }