Skip to content

Commit fcdbd8a

Browse files
committed
Make the maximum number of connections per IP address configurable in /lvp settings
1 parent 4e891f7 commit fcdbd8a

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

javascript/features/settings/pawn_config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Setting } from 'entities/setting.js';
66

77
// List of PawnConfig settings with their unique values and settings. Must be synced with Pawn. The
88
// settings can be in any category, of any type, as long as the identifier is a valid one.
9-
// Next ID: 18
9+
// Next ID: 19
1010
const kSynchronizedSettings = new Map([
1111
[ 'abuse/disable_out_of_range_damage', { id: 14 } ],
1212
[ 'abuse/fake_car_entry_prevention_enter_ms', { id: 11 } ],
@@ -18,6 +18,7 @@ const kSynchronizedSettings = new Map([
1818
[ 'abuse/kick_reason_public', { id: 6 } ],
1919
[ 'abuse/kill_attribution_time_sec', { id: 7 } ],
2020
[ 'abuse/manual_sawnoff_damage', { id: 13 } ],
21+
[ 'abuse/maximum_connections_per_ip', { id: 18 } ],
2122
[ 'vehicles/drifting_enabled', { id: 1 } ],
2223
[ 'vehicles/drifting_max_angle', { id: 2 } ],
2324
[ 'vehicles/drifting_max_distance', { id: 8 } ],

javascript/features/settings/setting_list.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pawn/Driver/PawnConfig.pwn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ new bool: g_abuseIgnoreSolePassengerDamage = true;
1616
new bool: g_abuseKickReasonsPublic = true;
1717
new g_abuseKillAttributionTimeSec = 10;
1818
new bool: g_abuseManualSawnoffDamage = false;
19+
new g_maximumConnectionsPerIP = 3;
1920

2021
// Section: drifting
2122
new bool: g_driftingEnabled = false;
@@ -30,7 +31,7 @@ new bool: g_vehicleKeysBlockedInLasVenturas = true;
3031

3132
// These are the unique Ids for each of the properties that can be updated. They must be identical
3233
// between the Pawn and the JavaScript code.
33-
// Next ID: 18
34+
// Next ID: 19
3435
enum PawnConfigProperty {
3536
kAbuseDisableOutOfRangeDamage = 14,
3637
kAbuseFakeCarEntryPreventionEnterMs = 11,
@@ -42,6 +43,7 @@ enum PawnConfigProperty {
4243
kAbuseKickReasonPublic = 6,
4344
kAbuseKillAttributionTimeSec = 7,
4445
kAbuseManualSawnoffDamage = 13,
46+
kAbuseMaximumConnectionsPerIP = 18,
4547
kVehiclesDriftingEnabled = 1,
4648
kVehiclesDriftingMaxAngle = 2,
4749
kVehiclesDriftingMaxDistance = 8,
@@ -116,3 +118,6 @@ public OnPawnConfigDataChange(PawnConfigProperty: property, Float: numberValue)
116118

117119
// Functions to allow legacy parts of the gamemode to access the values. Only when needed.
118120
AreKickReasonsPublic() { return g_abuseKickReasonsPublic ? 1 : 0; }
121+
122+
// Returns the maximum number of allowable connections per IP address.
123+
GetMaximumConnectionsPerIP() { return g_maximumConnectionsPerIP; }

pawn/Entities/Players/PlayerEvents.pwn

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
* @author Russell Krupke <russell@sa-mp.nl>
1111
*/
1212
class PlayerEvents <playerId (MAX_PLAYERS)> {
13-
// Maximum number of connections allowed from a single IP address.
14-
const MaxConnectionsPerIp = 3;
15-
1613
// Time in milliseconds between two timestamps of connections originating from the same IP address.
1714
const DefaultDelayConnection = 500;
1815

@@ -52,7 +49,7 @@ class PlayerEvents <playerId (MAX_PLAYERS)> {
5249
}
5350

5451
// Check if the maximum number of players ingame from the same IP has been reached.
55-
if (matchedPlayers >= MaxConnectionsPerIp) {
52+
if (matchedPlayers >= GetMaximumConnectionsPerIP()) {
5653
printf("Player [%d] shares IP with %d ingame players.", playerId, matchedPlayers);
5754
Kick(playerId); // deny player entry
5855
}

0 commit comments

Comments
 (0)