mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-11-10 05:03:35 +01:00
show address for display with onion or localhost
This commit is contained in:
parent
1647a582f5
commit
60c2c12a95
@ -191,7 +191,7 @@ public class PrivateNotificationManager implements MessageListener {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Throwable throwable) {
|
||||
String errorMessage = "Sending ping to " + peersNodeAddress.getHostNameForDisplay() +
|
||||
String errorMessage = "Sending ping to " + peersNodeAddress.getAddressForDisplay() +
|
||||
" failed. That is expected if the peer is offline.\n\tping=" + ping +
|
||||
".\n\tException=" + throwable.getMessage();
|
||||
log.info(errorMessage);
|
||||
|
@ -1233,7 +1233,7 @@ public abstract class DisputeView extends ActivatableView<VBox, Void> implements
|
||||
long accountAge = accountAgeWitnessService.getAccountAge(item.getBuyerPaymentAccountPayload(), contract.getBuyerPubKeyRing());
|
||||
String age = DisplayUtils.formatAccountAge(accountAge);
|
||||
String postFix = CurrencyUtil.isTraditionalCurrency(item.getContract().getOfferPayload().getCurrencyCode()) ? " / " + age : "";
|
||||
return buyerNodeAddress.getHostNameWithoutPostFix() + " (" + nrOfDisputes + postFix + ")";
|
||||
return buyerNodeAddress.getAddressForDisplay() + " (" + nrOfDisputes + postFix + ")";
|
||||
} else
|
||||
return Res.get("shared.na");
|
||||
} else {
|
||||
@ -1250,7 +1250,7 @@ public abstract class DisputeView extends ActivatableView<VBox, Void> implements
|
||||
long accountAge = accountAgeWitnessService.getAccountAge(item.getSellerPaymentAccountPayload(), contract.getSellerPubKeyRing());
|
||||
String age = DisplayUtils.formatAccountAge(accountAge);
|
||||
String postFix = CurrencyUtil.isTraditionalCurrency(item.getContract().getOfferPayload().getCurrencyCode()) ? " / " + age : "";
|
||||
return sellerNodeAddress.getHostNameWithoutPostFix() + " (" + nrOfDisputes + postFix + ")";
|
||||
return sellerNodeAddress.getAddressForDisplay() + " (" + nrOfDisputes + postFix + ")";
|
||||
} else
|
||||
return Res.get("shared.na");
|
||||
} else {
|
||||
@ -1470,7 +1470,7 @@ public abstract class DisputeView extends ActivatableView<VBox, Void> implements
|
||||
|
||||
private PeerInfoIconDispute createAvatar(Integer tableRowId, Dispute dispute, boolean isBuyer) {
|
||||
NodeAddress nodeAddress = isBuyer ? dispute.getContract().getBuyerNodeAddress() : dispute.getContract().getSellerNodeAddress();
|
||||
String key = tableRowId + nodeAddress.getHostNameWithoutPostFix() + (isBuyer ? "BUYER" : "SELLER");
|
||||
String key = tableRowId + nodeAddress.getAddressForDisplay() + (isBuyer ? "BUYER" : "SELLER");
|
||||
Long accountAge = isBuyer ?
|
||||
accountAgeWitnessService.getAccountAge(dispute.getBuyerPaymentAccountPayload(), dispute.getContract().getBuyerPubKeyRing()) :
|
||||
accountAgeWitnessService.getAccountAge(dispute.getSellerPaymentAccountPayload(), dispute.getContract().getSellerPubKeyRing());
|
||||
|
@ -96,7 +96,7 @@ public class FileTransferPart extends NetworkEnvelope implements ExtendedDataSiz
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileTransferPart{" +
|
||||
"\n senderNodeAddress='" + senderNodeAddress.getHostNameForDisplay() + '\'' +
|
||||
"\n senderNodeAddress='" + senderNodeAddress.getAddressForDisplay() + '\'' +
|
||||
",\n uid='" + uid + '\'' +
|
||||
",\n tradeId='" + tradeId + '\'' +
|
||||
",\n traderId='" + traderId + '\'' +
|
||||
|
@ -74,19 +74,27 @@ public final class NodeAddress implements PersistablePayload, NetworkPayload, Us
|
||||
return hostName + ":" + port;
|
||||
}
|
||||
|
||||
public String getHostNameWithoutPostFix() {
|
||||
public String getAddressForDisplay() {
|
||||
if (hostName.endsWith(".onion")) return getHostNameForDisplay();
|
||||
else return shortenAddressForDisplay(getFullAddress());
|
||||
}
|
||||
|
||||
private String getHostNameWithoutPostFix() {
|
||||
return hostName.replace(".onion", "");
|
||||
}
|
||||
|
||||
// tor v3 onions are too long to display for example in a table grid, so this convenience method
|
||||
// produces a display-friendly format which includes [first 7]..[last 7] characters.
|
||||
// tor v2 and localhost will be displayed in full, as they are 16 chars or fewer.
|
||||
public String getHostNameForDisplay() {
|
||||
String work = getHostNameWithoutPostFix();
|
||||
if (work.length() > 16) {
|
||||
return work.substring(0, 7) + ".." + work.substring(work.length() - 7);
|
||||
private String getHostNameForDisplay() {
|
||||
return shortenAddressForDisplay(getHostNameWithoutPostFix());
|
||||
}
|
||||
|
||||
private String shortenAddressForDisplay(String address) {
|
||||
if (address.length() > 16) {
|
||||
return address.substring(0, 7) + ".." + address.substring(address.length() - 7);
|
||||
}
|
||||
return work;
|
||||
return address;
|
||||
}
|
||||
|
||||
// We use just a few chars from the full address to blur the potential receiver for sent network_messages
|
||||
|
Loading…
Reference in New Issue
Block a user