Skip to content

Commit

Permalink
add readme. set default value on error for override limit to global l…
Browse files Browse the repository at this point in the history
…imit
  • Loading branch information
voidstarr committed May 31, 2021
1 parent a463d64 commit fba5ce7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Altimeter

### [Discord](https://discord.gg/eeZbM9umBy)

Sponge API 7.3.x Plugin that limits the number of accounts that can connect from an IP address

##The gist
A list exists per IP, each list can hold up to X accounts and each account will be removed from the queue until the TTL expires.
If the list fills for that IP, no more accounts can be logged in from that IP.

## Definitions
* TTL: `Time to live`

## Commands
* `/altimeter`: lists sub commands
* `/altimeter clear [all|x.x.x.x]`: clear the all account list, or the account list associated with a given IP address (v4/v6)
* `/altimeter override x.x.x.x <limit>`: set account limit for `x.x.x.x` to `limit`

## Permissions
* `altimeter.override`
* `altimeter.clear.ip`
* `altimeter.clear.all`

## Configuration
```
altimeter {
# How many accounts from one IP can log in.
accountLimit=5
# How often accounts should be checked and cleared from IP lists.
checkInterval {
# DAYS, HOURS, MINUTES, or SECONDS
unit=MINUTES
value=5
}
# Override account limit for specific IPs
limitOverrides=[
{
ip="127.0.0.1"
limit=5
}
]
# How long after an account is added to the queue is it removed.
ttl {
# DAYS, HOURS, MINUTES, or SECONDS
unit=DAYS
value=30
}
}
```
5 changes: 3 additions & 2 deletions src/main/java/tv/voidstar/altimeter/AltimeterConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ public static void load() {
Altimeter.getLogger().info("load limit overrides data");
for (ConfigurationNode overrideNode : limitOverridesNode.getChildrenList()) {
String ip = overrideNode.getNode("ip").getString("in.va.li.d");
int limit = overrideNode.getNode("limit").getInt(accountLimit);
if (InetAddresses.isInetAddress(ip)) {
accountLimitOverrides.put(ip, overrideNode.getNode("limit").getInt(5));
Altimeter.getLogger().info("{} has {} account limit", ip, overrideNode.getNode("limit").getInt(5));
accountLimitOverrides.put(ip, limit);
Altimeter.getLogger().info("{} has {} account limit", ip, limit);
} else {
Altimeter.getLogger().error("Invalid IP in limitOverrides configuration {}", ip);
}
Expand Down

0 comments on commit fba5ce7

Please sign in to comment.