コード例 #1
0
ファイル: P2PVPNForm.cs プロジェクト: nagyist/P2PVpn
 private void btnFirewallRules_Click(object sender, EventArgs e)
 {
     lblFirewallRules.Text = "Repairing Filewall Rules...";
     WinFirewall.CreateFirewallRules();
     lblFirewallRules.Text = "Finished Repairing Filewall Rules";
     firewallTimer.Enabled = true;
 }
コード例 #2
0
        private void FwCheckButton_Click(object sender, EventArgs e)
        {
            switch (WinFirewall.IsFirewallEnabled())
            {
            case FirewallStatus.Enabled:
                MessageBox.Show("Windows firewall is enabled.", "Windows Firewall Check", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                break;

            case FirewallStatus.PrivateDisabled:
                MessageBox.Show("Private networks are disabled in windows firewall. This may not allow you to block connections successfully.", "Windows Firewall Check", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                break;

            case FirewallStatus.PublicDisabled:
                MessageBox.Show("Public networks are disabled in windows firewall. This may not allow you to block connections successfully.", "Windows Firewall Check", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                break;

            default:
                MessageBox.Show("Windows firewall is disabled. This will not allow you to block connections successfully.", "Windows Firewall Check", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                break;
            }
        }
コード例 #3
0
        private void BlockButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PortTextBox.Text) || string.IsNullOrEmpty(ProtocolTextBox.Text))
            {
                MessageBox.Show("Missing selection. Choose a result from the 'Find ports' section.", "Missing selection", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(ForeignIPTextBox.Text))
            {
                MessageBox.Show("A foreign IP is required. Use the 'Listen for remote connections' button if the protocol is UDP and choose one of the IP addresses that may appear over time.", "No foreign IP", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            FirewallStatus status = WinFirewall.IsFirewallEnabled();

            if (status == FirewallStatus.PrivateDisabled || status == FirewallStatus.PublicDisabled || status == FirewallStatus.AllDisabled)
            {
                MessageBox.Show("Your windows firewall is not fully enabled which may prevent blocks from being effective. Change your firewall settings through the control panel. Use the 'Firewall Status Check' button for more information.", "Windows Firewall Check", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            WinFirewall.AddFirewallRule(ProtocolTextBox.Text == "UDP" ? NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP : NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP, ForeignIPTextBox.Text, PortTextBox.Text, ProcessPathTextBox.Text);
        }
コード例 #4
0
 private void RemoveBlocksButton_Click(object sender, EventArgs e)
 {
     WinFirewall.RemoveAllRules();
 }