File Explorer

/var/runtime/node_modules/@aws-sdk/util-dns/dist-cjs/util

This explorer reads the filesystem of the server it runs on, so /workspace/user isn't present here. Browsing and the terminal still work against this server's own disk from /.

HostEntry.js5.0 KB · 126 lines
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.HostEntry = void 0;const types_1 = require("@aws-sdk/types");const HostAddressEntryCollection_1 = require("./HostAddressEntryCollection");class HostEntry {    aaaaRecords;    aRecords;    failedAaaaRecords;    failedARecords;    nextTimestampToUpdateMs;    constructor(nextTimestampToProcessMs) {        this.aaaaRecords = new HostAddressEntryCollection_1.HostAddressEntryCollection();        this.aRecords = new HostAddressEntryCollection_1.HostAddressEntryCollection();        this.failedAaaaRecords = new HostAddressEntryCollection_1.HostAddressEntryCollection();        this.failedARecords = new HostAddressEntryCollection_1.HostAddressEntryCollection();        this.nextTimestampToUpdateMs = nextTimestampToProcessMs;    }    updateRecords(addresses, expirationTtlMs) {        this.nextTimestampToUpdateMs = expirationTtlMs;        const addressesToAppend = [];        for (const freshAddress of addresses) {            const hostAddressEntry = this.findAddress(freshAddress);            if (hostAddressEntry !== undefined) {                hostAddressEntry.expirationTtlMs = expirationTtlMs;                continue;            }            addressesToAppend.push(freshAddress);        }        for (const addressToAppend of addressesToAppend) {            const hostAddressEntry = this.findAddress(addressToAppend);            if (hostAddressEntry !== undefined) {                continue;            }            const successRecords = this.getGoodRecords(addressToAppend);            successRecords.append(Object.assign(addressToAppend, {                expirationTtlMs,            }));        }    }    processRecords() {        this.processRecordsAddressType(this.aRecords, this.failedARecords);        this.processRecordsAddressType(this.aaaaRecords, this.failedAaaaRecords);    }    failAddressInRecords(address) {        const successRecords = this.getGoodRecords(address);        const failedRecords = this.getFailedRecords(address);        const recordsToRemove = [];        for (const hostAddressEntry of successRecords) {            if (hostAddressEntry.address === address.address) {                recordsToRemove.push(hostAddressEntry);                failedRecords.append(hostAddressEntry);            }        }        for (const recordToRemove of recordsToRemove) {            successRecords.remove(recordToRemove);        }    }    findAddress(address) {        const successRecords = this.getGoodRecords(address);        for (const hostAddressEntry of successRecords) {            if (address.address === hostAddressEntry.address) {                return hostAddressEntry;            }        }        const failedRecords = this.getFailedRecords(address);        for (const hostAddressEntry of failedRecords) {            if (address.address === hostAddressEntry.address) {                return hostAddressEntry;            }        }        return undefined;    }    processRecordsAddressType(successRecords, failedRecords) {        const successRecordsToRemove = [];        let successIndex = 0;        for (const hostAddressEntry of successRecords) {            if (successIndex === successRecords.length - 1) {                break;            }            if (Date.now() >= hostAddressEntry.expirationTtlMs) {                successRecordsToRemove.push(hostAddressEntry);            }            successIndex++;        }        for (const recordToRemove of successRecordsToRemove) {            successRecords.remove(recordToRemove);        }        const failedRecordsToRemove = [];        let failedIndex = 0;        for (const hostAddressEntry of failedRecords) {            if (failedIndex === failedRecords.length - 1) {                break;            }            if (Date.now() >= hostAddressEntry.expirationTtlMs) {                failedRecordsToRemove.push(hostAddressEntry);            }            failedIndex++;        }        for (const recordToRemove of failedRecordsToRemove) {            failedRecords.remove(recordToRemove);        }        if (successRecords.length === 0) {            let hostAddressEntryToPromote = undefined;            for (const hostAddressEntry of failedRecords) {                if (Date.now() >= hostAddressEntry.expirationTtlMs) {                    continue;                }                hostAddressEntryToPromote = hostAddressEntry;                break;            }            if (hostAddressEntryToPromote !== undefined) {                failedRecords.remove(hostAddressEntryToPromote);                successRecords.append(hostAddressEntryToPromote);            }        }    }    getGoodRecords(address) {        return address.addressType === types_1.HostAddressType.AAAA ? this.aaaaRecords : this.aRecords;    }    getFailedRecords(address) {        return address.addressType === types_1.HostAddressType.AAAA ? this.failedAaaaRecords : this.failedARecords;    }}exports.HostEntry = HostEntry;