[GH-ISSUE #7] Firewall open port #4

Open
opened 2026-02-25 22:30:29 +03:00 by kerem · 3 comments
Owner

Originally created by @Tendoncs on GitHub (Dec 15, 2014).
Original GitHub issue: https://github.com/EslaMx7/ScreenTask/issues/7

New to the Git Stuff I will have to figure out how to make a new branch and update code there. But I found this bug. The software does not close the port it opens when it stops the server.

I created a DeleteFirewallRule

    private Task DeleteFirewallRule()
    {
        return Task.Run(() =>
        {
            string cmd = RunCMD("netsh advfirewall firewall show rule \"Screen Task\"");
            if (cmd.StartsWith("\r\nNo rules match the specified criteria."))
            {
            }
            else
            {
                cmd = RunCMD("netsh advfirewall firewall delete rule name=\"Screen Task\"");
                Log("Screen Task Rule was removed from your firewall");
            }
        });
    }

Added a call to it in the btnStartServer.Tag check.

        if (btnStartServer.Tag.ToString() != "start")
        {
            btnStartServer.Tag = "start";
            btnStartServer.Text = "Start Server";
            isWorking = false;
            isTakingScreenshots = false;
            Log("Server Stoped.");
            //Added
            await DeleteFirewallRule();
            return;
        }
Originally created by @Tendoncs on GitHub (Dec 15, 2014). Original GitHub issue: https://github.com/EslaMx7/ScreenTask/issues/7 New to the Git Stuff I will have to figure out how to make a new branch and update code there. But I found this bug. The software does not close the port it opens when it stops the server. I created a DeleteFirewallRule ``` private Task DeleteFirewallRule() { return Task.Run(() => { string cmd = RunCMD("netsh advfirewall firewall show rule \"Screen Task\""); if (cmd.StartsWith("\r\nNo rules match the specified criteria.")) { } else { cmd = RunCMD("netsh advfirewall firewall delete rule name=\"Screen Task\""); Log("Screen Task Rule was removed from your firewall"); } }); } ``` Added a call to it in the btnStartServer.Tag check. ``` if (btnStartServer.Tag.ToString() != "start") { btnStartServer.Tag = "start"; btnStartServer.Text = "Start Server"; isWorking = false; isTakingScreenshots = false; Log("Server Stoped."); //Added await DeleteFirewallRule(); return; } ```
Author
Owner

@Tendoncs commented on GitHub (Dec 15, 2014):

Also, added "Rule removed" to log window.

Also Added Remove Firewall rule to the application close

<!-- gh-comment-id:67039152 --> @Tendoncs commented on GitHub (Dec 15, 2014): Also, added "Rule removed" to log window. Also Added Remove Firewall rule to the application close
Author
Owner

@ElBedeawi commented on GitHub (Feb 26, 2022):

@Tendoncs a lot of users requires the port to stay open, but we can add an option to delete ports on exit.

<!-- gh-comment-id:1051863529 --> @ElBedeawi commented on GitHub (Feb 26, 2022): @Tendoncs a lot of users requires the port to stay open, but we can add an option to delete ports on exit.
Author
Owner

@mchampanis commented on GitHub (Nov 5, 2024):

fixed here: https://github.com/mchampanis/ScreenTask/releases/tag/1.3

<!-- gh-comment-id:2457915783 --> @mchampanis commented on GitHub (Nov 5, 2024): fixed here: https://github.com/mchampanis/ScreenTask/releases/tag/1.3
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ScreenTask#4
No description provided.