Chore: more refactor to the bun

This commit is contained in:
SukkaW
2023-11-15 15:20:37 +08:00
parent 37257958c2
commit 071b8120a6
36 changed files with 200 additions and 250 deletions

View File

@@ -0,0 +1,23 @@
import { fetchRemoteTextAndCreateReadlineInterface } from './fetch-remote-text-by-line';
import tldts from 'tldts';
const isDomainLoose = (domain: string): boolean => {
const { isIcann, isPrivate, isIp } = tldts.parse(domain);
return !!(!isIp && (isIcann || isPrivate));
};
const parseFelixDnsmasq = async (url: string | URL): Promise<string[]> => {
const res: string[] = [];
for await (const line of await fetchRemoteTextAndCreateReadlineInterface(url)) {
if (line.startsWith('server=/') && line.endsWith('/114.114.114.114')) {
const domain = line.replace('server=/', '').replace('/114.114.114.114', '');
if (isDomainLoose(domain)) {
res.push(domain);
}
}
}
return res;
};
export { parseFelixDnsmasq };