* i2ptunnel:

- Better privkey backup file name
   - Revert increment of privkey tunnel name
   - Move deleted privkeys to backup dir
   - Fix jsp build dependencies
   - Fix layout issue on Chrome (ticket #757)
This commit is contained in:
zzz
2012-11-02 15:59:51 +00:00
parent eee38a626d
commit 9c220e08f8
5 changed files with 19 additions and 14 deletions

View File

@@ -179,6 +179,7 @@
<pathelement location="${ant.home}/lib/ant.jar" />
<pathelement location="build/i2ptunnel.jar" />
<pathelement location="build/temp-beans.jar" />
<pathelement location="../../../core/java/build/i2p.jar" />
</classpath>
<arg value="-d" />
<arg value="../jsp/WEB-INF/classes" />
@@ -202,6 +203,7 @@
<pathelement location="../../jetty/jettylib/jsp-api.jar" />
<pathelement location="build/i2ptunnel.jar" />
<pathelement location="build/temp-beans.jar" />
<pathelement location="../../../core/java/build/i2p.jar" />
</classpath>
</javac>
<copy file="../jsp/web.xml" tofile="../jsp/web-out.xml" />
@@ -213,6 +215,7 @@
<uptodate property="precompilejsp.uptodate" targetfile="../jsp/web-out.xml">
<srcfiles dir= "../jsp" includes="*.jsp, *.html, web.xml"/>
<srcfiles dir= "src/net/i2p/i2ptunnel/web" includes="*.java"/>
</uptodate>
<target name="javadoc">

View File

@@ -45,7 +45,7 @@ public class TunnelController implements Logging {
private boolean _running;
private boolean _starting;
private static final String KEY_BACKUP_DIR = "i2ptunnel-keyBackup";
public static final String KEY_BACKUP_DIR = "i2ptunnel-keyBackup";
/**
* Create a new controller for a tunnel out of the specific config options.
@@ -108,13 +108,11 @@ public class TunnelController implements Logging {
log("Private key created and saved in " + keyFile.getAbsolutePath());
log("You should backup this file in a secure place.");
log("New destination: " + destStr);
log("Base32: " + Base32.encode(dest.calculateHash().getData()) + ".b32.i2p");
String b32 = Base32.encode(dest.calculateHash().getData()) + ".b32.i2p";
log("Base32: " + b32);
File backupDir = new SecureFile(I2PAppContext.getGlobalContext().getConfigDir(), KEY_BACKUP_DIR);
if (backupDir.exists() || backupDir.mkdir()) {
String name = keyFile.getName();
if (name.endsWith(".dat"))
name = name.substring(0, name.length() - 4);
name += "-" + I2PAppContext.getGlobalContext().clock().now() + ".dat";
if (backupDir.isDirectory() || backupDir.mkdir()) {
String name = b32 + '-' + I2PAppContext.getGlobalContext().clock().now() + ".dat";
File backup = new File(backupDir, name);
if (FileUtil.copy(keyFile, backup, false, true))
log("Private key backup saved to " + backup.getAbsolutePath());

View File

@@ -79,7 +79,7 @@ public class EditBean extends IndexBean {
if (tun != null && tun.getPrivKeyFile() != null)
return tun.getPrivKeyFile();
if (tunnel < 0)
tunnel = _group == null ? 1 : _group.getControllers().size() + 1;
tunnel = _group == null ? 999 : _group.getControllers().size();
return "i2ptunnel" + tunnel + "-privKeys.dat";
}

View File

@@ -38,6 +38,7 @@ import net.i2p.util.ConcurrentHashSet;
import net.i2p.util.FileUtil;
import net.i2p.util.Log;
import net.i2p.util.PasswordManager;
import net.i2p.util.SecureFile;
/**
* Simple accessor for exposing tunnel info, but also an ugly form handler
@@ -373,10 +374,13 @@ public class IndexBean {
name = Long.toString(_context.clock().now());
}
}
name = "i2ptunnel-deleted-" + name.replace(' ', '_') + "-privkeys.dat";
File to = new File(_context.getConfigDir(), name);
if (to.exists())
to = new File(_context.getConfigDir(), name + '-' + _context.clock().now());
name = "i2ptunnel-deleted-" + name.replace(' ', '_') + '-' + _context.clock().now() + "-privkeys.dat";
File backupDir = new SecureFile(_context.getConfigDir(), TunnelController.KEY_BACKUP_DIR);
File to;
if (backupDir.isDirectory() || backupDir.mkdir())
to = new File(backupDir, name);
else
to = new File(_context.getConfigDir(), name);
boolean success = FileUtil.rename(pkf, to);
if (success)
msgs.add("Private key file " + pkf.getAbsolutePath() +