mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Favor nano time, because it's monotonic
This commit is contained in:
@ -70,7 +70,7 @@ public class AuthStorage {
|
|||||||
|
|
||||||
// adding paranoid hides hostname, username, version and so
|
// adding paranoid hides hostname, username, version and so
|
||||||
// could be useful for hiding server details
|
// could be useful for hiding server details
|
||||||
config.addDataSourceProperty("paranoid", "true");
|
config.addDataSourceProperty("paranoid", true);
|
||||||
|
|
||||||
// enable MySQL specific optimizations
|
// enable MySQL specific optimizations
|
||||||
// disabled by default - will return the same prepared statement instance
|
// disabled by default - will return the same prepared statement instance
|
||||||
|
@ -21,8 +21,8 @@ public class RateLimiter {
|
|||||||
* @return true if allowed
|
* @return true if allowed
|
||||||
*/
|
*/
|
||||||
public boolean tryAcquire() {
|
public boolean tryAcquire() {
|
||||||
// currentTime millis could be expensive on some systems
|
// current time millis is not monotonic - it can jump back depending on user choice or NTP
|
||||||
long now = System.currentTimeMillis();
|
long now = System.nanoTime() / 1_000_000;
|
||||||
|
|
||||||
// after this the request should be expired
|
// after this the request should be expired
|
||||||
long toBeExpired = now - expireTime;
|
long toBeExpired = now - expireTime;
|
||||||
|
Reference in New Issue
Block a user