> Date: Fri, 13 Aug 2004 15:58:30 +1200 (NZST)
> Message-ID: <1776.202.37.75.101.1092369510.squirrel@202.37.75.101> > From: adam@adambuckley.net > To: jrandom@i2p.net > > [...] > > I hereby authorize my NtpClient.java and NtpMessage.java code to be > redistributed under the BSD license for the purpose of integration with > the I2P project, providing that I am credited as the original author of > the code. > > [...] w00t! adam++ code migrated into core/java/src/net/i2p/time, integrated with Clock, dropping that whole ugly pass-the-time-through-URL, and hence dropped support for :7655/setTime. New router.config properties to control the timestamper: time.sntpServerList=pool.ntp.org,pool.ntp.org,pool.ntp.org time.queryFrequencyMs=300000 time.disabled=false So, to disable, add time.disabled=true to your router.config. It is enabled by default. Default router.config and startup scripts updated accordingly (since timestamper.jar is now gone)
This commit is contained in:
@ -6,10 +6,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
@ -58,13 +55,6 @@ class AdminRunner implements Runnable {
|
||||
}
|
||||
} else if (command.indexOf("/profile/") >= 0) {
|
||||
replyText(out, getProfile(command));
|
||||
} else if (command.indexOf("setTime") >= 0) {
|
||||
if (allowTimeUpdate(command)) {
|
||||
setTime(command);
|
||||
reply(out, "<html><body>Time updated</body></html>");
|
||||
} else {
|
||||
reply(out, "<html><body>Time not updated</body></html>");
|
||||
}
|
||||
} else if (command.indexOf("/shutdown") >= 0) {
|
||||
reply(out, shutdown(command));
|
||||
} else if (true || command.indexOf("routerConsole.html") > 0) {
|
||||
@ -80,25 +70,6 @@ class AdminRunner implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean allowTimeUpdate(String command) {
|
||||
String pass = _context.getProperty("adminTimePassphrase");
|
||||
if ( (pass == null) || (pass.trim().length() <= 0) ) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("No passphrase for update time from " + _socket.getInetAddress()
|
||||
+ ":" + _socket.getPort());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.indexOf(pass) != -1) {
|
||||
return true;
|
||||
} else {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Invalid passphrase for update time from " + _socket.getInetAddress()
|
||||
+ ":" + _socket.getPort());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void reply(OutputStream out, String content) throws IOException {
|
||||
StringBuffer reply = new StringBuffer(10240);
|
||||
reply.append("HTTP/1.1 200 OK\n");
|
||||
@ -152,33 +123,6 @@ class AdminRunner implements Runnable {
|
||||
return "No such peer is being profiled\n";
|
||||
}
|
||||
|
||||
|
||||
private static final String FORMAT_STRING = "yyyyMMdd_HH:mm:ss.SSS";
|
||||
private SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT_STRING, Locale.UK);
|
||||
|
||||
private long getTime(String now) throws ParseException {
|
||||
synchronized (_fmt) {
|
||||
return _fmt.parse(now).getTime();
|
||||
}
|
||||
}
|
||||
private void setTime(String cmd) {
|
||||
int start = cmd.indexOf("now=");
|
||||
String str = cmd.substring(start + 4, start+4+FORMAT_STRING.length());
|
||||
try {
|
||||
long now = getTime(str);
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.log(Log.INFO, "Admin time set to " + str);
|
||||
setTime(now);
|
||||
} catch (ParseException pe) {
|
||||
_log.error("Invalid time specified [" + str + "]", pe);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTime(long now) {
|
||||
_context.clock().setNow(now);
|
||||
}
|
||||
|
||||
|
||||
private static final String SHUTDOWN_PASSWORD_PROP = "router.shutdownPassword";
|
||||
private String shutdown(String cmd) {
|
||||
String password = _context.router().getConfigSetting(SHUTDOWN_PASSWORD_PROP);
|
||||
|
Reference in New Issue
Block a user