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