Skip to content

Commit

Permalink
testing: block inbound
Browse files Browse the repository at this point in the history
was getting some disconnects, maybe this fixes it :c
  • Loading branch information
stowmyy committed Sep 1, 2024
1 parent 264059c commit 075187c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions dropship/src/FirewallManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

bool FirewallManager::AddFirewallRule(Endpoint* e, bool enabled)
{
return this->_windowsFirewall->add_rule(e, enabled, NET_FW_PROFILE2_ALL);
return this->_windowsFirewall->add_rule(e, NET_FW_RULE_DIR_OUT, enabled, NET_FW_PROFILE2_ALL)
&& this->_windowsFirewall->add_rule(e, NET_FW_RULE_DIR_IN, enabled, NET_FW_PROFILE2_ALL);
}


Expand Down Expand Up @@ -50,7 +51,8 @@ void FirewallManager::flushRules(std::vector<Endpoint>* endpoints)
printf("Adding rules..\n");
for (auto &e : *endpoints)
{
this->_windowsFirewall->add_rule(&e, false);
this->_windowsFirewall->add_rule(&e, NET_FW_RULE_DIR_OUT, false);
this->_windowsFirewall->add_rule(&e, NET_FW_RULE_DIR_IN, false);
}
printf("Added %d rules.\n", endpoints->size());

Expand Down
4 changes: 2 additions & 2 deletions dropship/src/_WindowsFirewallUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ class _WindowsFirewallUtil : public failable
}

// returns true if succeeded
bool add_rule(Endpoint* e, bool enabled = false, NET_FW_PROFILE_TYPE2_ profile = NET_FW_PROFILE2_ALL)
bool add_rule(Endpoint* e, NET_FW_RULE_DIRECTION_ dir, bool enabled = false, NET_FW_PROFILE_TYPE2_ profile = NET_FW_PROFILE2_ALL)
{
//BSTR bstrRuleName = SysAllocString(std::wstring(e.title.begin(), e.title.end()).c_str());
BSTR bstrRuleName = _com_util::ConvertStringToBSTR(e->title.c_str());
Expand All @@ -675,7 +675,7 @@ class _WindowsFirewallUtil : public failable
//pFwRule->put_ApplicationName(bstrRuleApplication);
pFwRule->put_Protocol(NET_FW_IP_PROTOCOL_ANY);
pFwRule->put_RemoteAddresses(bstrRuleRAddresses);
pFwRule->put_Direction(NET_FW_RULE_DIR_OUT);
pFwRule->put_Direction(dir);
pFwRule->put_Grouping(bstrRuleGroup);
pFwRule->put_Profiles(profile);
pFwRule->put_Action(NET_FW_ACTION_BLOCK);
Expand Down

0 comments on commit 075187c

Please sign in to comment.