Skip to content

Commit 9623d7f

Browse files
committed
Enforce FriendsOnly lobby privacy during handshake
Adds host-side enforcement for LobbyPrivacy.FriendsOnly lobbies. Previously, non-friends could still connect and remain in the lobby, which is now fixed.
1 parent 0403bd2 commit 9623d7f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

engine/Sandbox.Engine/Systems/Networking/System/NetworkSystem.Handshake.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ Task On_Handshake_ClientInfo( UserInfo msg, Connection source, Guid msgId )
144144

145145
Log.Info( $"{msg.DisplayName} [{msg.SteamId}] is connecting" );
146146

147+
//
148+
// If the lobby is set to FriendsOnly,
149+
// only allow players who are Steam friends with the host.
150+
//
151+
if ( Config.Privacy == LobbyPrivacy.FriendsOnly && msg.SteamId != 0 )
152+
{
153+
var hostSteamId = Utility.Steam.SteamId;
154+
155+
// Host is always allowed
156+
if ( msg.SteamId != hostSteamId.Value && !new Friend( msg.SteamId ).IsFriend )
157+
{
158+
Log.Info( $"Kicked {msg.DisplayName} [{msg.SteamId}] - not friends with host [{hostSteamId}]" );
159+
source.Kick( "This lobby is Friends Only." );
160+
return Task.CompletedTask;
161+
}
162+
}
163+
164+
147165
var denialReason = "";
148166

149167
source.PreInfo = new ConnectionInfo( null )

0 commit comments

Comments
 (0)