Ejemplo n.º 1
0
        private void fixport_Click(object sender, EventArgs e)
        {
            UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
            IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;

            try
            {
                mappings.Add(Convert.ToInt32(VooblyNat), "UDP", Convert.ToInt32(VooblyNat), GetLocalIPAddress(), true, "Voobly-" + Environment.MachineName.ToString());
                ErrorClean = true;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                ErrorClean = true;
                MessageBox.Show("Already Port Forwarded!");
            }
            catch (SystemException)
            {
                ErrorClean = false;
                MessageBox.Show("Please Enable UPnP In Your Router! Then Try Again. \n If UPnP is Already Enabled That means that this functionality is broken in your router.");
            }
            finally
            {
                if (ErrorClean == true)
                {
                    checkport.Visible = true;
                    fixport.Visible   = false;
                }
            }
        }
Ejemplo n.º 2
0
 private void DrVoobly_Load(object sender, EventArgs e)
 {
     using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Voobly\Voobly", true))
     {
         if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Voobly\Voobly", "NATPort", null) != null)
         {
             string natport = key.GetValue("NATPort").ToString();
             VooblyNat       = natport;
             portlbl.Text    = VooblyNat + " (UDP)";
             portlbl.Enabled = true;
         }
         else
         {
             portlbl.Text = "Voobly Not Installed!";
         }
     }
     try
     {
         NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
         NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
         foreach (NATUPNPLib.IStaticPortMapping portMapping in mappings)
         {
             if (portMapping.Description.ToString() == "Voobly-" + Environment.MachineName.ToString() && portMapping.InternalClient.ToString() == GetLocalIPAddress() && portMapping.InternalPort.ToString() == VooblyNat)
             {
                 fixport.Visible   = false;
                 checkport.Visible = true;
             }
         }
     }
     catch (SystemException)
     {
     }
 }