* Export petnames from syndie to the router's petname db instead of userhosts.txt.
This commit is contained in:
@ -409,31 +409,17 @@ public class BlogManager {
|
||||
public String exportHosts(User user) {
|
||||
if (!user.getAuthenticated() || !user.getAllowAccessRemote())
|
||||
return "<span class=\"b_addrMsgErr\">Not authorized to export the hosts</span>";
|
||||
Map newNames = new HashMap();
|
||||
PetNameDB db = user.getPetNameDB();
|
||||
for (Iterator names = db.getNames().iterator(); names.hasNext(); ) {
|
||||
PetName pn = db.get((String)names.next());
|
||||
if (pn == null) continue;
|
||||
if (pn.getNetwork().equalsIgnoreCase("i2p")) {
|
||||
try {
|
||||
Destination d = new Destination(pn.getLocation().trim());
|
||||
newNames.put(pn.getName(), d);
|
||||
} catch (DataFormatException dfe) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
PetNameDB userDb = user.getPetNameDB();
|
||||
PetNameDB routerDb = _context.petnameDb();
|
||||
// horribly inefficient...
|
||||
for (Iterator iter = newNames.keySet().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
Destination existing = _context.namingService().lookup(name);
|
||||
if (existing == null) {
|
||||
Destination known = (Destination)newNames.get(name);
|
||||
for (Iterator names = userDb.getNames().iterator(); names.hasNext();) {
|
||||
PetName pn = userDb.get((String)names.next());
|
||||
if (pn == null) continue;
|
||||
Destination existing = _context.namingService().lookup(pn.getName());
|
||||
if (existing == null && pn.getNetwork().equalsIgnoreCase("i2p")) {
|
||||
routerDb.set(pn.getName(), pn);
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream("userhosts.txt", true);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
|
||||
osw.write(name + "=" + known.toBase64() + "\n");
|
||||
osw.close();
|
||||
routerDb.store();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
return "<span class=\"b_addrMsgErr\">Error exporting the hosts: " + ioe.getMessage() + "</span>";
|
||||
|
@ -190,7 +190,7 @@ if (!user.getAuthenticated()) {
|
||||
</form></tr>
|
||||
<tr class="b_addrExport"><form action="addresses.jsp" method="POST">
|
||||
<td class="b_addrExport" colspan="7">
|
||||
<span class="b_addrExport">Export the eepsites to your router's userhosts.txt:</span>
|
||||
<span class="b_addrExport">Export the eepsites to your router's petname db</span>
|
||||
<input class="b_addrExportSubmit" type="submit" name="action" value="Export" /></td>
|
||||
</form></tr>
|
||||
</table>
|
||||
|
@ -45,6 +45,7 @@ public class PetNameDB {
|
||||
}
|
||||
|
||||
public void load(String location) throws IOException {
|
||||
_path = location;
|
||||
File f = new File(location);
|
||||
if (!f.exists()) return;
|
||||
BufferedReader in = null;
|
||||
@ -56,7 +57,6 @@ public class PetNameDB {
|
||||
if (name.getName() != null)
|
||||
_names.put(name.getName(), name);
|
||||
}
|
||||
_path = location;
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
$Id: history.txt,v 1.270 2005/09/29 14:19:23 jrandom Exp $
|
||||
|
||||
2005-09-29 ragnarok
|
||||
* Export petnames from syndie to the router's petname db instead of
|
||||
userhosts.txt.
|
||||
|
||||
2005-09-29 jrandom
|
||||
* Support noreseed.i2p in addition to .i2pnoreseed for disabling automatic
|
||||
reseeding - useful on OSes that make it hard to create dot files.
|
||||
|
Reference in New Issue
Block a user