Opened 8 years ago

Closed 8 years ago

Last modified 3 years ago

#3953 closed enhancement (fixed)

[PATCH] Network cleanup - IP address conversion

Reported by: elexis Owned by: elexis
Priority: Nice to Have Milestone: Alpha 21
Component: Network Keywords: patch
Cc: Patch:

Description (last modified by wraitii)

  • This patch was done because leper didn't like r17772 (#2854) converting the IP-address from a 32bit number to a string and then comparing that against 127.0.0.1. (I'm not convinced this is less elegant than the proposed patch changing the protocol). The function GetIPAddress() is thus deleted (might be introduced for other purposes later like showing IPs in the GUI). The other GetIPAddress() was introduced in r17217 (#3241) and has the same issue, can be removed in a follow-up patch.
  • Previously, the timeouts were disabled if the IP is 127.0.0.1. Now it is disabled only if the server and client are started from the same process, thus working better in some edgecases when clients for example connect via a reverse proxy and thus also had 127.0.0.1.
  • To avoid accessing globals the g_NetServer and g_NetClient from inside the others thread (thread safety), the client now needs to inform the server that it is running in the same process, which is now transmitted on authentication.
  • There are no security measures taken to prevent arbitrary clients from setting that disableTimeout flag to true, but could be implemented trivially by changing the boolean that is transmitted via network to a shared secret.
  • The compiler didn't want to consume a default argument for the ctor of CNetClient, thus changes all occurances where it is instantiated.
  • Notice m_HostGUID is only used to prevent the host client from kicking itself.

Attachments (2)

disable_timeouts_differently_v1.patch (13.2 KB ) - added by elexis 8 years ago.
disable_timeouts_differently_v2.patch (16.9 KB ) - added by elexis 8 years ago.
Renames the new variable to isLocalClient, replaces g_HostGUID and changes the other mentioned GetIPAddress function to not convert to string.

Download all attachments as: .zip

Change History (8)

by elexis, 8 years ago

Renames the new variable to isLocalClient, replaces g_HostGUID and changes the other mentioned GetIPAddress function to not convert to string.

comment:1 by elexis, 8 years ago

Cc: leper added

comment:2 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 18140:

Network cleanup, fixes #3953.

Don't compare for "127.0.0.1" to identify the host, but check for a new boolean flag that is set by the client, refs #2854.
Remove an unneeded IP address conversion from u32 to string, refs #3241.

comment:3 by elexis, 8 years ago

Cc: leper removed
Keywords: review removed

Big thanks to Philip for discussing thoroughly on 2016-05-01 which implementation is to be prefered. This patch wouldn't have been possible without him!

Thanks leper for the proposed improvements and reviewing this on 2016-05-04:

15:54 <@leper> elexis: Re #3953: Should we move the timeout disabling to some function? (or just define that function to nothing in case the used enet version doesn't support it?); IsLocalClient() can be const
15:55 <@leper> looks a lot better
15:55 <@leper> (can be committed with just the const fix, the other thing probably isn't needed, just something to think about)

Defining the function only if enet supports it would also mean that the if-directive would have to be placed in the header and the calls to that function as well, which is a bit meh IMO.

Did the const change and also reverted the removal of m_HostGUID from the previous patch, as clients can freely impersonate the localhost right now and thus would be able to become unkickable. (The host should remain unkickable as doing so would kill the game)

comment:4 by elexis, 8 years ago

In 18143:

Fix Windows build. Those includes in r18140 didn't resolve properly on Windows, refs #3953.

comment:5 by elexis, 8 years ago

Component: Core engineNetwork

(changed component to network)

comment:6 by wraitii, 3 years ago

Description: modified (diff)

See Phab:D3075 for a further step towards enabling these by making authentication use a shared secret.

Note: See TracTickets for help on using tickets.