@push.rocks/smartnftables 1.4.0 → 1.6.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.
Files changed (53) hide show
  1. package/changelog.md +26 -0
  2. package/dist_rust/smartnftables_linux_amd64_musl +0 -0
  3. package/dist_rust/smartnftables_linux_amd64_musl.tsrust-build.json +4 -4
  4. package/dist_rust/smartnftables_linux_arm64_musl +0 -0
  5. package/dist_rust/smartnftables_linux_arm64_musl.tsrust-build.json +4 -4
  6. package/dist_ts/00_commitinfo_data.js +1 -1
  7. package/dist_ts/classes.manageddockerforwarding.d.ts +17 -0
  8. package/dist_ts/classes.manageddockerforwarding.js +128 -0
  9. package/dist_ts/classes.managednftables.d.ts +9 -7
  10. package/dist_ts/classes.managednftables.js +2 -2
  11. package/dist_ts/index.d.ts +3 -0
  12. package/dist_ts/index.js +3 -1
  13. package/dist_ts/managed.docker.types.d.ts +78 -0
  14. package/dist_ts/managed.docker.types.js +2 -0
  15. package/dist_ts/managed.egress.types.d.ts +91 -0
  16. package/dist_ts/managed.egress.types.js +2 -0
  17. package/dist_ts/managed.types.d.ts +20 -18
  18. package/package.json +2 -2
  19. package/readme.md +143 -6
  20. package/rust/src/docker.frontend.rs +203 -0
  21. package/rust/src/docker.graph.rs +129 -0
  22. package/rust/src/docker.policy.rs +140 -0
  23. package/rust/src/docker.rs +191 -0
  24. package/rust/src/docker_process_tests.rs +29 -0
  25. package/rust/src/docker_tests.rs +148 -0
  26. package/rust/src/egress.compile.rs +288 -0
  27. package/rust/src/egress.host.rs +103 -0
  28. package/rust/src/egress.router.rs +231 -0
  29. package/rust/src/egress.rs +682 -0
  30. package/rust/src/egress_tests.rs +332 -0
  31. package/rust/src/main.rs +13 -6
  32. package/rust/src/managed.rs +105 -0
  33. package/rust/src/owner.rs +115 -7
  34. package/rust/src/owner_coexistence_tests.rs +77 -0
  35. package/rust/src/owner_egress_identity_tests.rs +155 -0
  36. package/rust/src/owner_egress_tests.rs +153 -0
  37. package/rust/src/owner_egress_traffic_tests.rs +470 -0
  38. package/rust/src/owner_host_traffic_tests.rs +305 -0
  39. package/rust/src/owner_identity_tests.rs +169 -0
  40. package/rust/src/owner_link_tests.rs +119 -0
  41. package/rust/src/owner_packet_fixture.rs +200 -0
  42. package/rust/src/owner_tests.rs +33 -7
  43. package/rust/src/policy.rs +120 -81
  44. package/rust/src/tests.rs +22 -0
  45. package/rust/src/wire.links.rs +279 -0
  46. package/rust/src/wire.rs +16 -66
  47. package/ts/00_commitinfo_data.ts +1 -1
  48. package/ts/classes.manageddockerforwarding.ts +113 -0
  49. package/ts/classes.managednftables.ts +13 -13
  50. package/ts/index.ts +3 -0
  51. package/ts/managed.docker.types.ts +49 -0
  52. package/ts/managed.egress.types.ts +85 -0
  53. package/ts/managed.types.ts +20 -16
@@ -0,0 +1,85 @@
1
+ import type { IManagedNftEndpoint, IManagedNftRule } from './managed.types.js';
2
+
3
+ /** Namespace-local facts, checked through rtnetlink. The caller retains actual link-generation ownership. */
4
+ export interface IManagedNftLocalLinkV2 {
5
+ interfaceIndex: number;
6
+ interfaceName: string;
7
+ interfaceKind: 'veth' | 'tun' | 'ethernet';
8
+ /** Canonical unicast Ethernet address, or null for an L3 TUN. */
9
+ macAddress: string | null;
10
+ interfaceLinkIndex: number;
11
+ requiredIpv4Addresses: string[];
12
+ }
13
+
14
+ export interface IManagedNftPlatformEndpointV2 {
15
+ id: string;
16
+ address: string;
17
+ protocol: 'tcp' | 'udp';
18
+ port: number;
19
+ }
20
+
21
+ /** Caller-authenticated complete protected authority; hashing does not attest completeness. */
22
+ export interface IManagedNftProtectionV2 {
23
+ authorityDigest: string;
24
+ prefixes: string[];
25
+ platformEndpoints: IManagedNftPlatformEndpointV2[];
26
+ }
27
+
28
+ export interface IManagedNftHandoffPortRangeV2 {
29
+ protocol: 'tcp' | 'udp';
30
+ first: number;
31
+ last: number;
32
+ }
33
+
34
+ export interface IManagedNftHandoffAllocationV2 {
35
+ lease: { id: string; generation: number; digest: string };
36
+ transitSourceAddress: string;
37
+ sourcePortRanges: IManagedNftHandoffPortRangeV2[];
38
+ }
39
+
40
+ export interface IManagedNftEgressGrantV2 {
41
+ /** A workload veth endpoint, or the actual router-local host for DNS/relay sockets. */
42
+ sourceEndpoint: string | null;
43
+ sourcePrefix: string;
44
+ destination: { kind: 'public'; prefix: string } | { kind: 'platform'; endpointId: string };
45
+ protocol: 'tcp' | 'udp';
46
+ sourcePort: number | null;
47
+ destinationPort: number | null;
48
+ /** One exact range from this generation's lease; selects the SNAT range for this grant. */
49
+ sourcePortRange: { first: number; last: number };
50
+ }
51
+
52
+ export interface IManagedNftEgressGenerationV2 extends IManagedNftHandoffAllocationV2 {
53
+ conntrackZone: number;
54
+ conntrackLabel: string;
55
+ grants: IManagedNftEgressGrantV2[];
56
+ }
57
+
58
+ /** One combined private/TUN/local/egress table; never compose a second ACCEPT over v1 terminal drops. */
59
+ export interface IManagedNftRouterEgressScopeV2 {
60
+ kind: 'routerEgress';
61
+ endpoints: IManagedNftEndpoint[];
62
+ rules: IManagedNftRule[];
63
+ /** One exact local binding for every private endpoint. */
64
+ links: IManagedNftLocalLinkV2[];
65
+ handoff: IManagedNftLocalLinkV2;
66
+ protection: IManagedNftProtectionV2;
67
+ /** Empty retains private/local enforcement while denying external egress. */
68
+ generations: IManagedNftEgressGenerationV2[];
69
+ }
70
+
71
+ /** Shared-host capture barrier and explicit outer SNAT; Docker forwarding remains a separate owner. */
72
+ export interface IManagedNftHostTransitScopeV2 {
73
+ kind: 'hostTransit';
74
+ protection: IManagedNftProtectionV2;
75
+ handoffs: Array<{ link: IManagedNftLocalLinkV2; allocations: IManagedNftHandoffAllocationV2[] }>;
76
+ uplink: IManagedNftLocalLinkV2;
77
+ /** Exact current address present on uplink. No masquerade or default-route inference. */
78
+ snatAddress: string;
79
+ }
80
+
81
+ export interface IManagedNftPolicyV2 {
82
+ schemaVersion: 2;
83
+ revision: number;
84
+ scope: IManagedNftRouterEgressScopeV2 | IManagedNftHostTransitScopeV2;
85
+ }
@@ -1,3 +1,5 @@
1
+ import type { IManagedNftPolicyV2 } from './managed.egress.types.js';
2
+
1
3
  /** The caller owns these workload links and keeps them disabled until apply is confirmed. */
2
4
  export interface IManagedNftEndpoint {
3
5
  id: string;
@@ -26,8 +28,8 @@ export interface IManagedNftPolicy {
26
28
  rules: IManagedNftRule[];
27
29
  }
28
30
 
29
- export interface IPreparedManagedNftPolicy {
30
- policy: IManagedNftPolicy;
31
+ export interface IPreparedManagedNftPolicy<TPolicy extends TManagedNftPolicy = IManagedNftPolicy> {
32
+ policy: TPolicy;
31
33
  digest: string;
32
34
  }
33
35
 
@@ -47,23 +49,23 @@ export interface IManagedNftReceipt {
47
49
  digest: string;
48
50
  }
49
51
 
50
- export interface IAppliedManagedNftPolicy {
52
+ export interface IAppliedManagedNftPolicy<TPolicy extends TManagedNftPolicy = IManagedNftPolicy> {
51
53
  receipt: IManagedNftReceipt;
52
- prepared: IPreparedManagedNftPolicy;
54
+ prepared: IPreparedManagedNftPolicy<TPolicy>;
53
55
  }
54
56
 
55
57
  /** Persist this complete command before reconcile, then retain its complete result. */
56
- export interface IManagedNftTransition {
57
- previous: IAppliedManagedNftPolicy | null;
58
- target: IPreparedManagedNftPolicy;
58
+ export interface IManagedNftTransition<TPolicy extends TManagedNftPolicy = IManagedNftPolicy> {
59
+ previous: IAppliedManagedNftPolicy<TPolicy> | null;
60
+ target: IPreparedManagedNftPolicy<TPolicy>;
59
61
  }
60
62
 
61
- export interface IManagedNftStatus {
63
+ export interface IManagedNftStatus<TPolicy extends TManagedNftPolicy = IManagedNftPolicy> {
62
64
  identity: IManagedNftIdentity;
63
65
  state: 'idle' | 'applied' | 'failed-owned' | 'released';
64
66
  enforced: boolean;
65
- applied: IAppliedManagedNftPolicy | null;
66
- pending: IManagedNftTransition | null;
67
+ applied: IAppliedManagedNftPolicy<TPolicy> | null;
68
+ pending: IManagedNftTransition<TPolicy> | null;
67
69
  error: string | null;
68
70
  }
69
71
 
@@ -81,11 +83,13 @@ export interface IManagedNftOptions {
81
83
  networkNamespaceFd?: number;
82
84
  }
83
85
 
84
- export type TManagedNftCommands = {
85
- preparePolicy: { params: IManagedNftPolicy; result: IPreparedManagedNftPolicy };
86
- openOwner: { params: Pick<IManagedNftOptions, 'ownerId' | 'instanceId' | 'tableName'>; result: IManagedNftStatus };
87
- reconcilePolicy: { params: IManagedNftTransition; result: IAppliedManagedNftPolicy };
88
- inspectPolicy: { params: Record<string, never>; result: IManagedNftStatus };
89
- releasePolicy: { params: IAppliedManagedNftPolicy; result: { released: true } };
86
+ export type TManagedNftPolicy = IManagedNftPolicy | IManagedNftPolicyV2;
87
+
88
+ export type TManagedNftCommands<TPolicy extends TManagedNftPolicy = IManagedNftPolicy> = {
89
+ preparePolicy: { params: TPolicy; result: IPreparedManagedNftPolicy<TPolicy> };
90
+ openOwner: { params: Pick<IManagedNftOptions, 'ownerId' | 'instanceId' | 'tableName'>; result: IManagedNftStatus<TPolicy> };
91
+ reconcilePolicy: { params: IManagedNftTransition<TPolicy>; result: IAppliedManagedNftPolicy<TPolicy> };
92
+ inspectPolicy: { params: Record<string, never>; result: IManagedNftStatus<TPolicy> };
93
+ releasePolicy: { params: IAppliedManagedNftPolicy<TPolicy>; result: { released: true } };
90
94
  closeOwner: { params: Record<string, never>; result: { released: true } };
91
95
  };