Server should only reply
This commit is contained in:
22
mud.c
22
mud.c
@@ -145,7 +145,6 @@ struct mud {
|
|||||||
struct crypto_key private, last, next, current;
|
struct crypto_key private, last, next, current;
|
||||||
int use_next;
|
int use_next;
|
||||||
int aes;
|
int aes;
|
||||||
int bad_key;
|
|
||||||
} crypto;
|
} crypto;
|
||||||
struct {
|
struct {
|
||||||
uint64_t send_time;
|
uint64_t send_time;
|
||||||
@@ -1041,28 +1040,27 @@ int mud_recv (struct mud *mud, void *data, size_t size)
|
|||||||
int ret = mud_decrypt(mud, data, size, packet, packet_size);
|
int ret = mud_decrypt(mud, data, size, packet, packet_size);
|
||||||
|
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
mud->crypto.bad_key = 1;
|
if ((!path->state.active) &&
|
||||||
|
(mud_timeout(now, mud->crypto.send_time, mud->send_timeout))) {
|
||||||
|
mud_ctrl_path(mud, mud_keyx, path, now);
|
||||||
|
mud->crypto.send_time = now;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mud_send_ctrl (struct mud *mud)
|
void mud_send_ctrl (struct mud *mud)
|
||||||
{
|
{
|
||||||
struct path *path;
|
struct path *path;
|
||||||
|
|
||||||
for (path = mud->path; path; path = path->next) {
|
for (path = mud->path; path; path = path->next) {
|
||||||
|
if (!path->state.active)
|
||||||
|
continue;
|
||||||
|
|
||||||
uint64_t now = mud_now(mud);
|
uint64_t now = mud_now(mud);
|
||||||
|
|
||||||
if (!path->state.active) {
|
|
||||||
if ((mud->crypto.bad_key) &&
|
|
||||||
(mud_timeout(now, mud->crypto.send_time, mud->send_timeout))) {
|
|
||||||
mud_ctrl_path(mud, mud_keyx, path, now);
|
|
||||||
mud->crypto.send_time = now;
|
|
||||||
mud->crypto.bad_key = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((mud_timeout(now, mud->crypto.send_time, mud->send_timeout)) &&
|
if ((mud_timeout(now, mud->crypto.send_time, mud->send_timeout)) &&
|
||||||
(mud_timeout(now, mud->crypto.recv_time, MUD_KEYX_TIMEOUT))) {
|
(mud_timeout(now, mud->crypto.recv_time, MUD_KEYX_TIMEOUT))) {
|
||||||
mud_ctrl_path(mud, mud_keyx, path, now);
|
mud_ctrl_path(mud, mud_keyx, path, now);
|
||||||
@@ -1088,8 +1086,6 @@ int mud_send_ctrl (struct mud *mud)
|
|||||||
mud_ctrl_path(mud, mud_ping, path, now);
|
mud_ctrl_path(mud, mud_ping, path, now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mud_send (struct mud *mud, const void *data, size_t size, int tc)
|
int mud_send (struct mud *mud, const void *data, size_t size, int tc)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user