#include "common.h"
#include "huge.h"
#include "share.h"
#include "gmsg.h"
#include "dmesh.h"
#include "verify_sha1.h"
#include "verify_tth.h"
#include "version.h"
#include "settings.h"
#include "spam.h"
#include "lib/atoms.h"
#include "lib/base32.h"
#include "lib/file.h"
#include "lib/header.h"
#include "lib/sha1.h"
#include "lib/tm.h"
#include "lib/urn.h"
#include "lib/walloc.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"
Data Structures | |
| struct | sha1_cache_entry |
| There's an in-core cache (the GHashTable sha1_cache), and a persistent copy (normally in ~/.gtk-gnutella/sha1_cache). More... | |
| struct | dump_cache_context |
Functions | |
| void | update_volatile_cache (struct sha1_cache_entry *item, filesize_t size, time_t mtime, const struct sha1 *sha1, const struct tth *tth) |
| Takes an in-memory cached entry, and update its content. | |
| void | add_volatile_cache_entry (const char *filename, filesize_t size, time_t mtime, const struct sha1 *sha1, const struct tth *tth, gboolean known_to_be_shared) |
| Add a new entry to the in-memory cache. | |
| void | cache_entry_print (FILE *f, const char *filename, const struct sha1 *sha1, const struct tth *tth, filesize_t size, time_t mtime) |
| void | add_persistent_cache_entry (const char *filename, filesize_t size, time_t mtime, const struct sha1 *sha1, const struct tth *tth) |
| Add an entry to the persistent cache. | |
| void | dump_cache_one_entry (gpointer unused_key, gpointer value, gpointer udata) |
| Dump one (in-memory) cache into the persistent cache. | |
| void | dump_cache (gboolean force) |
| Dump the whole in-memory cache onto disk. | |
| void | parse_and_append_cache_entry (char *line) |
| This function is used to read the disk cache into memory. | |
| void | sha1_read_cache (void) |
| Read the whole persistent cache into memory. | |
| gboolean | huge_update_hashes (struct shared_file *sf, const struct sha1 *sha1, const struct tth *tth) |
| Asynchronous computation of hash value. | |
| gboolean | huge_need_sha1 (struct shared_file *sf) |
| Get the next file waiting for its hash to be computed from the queue (actually a stack). | |
| gboolean | huge_verify_callback (const struct verify *ctx, enum verify_status status, void *user_data) |
| External interface. | |
| void | queue_shared_file_for_sha1_computation (struct shared_file *sf) |
| Put the shared file on the stack of the things to do. | |
| gboolean | cached_entry_up_to_date (const struct sha1_cache_entry *cache_entry, const struct shared_file *sf) |
| Check to see if an (in-memory) entry cache is up to date. | |
| gboolean | sha1_is_cached (const struct shared_file *sf) |
| External interface to check whether the sha1 for shared_file is known. | |
| gboolean | request_sha1 (struct shared_file *sf) |
| External interface to call for getting the hash for a shared_file. | |
| void | huge_init (void) |
| Call this function at the beginning. | |
| gboolean | cache_free_entry (gpointer unused_key, gpointer v, gpointer unused_udata) |
| Free SHA1 cache entry. | |
| void | huge_close (void) |
| Call this when servent is shutdown. | |
| gboolean | huge_improbable_sha1 (const gchar *buf, size_t len) |
| Test whether the SHA1 in its base32/binary form is improbable. | |
| gboolean | huge_sha1_extract32 (const gchar *buf, size_t len, struct sha1 *sha1, gconstpointer header) |
| Validate `len' bytes starting from `buf' as a proper base32 encoding of a SHA1 hash, and write decoded value in `sha1'. | |
| void | huge_collect_locations (const struct sha1 *sha1, header_t *header) |
| Parse the "X-Gnutella-Alternate-Location" header if present to learn about other sources for this file. | |
Variables | |
| GHashTable * | sha1_cache |
| gboolean | cache_dirty |
| cache_dirty means that in-core cache is different from the one on disk when TRUE. | |
| time_t | cache_dumped |
| const char | sha1_persistent_cache_file_header [] |
| Disk cache. | |
|
||||||||||||||||||||||||
|
Add an entry to the persistent cache.
|
|
||||||||||||||||||||||||||||
|
Add a new entry to the in-memory cache.
|
|
||||||||||||||||||||||||||||
|
|
|
||||||||||||||||
|
Free SHA1 cache entry.
|
|
||||||||||||
|
Check to see if an (in-memory) entry cache is up to date.
|
|
|
Dump the whole in-memory cache onto disk.
|
|
||||||||||||||||
|
Dump one (in-memory) cache into the persistent cache. This is a callback called by dump_cache to dump the whole in-memory cache onto disk. |
|
|
Call this when servent is shutdown.
|
|
||||||||||||
|
Parse the "X-Gnutella-Alternate-Location" header if present to learn about other sources for this file.
|
|
||||||||||||
|
Test whether the SHA1 in its base32/binary form is improbable. This is used to detect "urn:sha1:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" and things using the same pattern with other letters, as being rather improbable hashes. |
|
|
Call this function at the beginning.
|
|
|
Get the next file waiting for its hash to be computed from the queue (actually a stack).
|
|
||||||||||||||||||||
|
Validate `len' bytes starting from `buf' as a proper base32 encoding of a SHA1 hash, and write decoded value in `sha1'. Also make sure that the SHA1 is not an improbable value. `header' is the header of the packet where we found the SHA1, so that we may trace errors if needed. When `check_old' is true, check the encoding against an earlier version of the base32 alphabet.
|
|
||||||||||||||||
|
Asynchronous computation of hash value.
|
|
||||||||||||||||
|
External interface.
|
|
|
This function is used to read the disk cache into memory.
It must be passed one line from the cache (ending with ' |
|
|
Put the shared file on the stack of the things to do. Activate the timer if this wasn't done already. |
|
|
External interface to call for getting the hash for a shared_file.
|
|
|
External interface to check whether the sha1 for shared_file is known.
|
|
|
Read the whole persistent cache into memory.
|
|
||||||||||||||||||||||||
|
Takes an in-memory cached entry, and update its content.
|
|
|
cache_dirty means that in-core cache is different from the one on disk when TRUE.
|
|
|
|
|
|
|
|
|
Initial value: "#\n" "# gtk-gnutella SHA1 cache file.\n" "# This file is automatically generated.\n" "# Format is: URN<TAB>file_size<TAB>file_mtime<TAB>file_name\n" "# Comment lines start with a sharp (#)\n" "#\n" "\n"
|
1.3.9.1