forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 229
feat(network): Self-healing NAT state #3010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
githubawn
wants to merge
6
commits into
TheSuperHackers:main
Choose a base branch
from
githubawn:refactor/remove-refresh-nat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8113c09
refactor(network): Remove obsolete Refresh NAT button and INI state
githubawn 0a4ada6
fix(network): Reset probe state and close spare sockets on firewall r…
githubawn fd146ae
fix(network): Preserve FirewallHelper lifetime across online menus an…
githubawn 6c50745
Updated after review feedback
githubawn 67eef47
update after greptile feedback
githubawn 802dd30
refactor(network): Put Refresh NAT button hiding behind ENABLE_GUI_HACKS
githubawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,14 +54,17 @@ | |
| #include "GameNetwork/NAT.h" | ||
| #include "GameNetwork/udp.h" | ||
| #include "GameNetwork/NetworkDefs.h" | ||
| #include "GameNetwork/IPEnumeration.h" | ||
| #include "GameNetwork/GameSpy/GSConfig.h" | ||
|
|
||
|
|
||
| FirewallHelperClass *TheFirewallHelper = nullptr; | ||
|
|
||
| FirewallHelperClass * createFirewallHelper() | ||
| { | ||
| return NEW FirewallHelperClass(); | ||
| FirewallHelperClass *helper = NEW FirewallHelperClass(); | ||
|
githubawn marked this conversation as resolved.
|
||
| helper->detectFirewallBehavior(); | ||
| return helper; | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -176,22 +179,12 @@ void FirewallHelperClass::reset() | |
| *=============================================================================================*/ | ||
| Bool FirewallHelperClass::detectFirewall() | ||
| { | ||
| OptionPreferences pref; | ||
|
|
||
| OptionPreferences::const_iterator it = pref.find("FirewallNeedToRefresh"); | ||
| if (it != pref.end()) { | ||
| AsciiString str = it->second; | ||
| if (str.compareNoCase("TRUE") == 0) { | ||
| TheWritableGlobalData->m_firewallBehavior = FIREWALL_TYPE_UNKNOWN; | ||
| } | ||
| } | ||
|
|
||
| if (TheWritableGlobalData->m_firewallBehavior == FIREWALL_TYPE_UNKNOWN) { | ||
| if (m_behavior == FIREWALL_TYPE_UNKNOWN) { | ||
| detectFirewallBehavior(); | ||
|
|
||
| return FALSE; | ||
| } else { | ||
| DEBUG_LOG(("FirewallHelperClass::detectFirewall - firewall behavior already specified as %d, port allocation delta is %d, skipping detection.", TheWritableGlobalData->m_firewallBehavior, TheWritableGlobalData->m_firewallPortAllocationDelta)); | ||
| DEBUG_LOG(("FirewallHelperClass::detectFirewall - firewall behavior already specified as %d, port allocation delta is %d, skipping detection.", m_behavior, m_sourcePortAllocationDelta)); | ||
| } | ||
|
|
||
| return TRUE; | ||
|
|
@@ -535,11 +528,9 @@ void FirewallHelperClass::writeFirewallBehavior() | |
| *=============================================================================================*/ | ||
| void FirewallHelperClass::flagNeedToRefresh(Bool flag) | ||
| { | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| OptionPreferences pref; | ||
|
|
||
| (pref)["FirewallNeedToRefresh"] = flag ? "TRUE" : "FALSE"; | ||
|
|
||
| pref.write(); | ||
| if (flag) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flag argument looks very useless. Can be removed. "Munkee" text above needs updating then. |
||
| detectFirewallBehavior(); | ||
| } | ||
| } | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
|
|
@@ -581,15 +572,21 @@ void FirewallHelperClass::readFirewallBehavior() | |
| * HISTORY: * | ||
| * 3/15/01 12:30PM ST : Created * | ||
| *=============================================================================================*/ | ||
| void FirewallHelperClass::detectFirewallBehavior(/*Bool &canRecord*/) | ||
| void FirewallHelperClass::detectFirewallBehavior() | ||
| { | ||
| m_behavior = FIREWALL_TYPE_SIMPLE; | ||
|
|
||
| reset(); | ||
| m_currentTry = 0; | ||
| m_numManglers = 0; | ||
| m_numResponses = 0; | ||
| m_packetID = 0; | ||
| m_timeoutLength = 0; | ||
| m_timeoutStart = 0; | ||
| m_sourcePortAllocationDelta = 0; | ||
| m_behavior = FIREWALL_TYPE_UNKNOWN; | ||
| m_currentState = DETECTIONSTATE_BEGIN; | ||
| } | ||
|
|
||
| FirewallHelperClass::FirewallBehaviorType FirewallHelperClass::getFirewallBehavior() { | ||
| m_currentState = DETECTIONSTATE_IDLE; | ||
| return m_behavior; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this class is not intended to set state elsewhere in the program. Can this be implemented differently to keep the focus of this class for writing options?