Skip to content

hoangcoderr/FirewallPortManager

Repository files navigation

Firewall Port Manager

A Windows Forms application for managing Windows Firewall rules with an intuitive graphical interface.

πŸ“‹ Overview

Firewall Port Manager is a desktop application that provides an easy-to-use interface for managing Windows Firewall rules. It allows users to view, add, edit, and delete firewall rules without needing to use the command line or navigate through complex Windows settings.

✨ Features

  • Tabbed Interface: Separate tabs for Inbound and Outbound rules
  • Profile Filtering: Filter rules by Windows Firewall profiles (Domain, Private, Public)
  • Search & Filter: Search by port number or rule name, filter by action (Allow/Block)
  • Rule Management: Add, edit, delete, and refresh firewall rules
  • Modern UI: Clean, intuitive interface with color-coded buttons
  • Status Monitoring: Real-time firewall status display
  • Template Support: Pre-configured rule templates for common scenarios

πŸ–₯️ System Requirements

  • Operating System: Windows 7 or later
  • .NET Framework: 4.0 or higher
  • Privileges: Administrator rights required for firewall management
  • Screen Resolution: Minimum 1024x768 (optimized for low resolution screens)

πŸš€ Installation

Option 1: Download Release

  1. Go to the Releases page
  2. Download the latest FirewallPortManager.exe
  3. Run as Administrator

Option 2: Build from Source

  1. Clone the repository:
    git clone https://github.com/yourusername/FirewallPortManager.git
  2. Open FirewallPortManager.csproj in Visual Studio
  3. Build the solution (Ctrl+Shift+B)
  4. Run the executable from bin/Debug/ or bin/Release/

πŸ“– Usage

Starting the Application

  1. Right-click on FirewallPortManager.exe
  2. Select "Run as administrator"
  3. The main interface will open showing current firewall rules

Managing Rules

Adding a New Rule

  1. Click the Add Rule button (blue)
  2. Fill in the rule details:
    • Rule Name: Descriptive name for the rule
    • Port: Port number or range (e.g., 80, 8080-8090)
    • Protocol: TCP or UDP
    • Direction: Inbound or Outbound
    • Action: Allow or Block
    • Description: Optional description
  3. Click OK to save

Editing an Existing Rule

  1. Select a rule from the list
  2. Click the Edit Rule button (green)
  3. Modify the desired fields
  4. Click OK to save changes

Deleting a Rule

  1. Select a rule from the list
  2. Click the Delete Rule button (red)
  3. Confirm the deletion

Filtering and Search

  • Profile Filter: Use the dropdown to filter by firewall profile
  • Search: Type port number or rule name in the search box
  • Action Filter: Filter by Allow/Block actions
  • Clear: Reset all filters

πŸ—οΈ Project Structure

FirewallPortManager/
β”œβ”€β”€ Forms/
β”‚   β”œβ”€β”€ MainForm.cs              # Main application window
β”‚   β”œβ”€β”€ AddRuleForm.cs           # Add new rule dialog
β”‚   └── EditRuleForm.cs          # Edit existing rule dialog
β”œβ”€β”€ Models/
β”‚   β”œβ”€β”€ FirewallRule.cs          # Firewall rule data model
β”‚   └── RuleTemplate.cs          # Rule template model
β”œβ”€β”€ Services/
β”‚   β”œβ”€β”€ FirewallService.cs       # Windows Firewall API integration
β”‚   β”œβ”€β”€ FilterService.cs         # Rule filtering logic
β”‚   β”œβ”€β”€ ListViewService.cs       # ListView management
β”‚   β”œβ”€β”€ UIStateManager.cs        # UI state management
β”‚   β”œβ”€β”€ RuleBuilderService.cs    # Rule creation logic
β”‚   β”œβ”€β”€ RuleValidationService.cs # Input validation
β”‚   β”œβ”€β”€ RuleManagementService.cs # CRUD operations
β”‚   └── ConfigurationService.cs  # Application configuration
β”œβ”€β”€ Utils/
β”‚   β”œβ”€β”€ AdminHelper.cs           # Administrator privilege checks
β”‚   β”œβ”€β”€ Constants.cs             # Application constants
β”‚   └── PortHelper.cs            # Port validation utilities
β”œβ”€β”€ sample_rules.json            # Sample rule templates (JSON)
β”œβ”€β”€ sample_rules.xml             # Sample rule templates (XML)
└── logo.ico                     # Application icon

πŸ”§ Configuration

Rule Templates

The application supports rule templates in both JSON and XML formats:

JSON Format (sample_rules.json):

{
  "templates": [
    {
      "name": "Web Server (HTTP)",
      "port": "80",
      "protocol": "TCP",
      "direction": "Inbound",
      "action": "Allow",
      "description": "Allow HTTP traffic"
    }
  ]
}

XML Format (sample_rules.xml):

<RuleTemplates>
  <Template>
    <Name>Web Server (HTTP)</Name>
    <Port>80</Port>
    <Protocol>TCP</Protocol>
    <Direction>Inbound</Direction>
    <Action>Allow</Action>
    <Description>Allow HTTP traffic</Description>
  </Template>
</RuleTemplates>

πŸ› οΈ Development

Prerequisites

  • Visual Studio 2017 or later
  • .NET Framework 4.0 SDK
  • Windows SDK

Building

# Restore NuGet packages
dotnet restore

# Build the project
dotnet build

# Build for release
dotnet build --configuration Release

Dependencies

  • System.Windows.Forms: UI framework
  • vocaluxe.dependencies.netfwtypelib: Windows Firewall API access

πŸ”’ Security Considerations

  • Administrator Rights: Required for firewall rule management
  • UAC Prompt: Application will request elevation on startup
  • Firewall Access: Direct integration with Windows Firewall API
  • Input Validation: All user inputs are validated before processing

πŸ› Troubleshooting

Common Issues

"Access Denied" Error

  • Ensure the application is running as Administrator
  • Check Windows Firewall service is running

Rules Not Displaying

  • Verify Windows Firewall is enabled
  • Check firewall profile settings
  • Try refreshing the rule list

Build Errors

  • Ensure .NET Framework 4.0 is installed
  • Restore NuGet packages
  • Check RuntimeIdentifier configuration

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ž Support

🏷️ Version History

  • v1.0.0 - Initial release
    • Basic firewall rule management
    • Tabbed interface for Inbound/Outbound rules
    • Profile filtering and search functionality

πŸ™ Acknowledgments

  • Windows Firewall API documentation
  • .NET Framework community
  • Contributors and testers

⚠️ Important: This application requires administrator privileges to function properly. Always run as administrator when managing firewall rules.

About

A simple tool to manage Windows Firewall ports

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages