forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 230
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
Open
githubawn
wants to merge
5
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.
+317
−354
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0ec4675
refactor(network): Remove obsolete Refresh NAT button and INI state
githubawn 45476e9
greptile feedback and fix compile after rebase
githubawn 67e170e
really fix build now
githubawn 02fcd75
remove retry limit
githubawn 3ab259f
another grepfile round
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,8 @@ struct ManglerMessage { | |
| static const Int MAX_NUM_MANGLERS = 4; | ||
| static const UnsignedShort MANGLER_PORT = 4321; | ||
|
|
||
| static const UnsignedInt BEHAVIOR_DETECTION_WAIT_TIME = 6000; | ||
|
|
||
| class FirewallHelperClass { | ||
|
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. I suggest add a comment above this class explaining the new things it does now. |
||
|
|
||
| public: | ||
|
|
@@ -171,20 +173,19 @@ class FirewallHelperClass { | |
| FirewallHelperClass(); | ||
| virtual ~FirewallHelperClass(); | ||
| Bool detectFirewall(); | ||
| UnsignedShort getRawFirewallBehavior() {return((UnsignedShort)m_behavior);} | ||
| Short getSourcePortAllocationDelta(); | ||
| Int getFirewallHardness(FirewallBehaviorType behavior); | ||
| Int getFirewallRetries(FirewallBehaviorType behavior); | ||
| void detectFirewallBehavior(); | ||
| UnsignedShort getRawFirewallBehavior() const {return((UnsignedShort)m_behavior);} | ||
| Short getSourcePortAllocationDelta() const; | ||
| Int getFirewallHardness(FirewallBehaviorType behavior) const; | ||
| Int getFirewallRetries(FirewallBehaviorType behavior) const; | ||
| void setSourcePortPoolStart(Int port) {m_sourcePortPool = port;}; | ||
| Int getSourcePortPool() {return(m_sourcePortPool);}; | ||
| void readFirewallBehavior(); | ||
| Int getSourcePortPool() const {return(m_sourcePortPool);}; | ||
| void reset(); | ||
| Bool behaviorDetectionUpdate(); | ||
|
|
||
| FirewallBehaviorType getFirewallBehavior(); | ||
| void writeFirewallBehavior(); | ||
| FirewallBehaviorType getFirewallBehavior() const; | ||
|
|
||
| void flagNeedToRefresh(Bool flag); | ||
| Bool isBehaviorDetectionComplete() const {return(m_currentState == DETECTIONSTATE_DONE);} | ||
|
|
||
| static void getManglerName(Int manglerIndex, Char *nameBuf); | ||
| Bool sendToManglerFromPort(UnsignedInt address, UnsignedShort port, UnsignedShort packetID, Bool blitzme = FALSE); | ||
|
|
@@ -207,26 +208,23 @@ class FirewallHelperClass { | |
| /* | ||
| ** Behavior query functions. | ||
| */ | ||
| Bool isNAT() { | ||
| Bool isNAT() const { | ||
| if (m_behavior == FIREWALL_TYPE_UNKNOWN || (m_behavior & FIREWALL_TYPE_SIMPLE) != 0) { | ||
| return(FALSE); | ||
| } | ||
| return(TRUE); | ||
| }; | ||
|
|
||
| Bool isNAT(FirewallBehaviorType behavior) { | ||
| Bool isNAT(FirewallBehaviorType behavior) const { | ||
| if (behavior == FIREWALL_TYPE_UNKNOWN || (behavior & FIREWALL_TYPE_SIMPLE) != 0) { | ||
| return(FALSE); | ||
| } | ||
| return(TRUE); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| private: | ||
|
|
||
| Int getNATPortAllocationScheme(Int numPorts, UnsignedShort *originalPorts, UnsignedShort *mangledPorts, Bool &relativeDelta, Bool &looksGood); | ||
| void detectFirewallBehavior(/*Bool &canRecord*/); | ||
| Bool getReferencePort(); | ||
|
|
||
| SpareSocketStruct * findSpareSocketByPort(UnsignedShort port); | ||
|
|
@@ -239,21 +237,11 @@ class FirewallHelperClass { | |
| */ | ||
| FirewallBehaviorType m_behavior; | ||
|
|
||
| /* | ||
| ** How did the firewall behave the last time we ran the game. | ||
| */ | ||
| FirewallBehaviorType m_lastBehavior; | ||
|
|
||
| /* | ||
| ** What is the delta in our firewalls NAT port allocation scheme. | ||
| */ | ||
| Int m_sourcePortAllocationDelta; | ||
|
|
||
| /* | ||
| ** What was the delta the last time we ran? | ||
| */ | ||
| Int m_lastSourcePortAllocationDelta; | ||
|
|
||
| /* | ||
| ** Source ports used only to discover port allocation patterns. | ||
| ** Needs to be static so that previous communications with the manglers | ||
|
|
@@ -281,9 +269,11 @@ class FirewallHelperClass { | |
|
|
||
| Int m_numResponses; | ||
| Int m_currentTry; | ||
| UnsignedInt m_lastDetectionTime; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| extern FirewallHelperClass *TheFirewallHelper; | ||
| FirewallHelperClass * createFirewallHelper(); | ||
|
|
||
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.
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.
Is unused?