mirror of
https://github.com/lax1dude/eaglercraft-motd.git
synced 2024-11-09 04:46:04 -08:00
Fixed ratelimit order to be FIFO
This commit is contained in:
parent
1fd47f074e
commit
05c903b0ed
BIN
EaglerMOTD.jar
BIN
EaglerMOTD.jar
Binary file not shown.
|
@ -340,10 +340,12 @@ public class EaglerMOTD extends Plugin implements Listener {
|
||||||
public void onMOTD(WebsocketMOTDEvent evt) {
|
public void onMOTD(WebsocketMOTDEvent evt) {
|
||||||
MOTDConnection con = new MOTDConnection(evt.getListener(), evt.getMOTD());
|
MOTDConnection con = new MOTDConnection(evt.getListener(), evt.getMOTD());
|
||||||
if(con.execute()) {
|
if(con.execute()) {
|
||||||
synchronized(motdConnections) {
|
if(max_total_sockets > 0) {
|
||||||
while(motdConnections.size() >= max_total_sockets) {
|
synchronized(motdConnections) {
|
||||||
MOTDConnection c = motdConnections.remove(0);
|
while(motdConnections.size() >= max_total_sockets) {
|
||||||
c.close();
|
MOTDConnection c = motdConnections.remove(motdConnections.size() - 1);
|
||||||
|
c.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InetAddress addr = con.motd.getRemoteAddress();
|
InetAddress addr = con.motd.getRemoteAddress();
|
||||||
|
@ -356,22 +358,24 @@ public class EaglerMOTD extends Plugin implements Listener {
|
||||||
}
|
}
|
||||||
if(flag) {
|
if(flag) {
|
||||||
synchronized(motdConnections) {
|
synchronized(motdConnections) {
|
||||||
motdConnections.add(con);
|
motdConnections.add(0, con);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if(allow_banned_ips || !BanList.checkIpBanned(addr).isBanned()) {
|
if(allow_banned_ips || !BanList.checkIpBanned(addr).isBanned()) {
|
||||||
synchronized(motdConnections) {
|
synchronized(motdConnections) {
|
||||||
int i = 0;
|
if(max_sockets_per_ip > 0) {
|
||||||
int c = 0;
|
int i = 0;
|
||||||
while(i < motdConnections.size()) {
|
int c = 0;
|
||||||
if(motdConnections.get(i).motd.getRemoteAddress().equals(addr)) {
|
while(i < motdConnections.size()) {
|
||||||
++c;
|
if(motdConnections.get(i).motd.getRemoteAddress().equals(addr)) {
|
||||||
if(c >= max_sockets_per_ip) {
|
++c;
|
||||||
motdConnections.remove(i).close();
|
if(c >= max_sockets_per_ip) {
|
||||||
--i;
|
motdConnections.remove(i).close();
|
||||||
|
--i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
motdConnections.add(0, con);
|
motdConnections.add(0, con);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: EaglerMOTD
|
name: EaglerMOTD
|
||||||
main: net.lax1dude.eaglercraft.eaglermotd.EaglerMOTD
|
main: net.lax1dude.eaglercraft.eaglermotd.EaglerMOTD
|
||||||
version: 1.0
|
version: 1.0.2
|
||||||
author: LAX1DUDE
|
author: LAX1DUDE
|
Loading…
Reference in New Issue
Block a user