nts: load cookies early
Instead of waiting for the first request, try to load the cookies as soon as the instance is created, or the NTS address is changed. This enables loading of dump files for servers that are negotiated in NTS-KE.
This commit is contained in:
parent
c1d56ede3f
commit
e297df78e4
1 changed files with 5 additions and 8 deletions
|
@ -60,7 +60,6 @@ struct NNC_Instance_Record {
|
|||
NKC_Instance nke;
|
||||
SIV_Instance siv;
|
||||
|
||||
int load_attempt;
|
||||
int nke_attempts;
|
||||
double next_nke_attempt;
|
||||
double last_nke_success;
|
||||
|
@ -94,7 +93,6 @@ reset_instance(NNC_Instance inst)
|
|||
SIV_DestroyInstance(inst->siv);
|
||||
inst->siv = NULL;
|
||||
|
||||
inst->load_attempt = 0;
|
||||
inst->nke_attempts = 0;
|
||||
inst->next_nke_attempt = 0.0;
|
||||
inst->last_nke_success = 0.0;
|
||||
|
@ -129,6 +127,9 @@ NNC_CreateInstance(IPSockAddr *nts_address, const char *name, uint16_t ntp_port)
|
|||
|
||||
reset_instance(inst);
|
||||
|
||||
/* Try to reload saved keys and cookies */
|
||||
load_cookies(inst);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
@ -288,12 +289,6 @@ NNC_PrepareForAuth(NNC_Instance inst)
|
|||
UTI_GetRandomBytes(inst->uniq_id, sizeof (inst->uniq_id));
|
||||
UTI_GetRandomBytes(inst->nonce, sizeof (inst->nonce));
|
||||
|
||||
/* Try to reload saved keys and cookies (once for the NTS-KE address) */
|
||||
if (!inst->load_attempt) {
|
||||
load_cookies(inst);
|
||||
inst->load_attempt = 1;
|
||||
}
|
||||
|
||||
/* Get new cookies if there are not any, or they are no longer usable */
|
||||
if (!check_cookies(inst)) {
|
||||
if (!get_cookies(inst))
|
||||
|
@ -529,6 +524,8 @@ NNC_ChangeAddress(NNC_Instance inst, IPAddr *address)
|
|||
reset_instance(inst);
|
||||
|
||||
DEBUG_LOG("NTS reset");
|
||||
|
||||
load_cookies(inst);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
|
Loading…
Reference in a new issue