diff options
author | George Kadianakis <desnacked@riseup.net> | 2020-02-04 13:09:41 +0100 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2020-02-04 13:09:41 +0100 |
commit | 2a5e641cfe8f798c0cdb10f1a9d25b80f089dcce (patch) | |
tree | 2c7dc1f3e325165ad28afb5ac1054e97b207f4b5 /src/feature | |
parent | 6c749bf38ccf0ed9967482e1f0ca79b41ba7f9c7 (diff) | |
parent | 08f31e405d34fe47a8a4ae6e304058051c7818b6 (diff) | |
download | tor-2a5e641cfe8f798c0cdb10f1a9d25b80f089dcce.tar.gz tor-2a5e641cfe8f798c0cdb10f1a9d25b80f089dcce.zip |
Merge branch 'tor-github/pr/1704'
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/hs/hs_client.c | 22 | ||||
-rw-r--r-- | src/feature/hs/hs_client.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/feature/hs/hs_client.c b/src/feature/hs/hs_client.c index bcb0495c6f..611cc54302 100644 --- a/src/feature/hs/hs_client.c +++ b/src/feature/hs/hs_client.c @@ -1249,6 +1249,26 @@ can_client_refetch_desc(const ed25519_public_key_t *identity_pk, return 0; } +/** Purge the client authorization cache of all ephemeral entries that is the + * entries that are not flagged with CLIENT_AUTH_FLAG_IS_PERMANENT. + * + * This is called from the hs_client_purge_state() used by a SIGNEWNYM. */ +STATIC void +purge_ephemeral_client_auth(void) +{ + DIGEST256MAP_FOREACH_MODIFY(client_auths, key, + hs_client_service_authorization_t *, auth) { + /* Cleanup every entry that are _NOT_ permanent that is ephemeral. */ + if (!(auth->flags & CLIENT_AUTH_FLAG_IS_PERMANENT)) { + MAP_DEL_CURRENT(key); + client_service_authorization_free(auth); + } + } DIGESTMAP_FOREACH_END; + + log_info(LD_REND, "Client onion service ephemeral authorization " + "cache has been purged."); +} + /** Return the client auth in the map using the service identity public key. * Return NULL if it does not exist in the map. */ static hs_client_service_authorization_t * @@ -2433,6 +2453,8 @@ hs_client_purge_state(void) hs_cache_purge_as_client(); /* Purge the last hidden service request cache. */ hs_purge_last_hid_serv_requests(); + /* Purge ephemeral client authorization. */ + purge_ephemeral_client_auth(); log_info(LD_REND, "Hidden service client state has been purged."); } diff --git a/src/feature/hs/hs_client.h b/src/feature/hs/hs_client.h index 56b24a4119..3660bfa96c 100644 --- a/src/feature/hs/hs_client.h +++ b/src/feature/hs/hs_client.h @@ -162,6 +162,8 @@ MOCK_DECL(STATIC hs_client_fetch_status_t, STATIC void retry_all_socks_conn_waiting_for_desc(void); +STATIC void purge_ephemeral_client_auth(void); + #ifdef TOR_UNIT_TESTS STATIC void set_hs_client_auths_map(digest256map_t *map); |