Clear final M0 bugs on master (T-5 verified, T-12, T-15, T-17)

This commit is contained in:
Boki 2026-11-27 16:42:43 -05:00
parent ade0a3ef1d
commit 2ea7316af6
7 changed files with 148 additions and 17 deletions

View file

@ -114,7 +114,7 @@
"cachePrefix": "proxy:",
"ttl": 3600,
"webshare": {
"apiKey": "y8ay534rcbybdkk3evnzmt640xxfhy7252ce2t98",
"apiKey": "",
"apiUrl": "https://proxy.webshare.io/api/v2/"
}
},
@ -150,7 +150,7 @@
"name": "eod",
"enabled": false,
"priority": 4,
"apiKey": "657fe003583a32.85708911",
"apiKey": "",
"baseUrl": "https://eodhistoricaldata.com/api",
"tier": "free"
}

View file

@ -1,3 +1,4 @@
import { hostname as osHostname, networkInterfaces } from 'node:os';
import type { StockAppConfig } from './schemas';
export type StockServiceName = 'dataIngestion' | 'dataPipeline' | 'webApi' | 'orchestrator';
@ -532,9 +533,64 @@ function parseMongoTarget(uri?: string): ParsedMongoTarget {
};
}
function getLocalMachineHosts(): Set<string> {
const hosts = new Set<string>();
const rawHostname = osHostname().trim().toLowerCase().replace(/\.+$/, '');
if (rawHostname) {
hosts.add(rawHostname);
const shortName = rawHostname.split('.')[0];
if (shortName) {
hosts.add(shortName);
hosts.add(`${shortName}.local`);
}
}
const ifaces = networkInterfaces();
for (const entries of Object.values(ifaces)) {
if (!entries) {
continue;
}
for (const entry of entries) {
if (entry.address) {
const addr = entry.address.split('%')[0]?.trim().toLowerCase();
if (addr) {
hosts.add(addr);
}
}
}
}
return hosts;
}
function isLocalMachineHost(host?: string): boolean {
if (!host) {
return false;
}
if (isLoopbackHost(host)) {
return true;
}
const normalized = host
.trim()
.replace(/^\[|\]$/g, '')
.replace(/\.+$/, '')
.toLowerCase();
const localHosts = getLocalMachineHosts();
if (localHosts.has(normalized)) {
return true;
}
// Also normalize numeric/decimal IPv4 spellings (e.g. hex or leading-zero LAN IP)
const numericOctets = parseNumericIpv4Octets(normalized) ?? parseDecimalIpv4Octets(normalized);
if (numericOctets !== null) {
const dotted = numericOctets.join('.');
if (localHosts.has(dotted)) {
return true;
}
}
return false;
}
function isQaMongoTargetHosts(target: ParsedMongoTarget): boolean {
return target.hosts.some(
entry => isLoopbackHost(entry.host) && (entry.port === undefined || entry.port === 27017)
entry => isLocalMachineHost(entry.host) && (entry.port === undefined || entry.port === 27017)
);
}
@ -543,7 +599,7 @@ function isQaMongoTarget(uri: string | undefined): boolean {
}
function isQaPostgresTarget(pg: StockAppConfig['database']['postgres']): boolean {
return isLoopbackHost(pg.host) && pg.port === 5432 && pg.database === 'trading_bot';
return isLocalMachineHost(pg.host) && pg.port === 5432 && pg.database === 'trading_bot';
}
/**

View file

@ -1,5 +1,5 @@
export const EOD_CONFIG = {
// API configuration
API_BASE_URL: 'https://eodhd.com/api/',
API_TOKEN: '657fe003583a32.85708911',
API_TOKEN: process.env.EOD_API_KEY ?? '',
};