diff --git a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java index ed772988b..0b5222aca 100644 --- a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java +++ b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java @@ -409,31 +409,17 @@ public class BlogManager { public String exportHosts(User user) { if (!user.getAuthenticated() || !user.getAllowAccessRemote()) return "Not authorized to export the hosts"; - 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 "Error exporting the hosts: " + ioe.getMessage() + ""; diff --git a/apps/syndie/jsp/addresses.jsp b/apps/syndie/jsp/addresses.jsp index c15249906..52a82cd68 100644 --- a/apps/syndie/jsp/addresses.jsp +++ b/apps/syndie/jsp/addresses.jsp @@ -190,7 +190,7 @@ if (!user.getAuthenticated()) {
- Export the eepsites to your router's userhosts.txt: + Export the eepsites to your router's petname db
diff --git a/core/java/src/net/i2p/client/naming/PetNameDB.java b/core/java/src/net/i2p/client/naming/PetNameDB.java index a1d91ea90..72038b101 100644 --- a/core/java/src/net/i2p/client/naming/PetNameDB.java +++ b/core/java/src/net/i2p/client/naming/PetNameDB.java @@ -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(); } diff --git a/history.txt b/history.txt index f252c24be..3e7b07b75 100644 --- a/history.txt +++ b/history.txt @@ -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.