Refuse to create a new mud with a bad clock
This commit is contained in:
7
mud.c
7
mud.c
@@ -249,7 +249,7 @@ mud_now(void)
|
|||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
now = (tv.tv_sec - MUD_EPOCH) * MUD_ONE_SEC + tv.tv_usec;
|
now = (tv.tv_sec - MUD_EPOCH) * MUD_ONE_SEC + tv.tv_usec;
|
||||||
#endif
|
#endif
|
||||||
return now & ((UINT64_C(1) << 48) - 1);
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t
|
static uint64_t
|
||||||
@@ -721,6 +721,11 @@ mud_keyx_init(struct mud *mud, uint64_t now)
|
|||||||
struct mud *
|
struct mud *
|
||||||
mud_create(int port, int v4, int v6, int aes, int mtu)
|
mud_create(int port, int v4, int v6, int aes, int mtu)
|
||||||
{
|
{
|
||||||
|
uint64_t now = mud_now();
|
||||||
|
|
||||||
|
if (now >> 48)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (sodium_init() == -1)
|
if (sodium_init() == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user