/** * Whether a compressed XOVER reply that doesn't inflate is the server's: the * range fetched raw twice (compared with a saved copy), and once uncompressed. * * node --env-file=.env --import=@poppinss/ts-exec tools/false_end.ts [saved.gz] */ import { readFileSync } from 'node:fs' import { unzipSync } from 'node:zlib' import { XoverClient } from '#lib/nntp/index' const [group, from, to, saved] = process.argv.slice(2) const env = process.env const connect = (compress: boolean) => XoverClient.connect({ host: env.NNTP_HOST!, port: Number(env.NNTP_PORT ?? 563), user: env.NNTP_USER, password: env.NNTP_PASSWORD, secure: (env.NNTP_SECURE ?? 'true') !== 'false', compress, timeoutMs: 120_000 }) const gz = await connect(true) await gz.group(group) for (let i = 0; i < 2; i++) { const raw = await gz.xoverRaw(Number(from), Number(to)) let inflates = 'inflates' try { unzipSync(raw) } catch (e: any) { inflates = `doesn't inflate (${e.message})` } const same = saved ? (Buffer.compare(raw, readFileSync(saved)) === 0 ? ', same bytes as saved' : ', differs from saved') : '' console.log(`compressed #${i + 1}: ${raw.length} bytes, ${inflates}${same}`) } gz.close() const plain = await connect(false) await plain.group(group) const lines = await plain.xover(Number(from), Number(to)) console.log(`plain: ${lines.length} overview lines`) plain.close()