pmcf 4.25.16 → 4.25.18
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.
- package/package.json +1 -1
- package/src/base.mjs +11 -21
- package/src/initialization-context.mjs +2 -2
- package/src/network-interfaces/ethernet.mjs +7 -10
- package/src/network-interfaces/loopback.mjs +4 -4
- package/src/network-interfaces/network-interface.mjs +15 -17
- package/src/network-interfaces/tun.mjs +3 -4
- package/src/network-interfaces/wireguard.mjs +4 -4
- package/src/network-interfaces/wlan.mjs +3 -5
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -55,7 +55,7 @@ export class Base {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
static get typeName() {
|
|
58
|
-
return this.
|
|
58
|
+
return this.name;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
static get typeFileName() {
|
|
@@ -213,7 +213,7 @@ export class Base {
|
|
|
213
213
|
|
|
214
214
|
get typeName() {
|
|
215
215
|
// @ts-ignore
|
|
216
|
-
return this.constructor.
|
|
216
|
+
return this.constructor.name;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**
|
|
@@ -236,15 +236,8 @@ export class Base {
|
|
|
236
236
|
* @return {Iterable<[string,any]>} values
|
|
237
237
|
*/
|
|
238
238
|
*attributeIterator(filter) {
|
|
239
|
-
for (
|
|
240
|
-
|
|
241
|
-
typeDefinition;
|
|
242
|
-
typeDefinition = typeDefinition.extends
|
|
243
|
-
) {
|
|
244
|
-
for (const [path, def] of attributeIterator(
|
|
245
|
-
typeDefinition.attributes,
|
|
246
|
-
filter
|
|
247
|
-
)) {
|
|
239
|
+
for (let type = this.constructor; type; type = type.extends) {
|
|
240
|
+
for (const [path, def] of attributeIterator(type.attributes, filter)) {
|
|
248
241
|
const name = path.join(".");
|
|
249
242
|
const value = this.attribute(name);
|
|
250
243
|
|
|
@@ -545,14 +538,11 @@ export class Base {
|
|
|
545
538
|
}
|
|
546
539
|
|
|
547
540
|
toJSON() {
|
|
548
|
-
return extractFrom(this, this.constructor
|
|
541
|
+
return extractFrom(this, this.constructor);
|
|
549
542
|
}
|
|
550
543
|
}
|
|
551
544
|
|
|
552
|
-
export function extractFrom(
|
|
553
|
-
object,
|
|
554
|
-
typeDefinition = object?.constructor?.typeDefinition
|
|
555
|
-
) {
|
|
545
|
+
export function extractFrom(object, type = object?.constructor) {
|
|
556
546
|
switch (typeof object) {
|
|
557
547
|
case "undefined":
|
|
558
548
|
case "string":
|
|
@@ -572,12 +562,12 @@ export function extractFrom(
|
|
|
572
562
|
return undefined;
|
|
573
563
|
}
|
|
574
564
|
|
|
575
|
-
if (
|
|
565
|
+
if (type?.key) {
|
|
576
566
|
return Object.fromEntries(
|
|
577
567
|
object.map(o => {
|
|
578
568
|
o = extractFrom(o);
|
|
579
|
-
const name = o[
|
|
580
|
-
delete o[
|
|
569
|
+
const name = o[type.key];
|
|
570
|
+
delete o[type.key];
|
|
581
571
|
return [name, o];
|
|
582
572
|
})
|
|
583
573
|
);
|
|
@@ -588,9 +578,9 @@ export function extractFrom(
|
|
|
588
578
|
|
|
589
579
|
const json = {};
|
|
590
580
|
|
|
591
|
-
for (;
|
|
581
|
+
for (; type; type = type.extends) {
|
|
592
582
|
for (const [path, def] of attributeIterator(
|
|
593
|
-
|
|
583
|
+
type.attributes,
|
|
594
584
|
filterPublic
|
|
595
585
|
)) {
|
|
596
586
|
const name = path.join(".");
|
|
@@ -188,7 +188,7 @@ export class InitializationContext {
|
|
|
188
188
|
return object;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
read(object, data, type = object.constructor
|
|
191
|
+
read(object, data, type = object.constructor) {
|
|
192
192
|
if (data?.properties) {
|
|
193
193
|
Object.assign(object.properties, data.properties);
|
|
194
194
|
}
|
|
@@ -200,7 +200,7 @@ export class InitializationContext {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
_read(object, data, type
|
|
203
|
+
_read(object, data, type) {
|
|
204
204
|
if (type.extends) {
|
|
205
205
|
this._read(object, data, type.extends);
|
|
206
206
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { default_attribute_writable, addType } from "pacc";
|
|
2
|
-
import {
|
|
3
|
-
NetworkInterface,
|
|
4
|
-
NetworkInterfaceTypeDefinition
|
|
5
|
-
} from "./network-interface.mjs";
|
|
2
|
+
import { NetworkInterface } from "./network-interface.mjs";
|
|
6
3
|
|
|
7
4
|
export class EthernetNetworkInterface extends NetworkInterface {
|
|
8
|
-
static
|
|
9
|
-
static extends=
|
|
10
|
-
static specializationOf=
|
|
11
|
-
static owners=
|
|
12
|
-
static key= "name";
|
|
13
|
-
static attributes= {
|
|
5
|
+
static name = "ethernet";
|
|
6
|
+
static extends = NetworkInterface;
|
|
7
|
+
static specializationOf = NetworkInterface;
|
|
8
|
+
static owners = NetworkInterface.owners;
|
|
9
|
+
static key = "name";
|
|
10
|
+
static attributes = {
|
|
14
11
|
arpbridge: {
|
|
15
12
|
...default_attribute_writable,
|
|
16
13
|
type: "network_interface",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addType } from "pacc";
|
|
2
2
|
import { SUBNET_LOCALHOST_IPV4, SUBNET_LOCALHOST_IPV6 } from "pmcf";
|
|
3
3
|
import { SkeletonNetworkInterface } from "./skeleton.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { NetworkInterface } from "./network-interface.mjs";
|
|
5
5
|
|
|
6
6
|
const _localAddresses = new Map([
|
|
7
7
|
["127.0.0.1", SUBNET_LOCALHOST_IPV4],
|
|
@@ -12,9 +12,9 @@ const _localDomains = new Set(["localhost"]);
|
|
|
12
12
|
|
|
13
13
|
export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
|
|
14
14
|
static name = "loopback";
|
|
15
|
-
static extends =
|
|
16
|
-
static specializationOf =
|
|
17
|
-
static owners =
|
|
15
|
+
static extends = NetworkInterface;
|
|
16
|
+
static specializationOf = NetworkInterface;
|
|
17
|
+
static owners = NetworkInterface.owners;
|
|
18
18
|
static key = "name";
|
|
19
19
|
|
|
20
20
|
static typeDefinition = this;
|
|
@@ -16,17 +16,17 @@ import { SkeletonNetworkInterface } from "./skeleton.mjs";
|
|
|
16
16
|
import { Network } from "../network.mjs";
|
|
17
17
|
import { yesno } from "../utils.mjs";
|
|
18
18
|
|
|
19
|
-
export
|
|
20
|
-
name
|
|
21
|
-
owners
|
|
22
|
-
extends
|
|
23
|
-
specializations
|
|
24
|
-
factoryFor(owner, value) {
|
|
25
|
-
let t =
|
|
19
|
+
export class NetworkInterface extends SkeletonNetworkInterface {
|
|
20
|
+
static name = "network_interface";
|
|
21
|
+
static owners = ["host"];
|
|
22
|
+
static extends = Base;
|
|
23
|
+
static specializations = {};
|
|
24
|
+
static factoryFor(owner, value) {
|
|
25
|
+
let t = this.specializations[value.kind];
|
|
26
26
|
|
|
27
27
|
//console.log("factoryFor", owner, value);
|
|
28
28
|
if (!t) {
|
|
29
|
-
for (t of Object.values(
|
|
29
|
+
for (t of Object.values(this.specializations)) {
|
|
30
30
|
if (t.clazz.isCommonName && t.clazz.isCommonName(value.name)) {
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
@@ -39,10 +39,10 @@ export const NetworkInterfaceTypeDefinition = {
|
|
|
39
39
|
return t.clazz;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
key
|
|
45
|
-
attributes
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
static key = "name";
|
|
45
|
+
static attributes = {
|
|
46
46
|
...networkAttributes,
|
|
47
47
|
...networkAddressAttributes,
|
|
48
48
|
|
|
@@ -56,14 +56,12 @@ export const NetworkInterfaceTypeDefinition = {
|
|
|
56
56
|
hwaddr: string_attribute_writable,
|
|
57
57
|
network: {
|
|
58
58
|
...default_attribute_writable,
|
|
59
|
-
type: Network
|
|
59
|
+
type: Network
|
|
60
60
|
},
|
|
61
61
|
destination: string_attribute_writable
|
|
62
|
-
}
|
|
63
|
-
};
|
|
62
|
+
};
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
static typeDefinition = NetworkInterfaceTypeDefinition;
|
|
64
|
+
static typeDefinition = this;
|
|
67
65
|
|
|
68
66
|
static {
|
|
69
67
|
addType(this);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { addType } from "pacc";
|
|
2
2
|
import { NetworkInterface } from "./network-interface.mjs";
|
|
3
|
-
import { NetworkInterfaceTypeDefinition } from "./network-interface.mjs";
|
|
4
3
|
|
|
5
4
|
export class TUNNetworkInterface extends NetworkInterface {
|
|
6
5
|
static name = "tun";
|
|
7
|
-
static extends =
|
|
8
|
-
static specializationOf =
|
|
9
|
-
static owners =
|
|
6
|
+
static extends = NetworkInterface;
|
|
7
|
+
static specializationOf = NetworkInterface;
|
|
8
|
+
static owners = NetworkInterface.owners;
|
|
10
9
|
static key = "name";
|
|
11
10
|
|
|
12
11
|
static typeDefinition = this;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { addType } from "pacc";
|
|
2
2
|
import { SkeletonNetworkInterface } from "./skeleton.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { NetworkInterface } from "./network-interface.mjs";
|
|
4
4
|
|
|
5
5
|
export class WireguardNetworkInterface extends SkeletonNetworkInterface {
|
|
6
6
|
static name = "wireguard";
|
|
7
|
-
static extends =
|
|
8
|
-
static specializationOf =
|
|
9
|
-
static owners =
|
|
7
|
+
static extends = NetworkInterface;
|
|
8
|
+
static specializationOf = NetworkInterface;
|
|
9
|
+
static owners = NetworkInterface.owners;
|
|
10
10
|
static key = "name";
|
|
11
11
|
|
|
12
12
|
static typeDefinition = this;
|
|
@@ -6,15 +6,13 @@ import {
|
|
|
6
6
|
addType
|
|
7
7
|
} from "pacc";
|
|
8
8
|
import { writeLines, sectionLines } from "../utils.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
EthernetNetworkInterface
|
|
12
|
-
} from "./ethernet.mjs";
|
|
9
|
+
import { NetworkInterface } from "./network-interface.mjs";
|
|
10
|
+
import { EthernetNetworkInterface } from "./ethernet.mjs";
|
|
13
11
|
|
|
14
12
|
export class WLANNetworkInterface extends EthernetNetworkInterface {
|
|
15
13
|
static name = "wlan";
|
|
16
14
|
static extends = EthernetNetworkInterface;
|
|
17
|
-
static specializationOf =
|
|
15
|
+
static specializationOf = NetworkInterface;
|
|
18
16
|
static owners = EthernetNetworkInterface.owners;
|
|
19
17
|
static key = "name";
|
|
20
18
|
static attributes = {
|