Ejemplo n.º 1
0
wget_netrc_t *wget_netrc_get(const wget_netrc_db_t *netrc_db, const char *host)
{
	if (netrc_db) {
		wget_netrc_t netrc;

		// look for an exact match
		netrc.key = host;
		return wget_hashmap_get(netrc_db->machines, &netrc);
	}

	return NULL;
}
Ejemplo n.º 2
0
Archivo: ocsp.c Proyecto: kush789/wget2
int wget_ocsp_hostname_is_valid(const wget_ocsp_db_t *ocsp_db, const char *hostname)
{
	if (ocsp_db) {
		wget_ocsp_t ocsp, *ocspp;

		// look for an exact match
		ocsp.key = hostname;
		if ((ocspp = wget_hashmap_get(ocsp_db->hosts, &ocsp)) && ocspp->maxage >= time(NULL)) {
			return 1;
		}
	}

	return 0;
}
Ejemplo n.º 3
0
Archivo: ocsp.c Proyecto: kush789/wget2
int wget_ocsp_fingerprint_in_cache(const wget_ocsp_db_t *ocsp_db, const char *fingerprint, int *revoked)
{
	if (ocsp_db) {
		wget_ocsp_t ocsp, *ocspp;

		// look for an exact match
		ocsp.key = fingerprint;
		if ((ocspp = wget_hashmap_get(ocsp_db->fingerprints, &ocsp)) && ocspp->maxage >= time(NULL)) {
			if (revoked)
				*revoked = !ocspp->valid;
			return 1;
		}
	}

	return 0;
}
Ejemplo n.º 4
0
Archivo: ocsp.c Proyecto: kush789/wget2
void wget_ocsp_db_add_host(wget_ocsp_db_t *ocsp_db, wget_ocsp_t *ocsp)
{
	if (!ocsp)
		return;

	if (!ocsp_db) {
		wget_ocsp_free(ocsp);
		return;
	}

	wget_thread_mutex_lock(&ocsp_db->mutex);

	if (ocsp->maxage == 0) {
		if (wget_hashmap_remove(ocsp_db->hosts, ocsp))
			debug_printf("removed OCSP host %s\n", ocsp->key);
		wget_ocsp_free(ocsp);
	} else {
		wget_ocsp_t *old = wget_hashmap_get(ocsp_db->hosts, ocsp);

		if (old) {
			if (old->mtime < ocsp->mtime) {
				old->mtime = ocsp->mtime;
				old->maxage = ocsp->maxage;
				old->valid = ocsp->valid;
				debug_printf("update OCSP host %s (maxage=%ld)\n", old->key, old->maxage);
			}
			wget_ocsp_free(ocsp);
		} else {
			// key and value are the same to make wget_hashmap_get() return old 'ocsp'
			wget_hashmap_put_noalloc(ocsp_db->hosts, ocsp, ocsp);
			debug_printf("add OCSP host %s (maxage=%ld)\n", ocsp->key, ocsp->maxage);
			// no need to free anything here
		}
	}

	wget_thread_mutex_unlock(&ocsp_db->mutex);
}