Validate TTL: it must always be more than zero and less than 28 days
This commit is contained in:
parent
95c9be4d1c
commit
f50d7445c1
@ -3,9 +3,8 @@ package ch.dissem.bitmessage.utils;
|
||||
import static ch.dissem.bitmessage.utils.UnixTime.DAY;
|
||||
|
||||
/**
|
||||
* Stores times to live for different object types. Usually this shouldn't be messed with,
|
||||
* but for tests it might be a good idea to reduce it to a minimum, and on mobile clients
|
||||
* you might want to optimize it as well.
|
||||
* Stores times to live in seconds for different object types. Usually this shouldn't be messed with, but for tests
|
||||
* it might be a good idea to reduce it to a minimum, and on mobile clients you might want to optimize it as well.
|
||||
*
|
||||
* @author Christian Basler
|
||||
*/
|
||||
@ -19,7 +18,7 @@ public class TTL {
|
||||
}
|
||||
|
||||
public static void msg(long msg) {
|
||||
TTL.msg = msg;
|
||||
TTL.msg = validate(msg);
|
||||
}
|
||||
|
||||
public static long getpubkey() {
|
||||
@ -27,7 +26,7 @@ public class TTL {
|
||||
}
|
||||
|
||||
public static void getpubkey(long getpubkey) {
|
||||
TTL.getpubkey = getpubkey;
|
||||
TTL.getpubkey = validate(getpubkey);
|
||||
}
|
||||
|
||||
public static long pubkey() {
|
||||
@ -35,6 +34,11 @@ public class TTL {
|
||||
}
|
||||
|
||||
public static void pubkey(long pubkey) {
|
||||
TTL.pubkey = pubkey;
|
||||
TTL.pubkey = validate(pubkey);
|
||||
}
|
||||
|
||||
private static long validate(long ttl) {
|
||||
if (ttl < 0 || ttl > 28 * DAY) throw new IllegalArgumentException("TTL must be between 1 and 28 days");
|
||||
return ttl;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user