0
  3   íˆl–ßi~”jn-je@7q¦n2ò˜´oŽþZyg Óî2<û�ùò72ñÈï  H    í; configuration for php xml module
; priority=20
extension=xmlwriter.so
  M   ïˆl–äY>””ËmJi@·q§n	õ1hß�þBàp#�–‰^mÉ?Ÿó352òåa–ßi~” T¾R( 	ÅÍÆÚ¸”Å£ñ `    ï‹ Ãif Í’ÍN1…÷}Š³ÔM;~Æ¸ÀHŒF„ ÈÂ¸èL/Ð03�LÊÛ[	(+ÃÂÝ´iÏ=mÏýz¥7~­	‚w¸lÄÈì•¶òl²¦×¤D$¢&d7�Xvp%"!£áxÒ{žÄðKãvÕ¶È¶ÈŒó¦ðThÒP©7¶p×‡>–&]b®L\ôšà-t¹Z ¬l’Qî�«-
ë‘R›—yÒœ±™É²àë¼
³@©Ò•Z�«A:<<·Bô³ÍY·ÕÀêvmÜ
.œ>¾M‚ñ¼"ÒìæÄÁÞÆýÁðµ_Ãóp‚éKÿî=ü3Éu]Ó&V¹n…ˆ¸àÍzt�âb4ß÷/wÂÄ+—’·ƒôäëÙSH÷�EˆâÔÂ“ý{À0#½‡!ÚÃÐŽ›í8êž;ò†N‹‹ÿ¦á·ÅªJ—yb?÷nr)¸¨·Î¨Á_Bàî    A   ñˆl–Ãa¾”Ò~êq@µpLÜmõ1hß�þ[‘¬ã€�¹K‘È@?õ„yßô_ˆI|¥�+y,Àó ?÷     ñ/*
 * secure_dns_telemetry.h
 * Client Library for Secure DNS Telemetry (Corrected)
 * Features:
 * - Ciphertext Splitting: Splits >63 char payloads into multiple DNS labels
 * - Strict Memory Safety: No buffer overruns or unaligned access
 * - Direct UDP Connection: Validates Source IP/Port
 */

#pragma once

#include <stdint.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

#ifdef __cplusplus
extern "C" {
#endif

#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sodium.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>

/* --- CONFIGURATION --- */

/*
 * RUNTIME CONFIGURATION:
 * The telemetry system accepts host and key as runtime parameters.
 * No build-time configuration is required.
 *
 * Usage:
 *   telemetry_check(host, port, server_pk_b64, package, version)
 *
 * Generate server key:
 *   ./secure_dns_telemetry_gen_key server.key
 */

#define EDNS_PAYLOAD_SIZE  1232
#define DNS_LABEL_SIZE	   63
#define FIXED_PAYLOAD_SIZE 96

/*
 * More response JSON than fits into the TXT answer travels in an EDNS option
 * from the local/experimental range. The client asks for it by sending the
 * option empty; the answer announces it with a top-level "more":"opt".
 */
#define EDNS_MORE_OPTION   65001
#define MAX_MORE_JSON_SIZE 640

/* Default DNS port */
#ifndef TELEMETRY_DNS_PORT
#define TELEMETRY_DNS_PORT "53"
#endif

typedef struct {
	unsigned char pk[crypto_box_PUBLICKEYBYTES];
	unsigned char sk[crypto_box_SECRETKEYBYTES];
	unsigned char nonce[crypto_box_NONCEBYTES];
} session_ctx_t;

/* What the answer section asked us to report */
typedef struct {
	char severity[10]; /* Empty when there is nothing to report */
	int more;	   /* The answer announced more JSON */
	unsigned char nonce[crypto_box_NONCEBYTES]; /* Nonce of that answer */
} telemetry_alert_t;

/* --- HELPERS --- */

static inline uint16_t
read_u16(uint8_t **ptrp) {
	uint16_t val;
	memcpy(&val, *ptrp, sizeof(val));
	*ptrp += sizeof(val);
	return ntohs(val);
}

static inline uint32_t
read_u32(uint8_t **ptrp) {
	uint32_t val;
	memcpy(&val, *ptrp, sizeof(val));
	*ptrp += sizeof(val);
	return ntohl(val);
}

static inline void
write_u16(uint8_t **ptrp, uint16_t val) {
	uint16_t wire = htons(val);
	memcpy(*ptrp, &wire, sizeof(wire));
	*ptrp += sizeof(wire);
}

static inline void
write_u32(uint8_t **ptrp, uint32_t val) {
	uint32_t wire = htonl(val);
	memcpy(*ptrp, &wire, sizeof(wire));
	*ptrp += sizeof(wire);
}

static inline int
validate_package_name(const char *pkg) {
	if (!pkg || strlen(pkg) == 0 || strlen(pkg) > 63) {
		return -1;
	}
	for (const char *p = pkg; *p; p++) {
		/* Only allow alphanumeric, dash, dot, underscore */
		if (!isalnum((unsigned char)*p) && *p != '-' && *p != '.' &&
		    *p != '_') {
			return -1;
		}
	}
	return 0;
}

static inline void
sanitize_version(char *dest, const char *src, size_t dest_size) {
	const char *start = src;
	const char *colon = strchr(src, ':');
	if (colon) {
		start = colon + 1;
	}

	size_t i = 0;
	while (*start != '\0' && *start != '+' && *start != '~' &&
	       i < dest_size - 1) {
		dest[i++] = *start++;
	}
	dest[i] = '\0';
}

static inline int
append_dns_label(uint8_t **ptr, const uint8_t *end, const char *label,
		 size_t len) {
	if (len >