Rename getOnionAddress() to getBaseUrl()

This can later include a version parameter as well.
This commit is contained in:
Torsten Grote
2022-02-17 14:18:07 -03:00
parent 653b744a02
commit 88c54ed3b0
7 changed files with 20 additions and 18 deletions

View File

@@ -60,7 +60,7 @@ class MailboxApiImpl implements MailboxApi {
throws IOException, ApiException {
if (!properties.isOwner()) throw new IllegalArgumentException();
Request request = getRequestBuilder(properties.getAuthToken())
.url(properties.getOnionAddress() + "/setup")
.url(properties.getBaseUrl() + "/setup")
.put(EMPTY_REQUEST)
.build();
OkHttpClient client = httpClientProvider.get();
@@ -108,7 +108,7 @@ class MailboxApiImpl implements MailboxApi {
public void deleteContact(MailboxProperties properties, ContactId contactId)
throws IOException, ApiException, TolerableFailureException {
if (!properties.isOwner()) throw new IllegalArgumentException();
String url = properties.getOnionAddress() + "/contacts/" +
String url = properties.getBaseUrl() + "/contacts/" +
contactId.getInt();
Request request = getRequestBuilder(properties.getAuthToken())
.delete()
@@ -212,7 +212,7 @@ class MailboxApiImpl implements MailboxApi {
String path = "/files/" + folderId + "/" + fileId;
Request request = getRequestBuilder(properties.getAuthToken())
.delete()
.url(properties.getOnionAddress() + path)
.url(properties.getBaseUrl() + path)
.build();
OkHttpClient client = httpClientProvider.get();
Response response = client.newCall(request).execute();
@@ -254,7 +254,7 @@ class MailboxApiImpl implements MailboxApi {
private Response sendGetRequest(MailboxProperties properties, String path)
throws IOException {
Request request = getRequestBuilder(properties.getAuthToken())
.url(properties.getOnionAddress() + path)
.url(properties.getBaseUrl() + path)
.build();
OkHttpClient client = httpClientProvider.get();
return client.newCall(request).execute();
@@ -263,7 +263,7 @@ class MailboxApiImpl implements MailboxApi {
private Response sendPostRequest(MailboxProperties properties, String path,
RequestBody body) throws IOException {
Request request = getRequestBuilder(properties.getAuthToken())
.url(properties.getOnionAddress() + path)
.url(properties.getBaseUrl() + path)
.post(body)
.build();
OkHttpClient client = httpClientProvider.get();

View File

@@ -110,7 +110,7 @@ class MailboxPairingTaskImpl implements MailboxPairingTask {
}
MailboxAuthToken ownerToken = api.setup(mailboxProperties);
MailboxProperties ownerProperties = new MailboxProperties(
mailboxProperties.getOnionAddress(), ownerToken, true);
mailboxProperties.getBaseUrl(), ownerToken, true);
db.transaction(false, txn -> mailboxSettingsManager
.setOwnMailboxProperties(txn, ownerProperties));
synchronized (lock) {
@@ -158,9 +158,10 @@ class MailboxPairingTaskImpl implements MailboxPairingTask {
LOG.info("QR code is valid");
byte[] onionPubKey = Arrays.copyOfRange(bytes, 1, 33);
String onionAddress = crypto.encodeOnionAddress(onionPubKey);
String baseUrl = "http://" + onionAddress + ".onion";
byte[] tokenBytes = Arrays.copyOfRange(bytes, 33, 65);
MailboxAuthToken setupToken = new MailboxAuthToken(tokenBytes);
return new MailboxProperties(onionAddress, setupToken, true);
return new MailboxProperties(baseUrl, setupToken, true);
}
}

View File

@@ -57,7 +57,7 @@ class MailboxSettingsManagerImpl implements MailboxSettingsManager {
public void setOwnMailboxProperties(Transaction txn, MailboxProperties p)
throws DbException {
Settings s = new Settings();
s.put(SETTINGS_KEY_ONION, p.getOnionAddress());
s.put(SETTINGS_KEY_ONION, p.getBaseUrl());
s.put(SETTINGS_KEY_TOKEN, p.getAuthToken().toString());
settingsManager.mergeSettings(txn, s, SETTINGS_NAMESPACE);
}