NamingService, BFNS: Add API methods to lookup all reverse entries

Addressbook: Use new API methods to simplify delete-all code
i2ptunnel: Output full authentication line
HostTxtEntry: More tweaks for i2ptunnel
This commit is contained in:
zzz
2016-04-25 19:25:30 +00:00
parent 0ac83bd7c1
commit fc8b72768a
5 changed files with 125 additions and 49 deletions

View File

@ -574,40 +574,32 @@ public class Daemon {
}
}
// reverse lookup, delete all
// There's no NamingService API to get a list of all reverse
String rev;
String rev2 = null;
while ((rev = router.reverseLookup(pod)) != null) {
// prevent getting stuck from buggy NS
if (rev.equals(rev2))
break;
rev2 = rev;
// forward check in case hash collision or something
List<Destination> fwd = router.lookupAll(rev);
if (!fwd.contains(pod))
break; // can't go around again, fail
if (knownNames != null)
knownNames.remove(rev);
boolean success = router.remove(rev, pod);
if (success)
deleted++;
if (log != null) {
List<String> revs = router.reverseLookupAll(pod);
if (revs != null) {
for (String rev : revs) {
if (knownNames != null)
knownNames.remove(rev);
boolean success = router.remove(rev, pod);
if (success)
log.append("Removed: " + rev +
" as requested" +
". From: " + addressbook.getLocation());
else
log.append("Remove failed for: " + rev +
" as requested" +
". From: " + addressbook.getLocation());
}
// now update the published addressbook
if (published != null) {
if (publishedNS == null)
publishedNS = new SingleFileNamingService(I2PAppContext.getGlobalContext(), published.getAbsolutePath());
success = publishedNS.remove(rev, pod);
if (log != null && !success)
log.append("Remove from published address book " + published.getAbsolutePath() + " failed for " + rev);
deleted++;
if (log != null) {
if (success)
log.append("Removed: " + rev +
" as requested" +
". From: " + addressbook.getLocation());
else
log.append("Remove failed for: " + rev +
" as requested" +
". From: " + addressbook.getLocation());
}
// now update the published addressbook
if (published != null) {
if (publishedNS == null)
publishedNS = new SingleFileNamingService(I2PAppContext.getGlobalContext(), published.getAbsolutePath());
success = publishedNS.remove(rev, pod);
if (log != null && !success)
log.append("Remove from published address book " + published.getAbsolutePath() + " failed for " + rev);
}
}
}
} else {

View File

@ -128,7 +128,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
<label for="signature">
<%=intl._t("Authentication for adding host")%>
</label>
<textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.writeProps(out); %></textarea>
<textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.write(out); %></textarea>
</div>
</div>
<div id="tunnelAdvancedNetworking" class="panel">
@ -180,7 +180,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_CHANGENAME);
props.setProperty(HostTxtEntry.PROP_OLDNAME, oldname);
he.sign(spk);
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.writeProps(out); %></textarea>
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.write(out); %></textarea>
<span class="comment"><%=intl._t("This will change the name from {0} to {1}, using the same destination", oldname, name)%></span>
<%
} else {
@ -203,7 +203,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
props.setProperty(HostTxtEntry.PROP_ACTION, HostTxtEntry.ACTION_ADDNAME);
props.setProperty(HostTxtEntry.PROP_OLDNAME, oldname);
he.sign(spk);
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.writeProps(out); %></textarea>
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.write(out); %></textarea>
<span class="comment"><%=intl._t("This will add an alias {0} for {1}, using the same destination", name, oldname)%></span>
<%
} else {
@ -227,7 +227,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
props.setProperty(HostTxtEntry.PROP_OLDDEST, olddest);
he.signInner(spk2);
he.sign(spk);
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.writeProps(out); %></textarea>
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.write(out); %></textarea>
<span class="comment"><%=intl._t("This will change the destination for {0}", name)%></span>
<%
} else {
@ -252,7 +252,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
props.setProperty(HostTxtEntry.PROP_OLDDEST, olddest);
he.signInner(spk2);
he.sign(spk);
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.writeProps(out); %></textarea>
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.write(out); %></textarea>
<span class="comment"><%=intl._t("This will add an alternate destination for {0}", name)%></span>
<%
} else {
@ -278,7 +278,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
props.setProperty(HostTxtEntry.PROP_OLDDEST, olddest);
he.signInner(spk2);
he.sign(spk);
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.writeProps(out); %></textarea>
%><textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Copy and paste this to the registration site" wrap="off" spellcheck="false"><% he.write(out); %></textarea>
<span class="comment"><%=intl._t("This will add a subdomain {0} of {1}, with a different destination", name, oldname)%></span>
<%
} else {