@ai-ecoverse/slicc-kernel 1.111.0 → 1.112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5295,7 +5295,7 @@ var KERNEL_VERSION, OS_RELEASE;
5295
5295
  var init_version = __esm({
5296
5296
  "src/version.ts"() {
5297
5297
  "use strict";
5298
- KERNEL_VERSION = true ? "1.111.0" : "0.0.0-dev";
5298
+ KERNEL_VERSION = true ? "1.112.0" : "0.0.0-dev";
5299
5299
  OS_RELEASE = "6.0.0-slicc";
5300
5300
  }
5301
5301
  });
package/dist/node.js CHANGED
@@ -6510,7 +6510,7 @@ function satisfies(version, range2) {
6510
6510
  }
6511
6511
 
6512
6512
  // src/version.ts
6513
- var KERNEL_VERSION = true ? "1.111.0" : "0.0.0-dev";
6513
+ var KERNEL_VERSION = true ? "1.112.0" : "0.0.0-dev";
6514
6514
  var OS_RELEASE = "6.0.0-slicc";
6515
6515
  function procVersion() {
6516
6516
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -14644,6 +14644,7 @@ var Resolver = class {
14644
14644
  own;
14645
14645
  cache = /* @__PURE__ */ new Map();
14646
14646
  pending = /* @__PURE__ */ new Map();
14647
+ hosts;
14647
14648
  constructor(options) {
14648
14649
  this.uplink = options.uplink;
14649
14650
  this.routes = options.routes;
@@ -14651,6 +14652,14 @@ var Resolver = class {
14651
14652
  this.timeoutMs = options.timeoutMs ?? RESOLVE_TIMEOUT_MS;
14652
14653
  this.log = options.log ?? ((message3) => console.warn(message3));
14653
14654
  this.own = ownNames(options.hostname ?? DEFAULT_HOSTNAME);
14655
+ this.hosts = options.hosts;
14656
+ }
14657
+ async fromFile(key, family) {
14658
+ const listed = (await this.hosts?.().catch(() => void 0))?.get(key);
14659
+ if (!listed) return void 0;
14660
+ const v4 = listed.filter((a) => ipv4Bytes(a) !== void 0);
14661
+ const v6 = listed.filter((a) => ipv4Bytes(a) === void 0);
14662
+ return family === 4 ? v4 : family === 6 ? v6 : [...v4, ...v6];
14654
14663
  }
14655
14664
  async resolve(name2, family, blocking) {
14656
14665
  const key = name2.toLowerCase().replace(/\.$/, "");
@@ -14659,6 +14668,8 @@ var Resolver = class {
14659
14668
  const v4 = family !== 6 && local ? [local] : [];
14660
14669
  return family === 4 ? v4 : [...v4, key];
14661
14670
  }
14671
+ const listed = this.hosts ? await this.fromFile(key, family) : void 0;
14672
+ if (listed?.length) return listed;
14662
14673
  if (local) {
14663
14674
  const six = loopbackName(key, this.own) ? ["::1"] : [];
14664
14675
  return family === 6 ? six : family === 4 ? [local] : [local, ...six];
@@ -19060,6 +19071,43 @@ var JobTable = class {
19060
19071
  }
19061
19072
  };
19062
19073
 
19074
+ // src/kernel/net/hosts-file.ts
19075
+ var HOSTS_PATH = "/etc/hosts";
19076
+ function parseHosts(text) {
19077
+ const table = /* @__PURE__ */ new Map();
19078
+ for (const raw of text.split("\n")) {
19079
+ const [address, ...names] = raw.replace(/#.*/, "").trim().split(/\s+/);
19080
+ if (!address || names.length === 0) continue;
19081
+ if (ipv4Bytes(address) === void 0 && ipv6Groups(address) === void 0) continue;
19082
+ for (const name2 of names) {
19083
+ const key = name2.toLowerCase().replace(/\.$/, "");
19084
+ const known = table.get(key) ?? [];
19085
+ if (!known.includes(address)) known.push(address);
19086
+ table.set(key, known);
19087
+ }
19088
+ }
19089
+ return table;
19090
+ }
19091
+ function hostsReader(fs, path = HOSTS_PATH) {
19092
+ let stamp = "";
19093
+ let table;
19094
+ return async () => {
19095
+ const st = await fs.stat(path).catch(() => void 0);
19096
+ if (!st?.isFile) {
19097
+ stamp = "";
19098
+ table = void 0;
19099
+ return void 0;
19100
+ }
19101
+ const now = `${st.ino}:${st.size}:${st.mtime.getTime()}`;
19102
+ if (now === stamp && table) return table;
19103
+ const text = await fs.readFile(path).catch(() => void 0);
19104
+ if (text === void 0) return void 0;
19105
+ stamp = now;
19106
+ table = parseHosts(text);
19107
+ return table;
19108
+ };
19109
+ }
19110
+
19063
19111
  // src/kernel/net/redirect-hops.ts
19064
19112
  var HELD_MS = 3e4;
19065
19113
  var HELD_MAX = 64;
@@ -22500,7 +22548,12 @@ var Launcher = class {
22500
22548
  this.uplink = options.uplink;
22501
22549
  this.routes = new Routes(options.uplink?.traits.ipv6 === true);
22502
22550
  if (options.uplink?.routes) this.routes.set(options.uplink.routes);
22503
- this.resolver = new Resolver({ uplink: options.uplink, routes: this.routes, hostname });
22551
+ this.resolver = new Resolver({
22552
+ uplink: options.uplink,
22553
+ routes: this.routes,
22554
+ hostname,
22555
+ hosts: hostsReader(this.base)
22556
+ });
22504
22557
  if (options.uplink) this.net.useUplink({ uplink: options.uplink, routes: this.routes });
22505
22558
  enableNetwork(this.net, {
22506
22559
  transport: this.transport,