Skip to content

Commit

Permalink
Add disableApi flag to filter
Browse files Browse the repository at this point in the history
  • Loading branch information
chimp1984 committed Jan 4, 2021
1 parent 6fc9ad4 commit 4bbc394
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
24 changes: 17 additions & 7 deletions core/src/main/java/bisq/core/filter/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {

// added at v1.5.5
private final Set<String> nodeAddressesBannedFromNetwork;
private final boolean disableApi;

// After we have created the signature from the filter data we clone it and apply the signature
static Filter cloneWithSig(Filter filter, String signatureAsBase64) {
Expand Down Expand Up @@ -122,7 +123,8 @@ static Filter cloneWithSig(Filter filter, String signatureAsBase64) {
filter.getBannedPrivilegedDevPubKeys(),
filter.isDisableAutoConf(),
filter.getBannedAutoConfExplorers(),
filter.getNodeAddressesBannedFromNetwork());
filter.getNodeAddressesBannedFromNetwork(),
filter.isDisableApi());
}

// Used for signature verification as we created the sig without the signatureAsBase64 field we set it to null again
Expand Down Expand Up @@ -152,7 +154,8 @@ static Filter cloneWithoutSig(Filter filter) {
filter.getBannedPrivilegedDevPubKeys(),
filter.isDisableAutoConf(),
filter.getBannedAutoConfExplorers(),
filter.getNodeAddressesBannedFromNetwork());
filter.getNodeAddressesBannedFromNetwork(),
filter.isDisableApi());
}

public Filter(List<String> bannedOfferIds,
Expand All @@ -177,7 +180,8 @@ public Filter(List<String> bannedOfferIds,
List<String> bannedPrivilegedDevPubKeys,
boolean disableAutoConf,
List<String> bannedAutoConfExplorers,
Set<String> nodeAddressesBannedFromNetwork) {
Set<String> nodeAddressesBannedFromNetwork,
boolean disableApi) {
this(bannedOfferIds,
nodeAddressesBannedFromTrading,
bannedPaymentAccounts,
Expand All @@ -203,7 +207,8 @@ public Filter(List<String> bannedOfferIds,
bannedPrivilegedDevPubKeys,
disableAutoConf,
bannedAutoConfExplorers,
nodeAddressesBannedFromNetwork);
nodeAddressesBannedFromNetwork,
disableApi);
}


Expand Down Expand Up @@ -237,7 +242,8 @@ public Filter(List<String> bannedOfferIds,
List<String> bannedPrivilegedDevPubKeys,
boolean disableAutoConf,
List<String> bannedAutoConfExplorers,
Set<String> nodeAddressesBannedFromNetwork) {
Set<String> nodeAddressesBannedFromNetwork,
boolean disableApi) {
this.bannedOfferIds = bannedOfferIds;
this.nodeAddressesBannedFromTrading = nodeAddressesBannedFromTrading;
this.bannedPaymentAccounts = bannedPaymentAccounts;
Expand All @@ -264,6 +270,7 @@ public Filter(List<String> bannedOfferIds,
this.disableAutoConf = disableAutoConf;
this.bannedAutoConfExplorers = bannedAutoConfExplorers;
this.nodeAddressesBannedFromNetwork = nodeAddressesBannedFromNetwork;
this.disableApi = disableApi;

// ownerPubKeyBytes can be null when called from tests
if (ownerPubKeyBytes != null) {
Expand Down Expand Up @@ -302,7 +309,8 @@ public protobuf.StoragePayload toProtoMessage() {
.addAllBannedPrivilegedDevPubKeys(bannedPrivilegedDevPubKeys)
.setDisableAutoConf(disableAutoConf)
.addAllBannedAutoConfExplorers(bannedAutoConfExplorers)
.addAllNodeAddressesBannedFromNetwork(nodeAddressesBannedFromNetwork);
.addAllNodeAddressesBannedFromNetwork(nodeAddressesBannedFromNetwork)
.setDisableApi(disableApi);

Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64);
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData);
Expand Down Expand Up @@ -341,7 +349,8 @@ public static Filter fromProto(protobuf.Filter proto) {
ProtoUtil.protocolStringListToList(proto.getBannedPrivilegedDevPubKeysList()),
proto.getDisableAutoConf(),
ProtoUtil.protocolStringListToList(proto.getBannedAutoConfExplorersList()),
ProtoUtil.protocolStringListToSet(proto.getNodeAddressesBannedFromNetworkList())
ProtoUtil.protocolStringListToSet(proto.getNodeAddressesBannedFromNetworkList()),
proto.getDisableApi()
);
}

Expand Down Expand Up @@ -385,6 +394,7 @@ public String toString() {
",\n ownerPubKey=" + ownerPubKey +
",\n disableAutoConf=" + disableAutoConf +
",\n nodeAddressesBannedFromNetwork=" + nodeAddressesBannedFromNetwork +
",\n disableApi=" + disableApi +
"\n}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ private void addContent() {
Res.get("filterWindow.bannedPrivilegedDevPubKeys")).second;
InputTextField autoConfExplorersTF = addTopLabelInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.autoConfExplorers")).second;
CheckBox disableApiCheckBox = addLabelCheckBox(gridPane, ++rowIndex,
Res.get("filterWindow.disableApi"));

Filter filter = filterManager.getDevFilter();
if (filter != null) {
Expand All @@ -194,6 +196,7 @@ private void addContent() {
disableAutoConfCheckBox.setSelected(filter.isDisableAutoConf());
disableDaoBelowVersionTF.setText(filter.getDisableDaoBelowVersion());
disableTradeBelowVersionTF.setText(filter.getDisableTradeBelowVersion());
disableApiCheckBox.setSelected(filter.isDisableApi());
}

Button removeFilterMessageButton = new AutoTooltipButton(Res.get("filterWindow.remove"));
Expand Down Expand Up @@ -227,7 +230,8 @@ private void addContent() {
readAsList(bannedPrivilegedDevPubKeysTF),
disableAutoConfCheckBox.isSelected(),
readAsList(autoConfExplorersTF),
new HashSet<>(readAsList(bannedFromNetworkTF))
new HashSet<>(readAsList(bannedFromNetworkTF)),
disableApiCheckBox.isSelected()
);

// We remove first the old filter
Expand Down
1 change: 1 addition & 0 deletions proto/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ message Filter {
bool disable_auto_conf = 24;
repeated string banned_auto_conf_explorers = 25;
repeated string node_addresses_banned_from_network = 26;
bool disable_api = 27;
}

// Deprecated
Expand Down

0 comments on commit 4bbc394

Please sign in to comment.