mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 00:40:51 +01:00
allow option to block all packets
This commit is contained in:
parent
7ea507da98
commit
32fc9b8075
@ -92,12 +92,17 @@ public class BlockAndReplacePackets extends ExtensionForm {
|
||||
isValid = false;
|
||||
}
|
||||
else if (type.equals("Block packet")) {
|
||||
try {
|
||||
int v = Integer.parseInt(val);
|
||||
isValid = (v < (Short.MAX_VALUE * 2 + 2) && v > 0);
|
||||
if (val.equals("")) {
|
||||
isValid = true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
isValid = false;
|
||||
else {
|
||||
try {
|
||||
int v = Integer.parseInt(val);
|
||||
isValid = (v < (Short.MAX_VALUE * 2 + 2) && v > 0);
|
||||
}
|
||||
catch (Exception e) {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -20,7 +20,7 @@ public class BlockPacketRule extends BlockReplaceRule{
|
||||
if (side == Side.ALL
|
||||
|| (message.getDestination() == HMessage.Direction.TOSERVER && side == Side.OUTGOING)
|
||||
|| (message.getDestination() == HMessage.Direction.TOCLIENT && side ==Side.INCOMING)) {
|
||||
if (message.getPacket().headerId() == headerId) {
|
||||
if (headerId == -1 || message.getPacket().headerId() == headerId) {
|
||||
message.setBlocked(true);
|
||||
}
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class BlockPacketRule extends BlockReplaceRule{
|
||||
|
||||
@Override
|
||||
public String value() {
|
||||
return headerId+"";
|
||||
return headerId == -1 ? "ALL" : (headerId+"");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,11 @@ public class RuleFactory {
|
||||
BlockReplaceRule.Side rSide = BlockReplaceRule.Side.valueOf(side.toUpperCase());
|
||||
|
||||
if (rOption == BlockReplaceRule.Option.BLOCK) {
|
||||
return new BlockPacketRule(rSide, Integer.parseInt(value));
|
||||
return new BlockPacketRule(rSide,
|
||||
value.equals("") ?
|
||||
-1 : // block ALL headerIds if no headerId given
|
||||
Integer.parseInt(value)
|
||||
);
|
||||
}
|
||||
if (rOption == BlockReplaceRule.Option.REPLACE) {
|
||||
if (rType == BlockReplaceRule.Type.INTEGER) {
|
||||
|
Loading…
Reference in New Issue
Block a user