@aj-shadow/z-abs-funclayer-engine-server 0.0.0-aj-beta.221
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/.gitattributes +26 -0
- package/LICENSE.txt +96 -0
- package/README.md +5 -0
- package/npm-shrinkwrap.json +13 -0
- package/package.json +10 -0
- package/project/server/_build/Server-FuncLayer-Engine-server.bld +12 -0
- package/project/server/_build/z-abs-funclayer-engine-server.prj +12 -0
- package/project/server/address/address-calculator.js +377 -0
- package/project/server/address/address-data.js +364 -0
- package/project/server/address/address-manager.js +251 -0
- package/project/server/address/address.js +176 -0
- package/project/server/address/addresses.js +122 -0
- package/project/server/address/dns-url-cache.js +130 -0
- package/project/server/address/interfaces.js +100 -0
- package/project/server/address/local-dns.js +35 -0
- package/project/server/address/login-report.js +56 -0
- package/project/server/address/networks.js +598 -0
- package/project/server/address/real-networks.js +102 -0
- package/project/server/address/subnet.js +60 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-started.js +17 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-stopped.js +14 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-debug-paused.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-log.js +25 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-started.js +21 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-state.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-stopped.js +22 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-started.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-started.js +16 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-w/message-test-case-debug-actor-index-ok.js +15 -0
- package/project/server/communication/messages/messages-w-to-s/message-test-case-debug-actor-index.js +15 -0
- package/project/server/debug/debug-step-over.js +54 -0
- package/project/server/debug/debugger.js +102 -0
- package/project/server/debug-dashboard/debug-dashboard.js +14 -0
- package/project/server/debug-dashboard/gauge-manager.js +44 -0
- package/project/server/debug-dashboard/gauge.js +37 -0
- package/project/server/engine/actor/actor-condition.js +335 -0
- package/project/server/engine/actor/actor-intercepting.js +32 -0
- package/project/server/engine/actor/actor-local.js +24 -0
- package/project/server/engine/actor/actor-mixins/asynch-mixin.js +103 -0
- package/project/server/engine/actor/actor-mixins/content-mixin.js +22 -0
- package/project/server/engine/actor/actor-mixins/logger-mixin.js +603 -0
- package/project/server/engine/actor/actor-mixins/process-mixin.js +35 -0
- package/project/server/engine/actor/actor-mixins/shared-data-mixin.js +109 -0
- package/project/server/engine/actor/actor-mixins/shared-execution-data-mixin.js +57 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-client.js +157 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-server.js +123 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin.js +128 -0
- package/project/server/engine/actor/actor-mixins/test-data-mixin.js +402 -0
- package/project/server/engine/actor/actor-mixins/timer-mixin.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-base.js +668 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-mandatory.js +46 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-optional.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-value.js +71 -0
- package/project/server/engine/actor/actor-originating.js +32 -0
- package/project/server/engine/actor/actor-part-mixins/part-asynch-mixin.js +24 -0
- package/project/server/engine/actor/actor-part-mixins/part-logger-mixin.js +39 -0
- package/project/server/engine/actor/actor-part-mixins/part-shared-runtime-data-mixin.js +33 -0
- package/project/server/engine/actor/actor-part-mixins/part-timer-mixin.js +12 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-mandatory.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-optional.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-value.js +15 -0
- package/project/server/engine/actor/actor-part-post.js +37 -0
- package/project/server/engine/actor/actor-part-pre.js +37 -0
- package/project/server/engine/actor/actor-pending.js +79 -0
- package/project/server/engine/actor/actor-proxy.js +38 -0
- package/project/server/engine/actor/actor-results.js +36 -0
- package/project/server/engine/actor/actor-state-timeout.js +35 -0
- package/project/server/engine/actor/actor-sut.js +38 -0
- package/project/server/engine/actor/actor-terminating.js +32 -0
- package/project/server/engine/actor/actor.js +553 -0
- package/project/server/engine/actor-phase.js +26 -0
- package/project/server/engine/actor-state-machine-base.js +298 -0
- package/project/server/engine/actor-state-machine-data.js +383 -0
- package/project/server/engine/actor-state-machine-exec.js +137 -0
- package/project/server/engine/actor-state-machine-post.js +177 -0
- package/project/server/engine/actor-state-machine-pre.js +142 -0
- package/project/server/engine/actor-state-machine-process.js +88 -0
- package/project/server/engine/actor-state-machine-state.js +52 -0
- package/project/server/engine/actor-state-machine.js +185 -0
- package/project/server/engine/actor-state.js +35 -0
- package/project/server/engine/actor-worker.js +68 -0
- package/project/server/engine/actors-phase.js +49 -0
- package/project/server/engine/actors.js +317 -0
- package/project/server/engine/data/content-audio.js +18 -0
- package/project/server/engine/data/content-base.js +91 -0
- package/project/server/engine/data/content-binary.js +15 -0
- package/project/server/engine/data/content-cache.js +67 -0
- package/project/server/engine/data/content-data.js +254 -0
- package/project/server/engine/data/content-documents.js +18 -0
- package/project/server/engine/data/content-image.js +20 -0
- package/project/server/engine/data/content-other.js +19 -0
- package/project/server/engine/data/content-text.js +19 -0
- package/project/server/engine/data/content-undefined.js +14 -0
- package/project/server/engine/data/content-video.js +20 -0
- package/project/server/engine/data/content.js +60 -0
- package/project/server/engine/data/runtime-data-shared.js +75 -0
- package/project/server/engine/data/test-data.js +239 -0
- package/project/server/engine/execution-context-test-case.js +48 -0
- package/project/server/engine/execution-context-test-suite.js +66 -0
- package/project/server/engine/execution-context.js +93 -0
- package/project/server/engine/stage-setter.js +132 -0
- package/project/server/engine/stage.js +83 -0
- package/project/server/engine/test-case-load.js +25 -0
- package/project/server/engine/test-case-loader.js +125 -0
- package/project/server/engine/test-case-not-found.js +29 -0
- package/project/server/engine/test-case-result-type.js +42 -0
- package/project/server/engine/test-case.js +417 -0
- package/project/server/engine/test-output.js +116 -0
- package/project/server/engine/test-statistics-test-case.js +59 -0
- package/project/server/engine/test-statistics-test-suite.js +63 -0
- package/project/server/engine/test-suite.js +276 -0
- package/project/server/stack/api/base-64.js +16 -0
- package/project/server/stack/api/const-commands-decoder.js +15 -0
- package/project/server/stack/api/const-commands-encoder.js +15 -0
- package/project/server/stack/api/hmacSha1.js +14 -0
- package/project/server/stack/api/json-web-token.js +38 -0
- package/project/server/stack/api/sdp/sdp-decoder.js +70 -0
- package/project/server/stack/api/sdp/sdp-encoder.js +40 -0
- package/project/server/stack/api/sdp/sdp-media-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-media-session.js +16 -0
- package/project/server/stack/api/sdp/sdp-message.js +17 -0
- package/project/server/stack/api/sdp/sdp-origin.js +17 -0
- package/project/server/stack/api/sdp/sdp-session-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-timing.js +15 -0
- package/project/server/stack/api/text-protocol-header.js +35 -0
- package/project/server/stack/factory/stack-components-helpers.js +22 -0
- package/project/server/stack/factory/stack-components-template-base-actors.js +124 -0
- package/project/server/stack/factory/stack-components-template-base-test-cases.js +22 -0
- package/project/server/stack/factory/stack-components-templates-actors.js +15 -0
- package/project/server/stack/factory/stack-components-templates-test-cases.js +20 -0
- package/project/server/stack/managers/client-manager/client-manager.js +193 -0
- package/project/server/stack/managers/connection-manager/connection-data.js +82 -0
- package/project/server/stack/managers/connection-manager/connection-manager.js +177 -0
- package/project/server/stack/managers/connection-manager/connection-object.js +148 -0
- package/project/server/stack/managers/connection-manager/shared-data.js +14 -0
- package/project/server/stack/managers/manager.js +95 -0
- package/project/server/stack/managers/server-manager/server-manager.js +76 -0
- package/project/server/stack/managers/server-manager/server.js +384 -0
- package/project/server/stack/managers/shared-manager.js +117 -0
- package/project/server/stack/network/buffer-manager.js +190 -0
- package/project/server/stack/network/mc/mc-connection-client-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-client.js +117 -0
- package/project/server/stack/network/mc/mc-connection-server-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-server.js +58 -0
- package/project/server/stack/network/mc/mc-connection-shared.js +26 -0
- package/project/server/stack/network/mc/mc-connection.js +33 -0
- package/project/server/stack/network/mc/mc-server.js +90 -0
- package/project/server/stack/network/network-connection-shared.js +177 -0
- package/project/server/stack/network/network-connection.js +134 -0
- package/project/server/stack/network/network-helper.js +12 -0
- package/project/server/stack/network/network-server.js +36 -0
- package/project/server/stack/network/network-type.js +46 -0
- package/project/server/stack/network/tcp/tcp-connection-client-shared.js +18 -0
- package/project/server/stack/network/tcp/tcp-connection-client.js +71 -0
- package/project/server/stack/network/tcp/tcp-connection-server-shared.js +14 -0
- package/project/server/stack/network/tcp/tcp-connection-server.js +16 -0
- package/project/server/stack/network/tcp/tcp-connection-shared.js +55 -0
- package/project/server/stack/network/tcp/tcp-connection.js +167 -0
- package/project/server/stack/network/tcp/tcp-server.js +35 -0
- package/project/server/stack/network/tls/tls-connection-client-shared.js +18 -0
- package/project/server/stack/network/tls/tls-connection-client.js +76 -0
- package/project/server/stack/network/tls/tls-connection-server-shared.js +14 -0
- package/project/server/stack/network/tls/tls-connection-server.js +16 -0
- package/project/server/stack/network/tls/tls-connection-shared.js +63 -0
- package/project/server/stack/network/tls/tls-connection.js +176 -0
- package/project/server/stack/network/tls/tls-server.js +45 -0
- package/project/server/stack/network/transport.js +19 -0
- package/project/server/stack/network/udp/udp-connection-client-shared.js +47 -0
- package/project/server/stack/network/udp/udp-connection-client.js +93 -0
- package/project/server/stack/network/udp/udp-connection-server-shared.js +51 -0
- package/project/server/stack/network/udp/udp-connection-server.js +58 -0
- package/project/server/stack/network/udp/udp-connection-shared.js +26 -0
- package/project/server/stack/network/udp/udp-connection.js +33 -0
- package/project/server/stack/network/udp/udp-server.js +74 -0
- package/project/server/stack/pending/pending-const.js +22 -0
- package/project/server/stack/pending/pending-context-receive.js +18 -0
- package/project/server/stack/pending/pending-context-send.js +18 -0
- package/project/server/stack/pending/pending-context.js +18 -0
- package/project/server/stack/pending/pending-inner.js +107 -0
- package/project/server/stack/pending/pending-switch.js +146 -0
- package/project/server/stack/stacks/ascii-dictionary.js +289 -0
- package/project/server/stack/stacks/binary-log.js +88 -0
- package/project/server/stack/stacks/bit-byte.js +51 -0
- package/project/server/stack/stacks/browser-data.js +25 -0
- package/project/server/stack/stacks/cancel-object.js +16 -0
- package/project/server/stack/stacks/connection-client.js +228 -0
- package/project/server/stack/stacks/connection-instance.js +69 -0
- package/project/server/stack/stacks/connection-ip.js +374 -0
- package/project/server/stack/stacks/connection-server.js +169 -0
- package/project/server/stack/stacks/connection-web.js +113 -0
- package/project/server/stack/stacks/connection-worker-client.js +29 -0
- package/project/server/stack/stacks/connection-worker-connection.js +41 -0
- package/project/server/stack/stacks/connection-worker-server.js +29 -0
- package/project/server/stack/stacks/connection-worker.js +99 -0
- package/project/server/stack/stacks/connection.js +132 -0
- package/project/server/stack/stacks/decoder.js +83 -0
- package/project/server/stack/stacks/encoder.js +82 -0
- package/project/server/stack/stacks/ip-log.js +24 -0
- package/project/server/stack/stacks/message-selector.js +22 -0
- package/project/server/stack/stacks/msg-ip.js +18 -0
- package/project/server/stack/stacks/stack-content-cache.js +27 -0
- package/project/z-abs-funclayer-engine-server.tree +230 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Net = require('net');
|
|
5
|
+
const Dns = require('dns');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Address {
|
|
9
|
+
static IS_LOCAL = true;
|
|
10
|
+
static IS_REMOTE = false;
|
|
11
|
+
|
|
12
|
+
static CLIENT = 'client';
|
|
13
|
+
static SUT = 'sut';
|
|
14
|
+
static SERVER = 'server';
|
|
15
|
+
|
|
16
|
+
static PORT_NOT_SET = 0;
|
|
17
|
+
static PORT_VALUE = 1;
|
|
18
|
+
static PORT_ZERO = 2;
|
|
19
|
+
static PORT_GENERATED = 3;
|
|
20
|
+
|
|
21
|
+
static DNS_RESOLVED_NOT = 0;
|
|
22
|
+
static DNS_RESOLVED_PENDING = 1;
|
|
23
|
+
static DNS_RESOLVED = 2;
|
|
24
|
+
|
|
25
|
+
constructor(addressName, host, family, port, type, page, incognitoBrowser, uri) {
|
|
26
|
+
this.addressName = addressName;
|
|
27
|
+
//this.logName = '';
|
|
28
|
+
this.host = host;
|
|
29
|
+
this.family = family ? family : 'IPv4';
|
|
30
|
+
this.port = 'number' === typeof port ? port: (!!port ? Number.parseInt(port) : null);
|
|
31
|
+
this.portValueType = null === this.port ? Address.PORT_NOT_SET : (0 === this.port ? Address.PORT_ZERO : Address.PORT_VALUE);
|
|
32
|
+
this.type = type;
|
|
33
|
+
this.page = page;
|
|
34
|
+
this.incognitoBrowser = incognitoBrowser;
|
|
35
|
+
this.uri = uri
|
|
36
|
+
this.domain = null;
|
|
37
|
+
this.proxy = false;
|
|
38
|
+
this.isResolved = Address.DNS_RESOLVED_NOT;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
clone(port) {
|
|
42
|
+
const address = new Address(this.addressName, this.host, this.family, port ? port : this.port, this.type, this.page, this.incognitoBrowser, this.uri);
|
|
43
|
+
address.portValueType = this.portValueType;
|
|
44
|
+
address.domain = this.domain;
|
|
45
|
+
address.proxy = this.proxy;
|
|
46
|
+
address.isResolved = this.isResolved;
|
|
47
|
+
//address.logName = this.logName;
|
|
48
|
+
return address;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//setLogName(logName) {
|
|
52
|
+
// this.logName = this.logName = logName;
|
|
53
|
+
///
|
|
54
|
+
|
|
55
|
+
static from(address) {
|
|
56
|
+
const newAddress = new Address(address.addressName, address.host, address.family, address.port, address.type, address.page, address.incognitoBrowser, address.uri);
|
|
57
|
+
newAddress.portValueType = address.portValueType;
|
|
58
|
+
newAddress.domain = address.domain;
|
|
59
|
+
newAddress.proxy = address.proxy;
|
|
60
|
+
newAddress.isResolved = address.isResolved;
|
|
61
|
+
//address.logName = this.logName;
|
|
62
|
+
return newAddress;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static netAddress(srcAddress, dstAddress, port=-1, protocol='') {
|
|
66
|
+
if(!protocol) {
|
|
67
|
+
if(-1 !== port) {
|
|
68
|
+
return Address._netAddressTcp(srcAddress, dstAddress, port);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return Address._netAddressTcp(srcAddress, dstAddress.host, dstAddress.port);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if(-1 !== port) {
|
|
76
|
+
return Address._netAddressTls(srcAddress, dstAddress, port);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return Address._netAddressTls(srcAddress, dstAddress.host, dstAddress.port);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static _netAddressTcp(srcAddress, address, port) {
|
|
85
|
+
if('DEFAULT_SRC' !== srcAddress.addressName) {
|
|
86
|
+
return {
|
|
87
|
+
localAddress: srcAddress.host,
|
|
88
|
+
localPort: srcAddress.port,
|
|
89
|
+
host: address,
|
|
90
|
+
port: port,
|
|
91
|
+
allowHalfOpen: true
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return {
|
|
96
|
+
host: address,
|
|
97
|
+
port: port,
|
|
98
|
+
allowHalfOpen: true
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static _netAddressTls(srcAddress, address, port) {
|
|
104
|
+
if('DEFAULT_SRC' !== srcAddress.addressName) {
|
|
105
|
+
return {
|
|
106
|
+
localAddress: srcAddress.host,
|
|
107
|
+
localPort: srcAddress.port,
|
|
108
|
+
host: address,
|
|
109
|
+
port: port,
|
|
110
|
+
allowHalfOpen: true,
|
|
111
|
+
checkServerIdentity: (host, cert) => {}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return {
|
|
116
|
+
host: address,
|
|
117
|
+
port: port,
|
|
118
|
+
allowHalfOpen: true,
|
|
119
|
+
checkServerIdentity: (host, cert) => {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
resolve(portDefault) {
|
|
125
|
+
if(Address.DNS_RESOLVED === this.isResolved) {
|
|
126
|
+
return Address.DNS_RESOLVED;
|
|
127
|
+
}
|
|
128
|
+
if(!!this.uri) {
|
|
129
|
+
const url = new URL(this.uri);
|
|
130
|
+
this.domain = url.hostname;
|
|
131
|
+
this.port = url.port ? Number.parseInt(url.port) : this.port;
|
|
132
|
+
if(0 === this.port) {
|
|
133
|
+
this.portValueType = Address.PORT_ZERO;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.portValueType = Address.PORT_VALUE;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if(!this.port) {
|
|
140
|
+
if(!portDefault) {
|
|
141
|
+
this.port = 0;
|
|
142
|
+
this.portValueType = Address.PORT_ZERO;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.port = portDefault;
|
|
146
|
+
if(0 === this.port) {
|
|
147
|
+
this.portValueType = Address.PORT_ZERO;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.portValueType = Address.PORT_VALUE;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return Address.DNS_RESOLVED_PENDING;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setResolved(address) {
|
|
158
|
+
this.host = address;
|
|
159
|
+
this.isResolved = Address.DNS_RESOLVED;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
setProxy(address) {
|
|
163
|
+
this.host = address.host;
|
|
164
|
+
this.port = address.port;
|
|
165
|
+
if(0 === this.port) {
|
|
166
|
+
this.portValueType = Address.PORT_ZERO;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.portValueType = Address.PORT_VALUE;
|
|
170
|
+
}
|
|
171
|
+
this.proxy = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
module.exports = Address;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Address = require('./address');
|
|
5
|
+
const ActorPathGenerated = require('z-abs-corelayer-server/server/path/actor-path-generated');
|
|
6
|
+
const ActorPathData = require('z-abs-corelayer-server/server/path/actor-path-data');
|
|
7
|
+
const Fs = require('fs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Addresses {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.srcs = new Map();
|
|
13
|
+
this.sutSrvs = new Map();
|
|
14
|
+
this.srvs = new Map();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getSrc(name) {
|
|
18
|
+
if(name) {
|
|
19
|
+
const src = this.srcs.get(name);
|
|
20
|
+
if(src) {
|
|
21
|
+
return src;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return this.sutSrvs.get(name);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const firstSrc = this.srcs.values().next().value;
|
|
29
|
+
if(firstSrc) {
|
|
30
|
+
return firstSrc;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return this.sutSrvs.values().next().value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getDst(name) {
|
|
39
|
+
if(name) {
|
|
40
|
+
const dst = this.sutSrvs.get(name);
|
|
41
|
+
if(undefined !== dst) {
|
|
42
|
+
return dst;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return this.srvs.get(name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const dst = this.sutSrvs.values().next().value;
|
|
50
|
+
if(dst) {
|
|
51
|
+
return dst;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return this.srvs.values().next().value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getSrv(name) {
|
|
60
|
+
if(name) {
|
|
61
|
+
const srv = this.srvs.get(name);
|
|
62
|
+
if(srv) {
|
|
63
|
+
return srv;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return this.sutSrvs.get(name);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const firstSrv = this.srvs.values().next().value;
|
|
71
|
+
if(firstSrv) {
|
|
72
|
+
return firstSrv;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return this.sutSrvs.values().next().value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getDefaultSrc() {
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
sut(name) {
|
|
85
|
+
return this.srvs.has(name);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static save(addresses, done) {
|
|
89
|
+
Fs.writeFile(ActorPathGenerated.getAddressesFile(), JSON.stringify(addresses, null, 2), (err) => {
|
|
90
|
+
done(err);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static set(from, to) {
|
|
95
|
+
if(from) {
|
|
96
|
+
from.forEach((value) => {
|
|
97
|
+
const address = value[1];
|
|
98
|
+
to.set(value[0], new Address(address.addressName, address.host, address.family, address.port, address.type, address.page, address.incognitoBrowser, address.uri));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static load(addresses, done) {
|
|
104
|
+
Fs.readFile(ActorPathGenerated.getAddressesFile(), (err, data) => {
|
|
105
|
+
if(err) {
|
|
106
|
+
return done(err);
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const parsedAddresses = JSON.parse(data);
|
|
110
|
+
Addresses.set(parsedAddresses.srcs, addresses.srcs);
|
|
111
|
+
Addresses.set(parsedAddresses.dsts, addresses.sutSrvs);
|
|
112
|
+
Addresses.set(parsedAddresses.srvs, addresses.srvs);
|
|
113
|
+
done();
|
|
114
|
+
}
|
|
115
|
+
catch(e) {
|
|
116
|
+
done(e);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = Addresses;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Address = require('./address');
|
|
5
|
+
const Dns = require('dns');
|
|
6
|
+
const Net = require('net');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DnsUrlCache {
|
|
10
|
+
static id = 0;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
this.localDns = new Map();
|
|
14
|
+
this.cache = new Map();
|
|
15
|
+
this.pendings = new Map();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
resolveAddress(address, local, done) {
|
|
19
|
+
if(Address.DNS_RESOLVED === address.resolve()) {
|
|
20
|
+
process.nextTick(done, null);
|
|
21
|
+
}
|
|
22
|
+
else if(Address.DNS_RESOLVED === address.resolve()) {
|
|
23
|
+
const pendingQueue = this.pendings.get(address);
|
|
24
|
+
if(!pendingQueue) {
|
|
25
|
+
this.pendings.set(address, [done]);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
pendingQueue.push(done);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.get(local ? address.host : (address.domain ? address.domain : address.host), address.family, (err, ipAddress) => {
|
|
33
|
+
address.setResolved(ipAddress);
|
|
34
|
+
const pendingQueue = this.pendings.get(address);
|
|
35
|
+
process.nextTick(done, null);
|
|
36
|
+
if(pendingQueue) {
|
|
37
|
+
pendingQueue.forEach((queueDone) => {
|
|
38
|
+
process.nextTick(queueDone, null);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
this.pendings.delete(address);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setLocalDns(localDns) {
|
|
47
|
+
this.localDns = localDns;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getLocalDns() {
|
|
51
|
+
return this.localDns;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get(domain, family, done) {
|
|
55
|
+
const recordLocal = this.localDns.get(domain);
|
|
56
|
+
if(recordLocal) {
|
|
57
|
+
const position = recordLocal.position++;
|
|
58
|
+
if(position !== recordLocal.addresses.length) {
|
|
59
|
+
return done(null, recordLocal.addresses[position]);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
recordLocal.position = 0;
|
|
63
|
+
return done(null, recordLocal.addresses[0]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const record = this.cache.get(domain);
|
|
67
|
+
if(record) {
|
|
68
|
+
const position = record.position++;
|
|
69
|
+
if(position !== record.addresses.length) {
|
|
70
|
+
return done(null, record.addresses[position]);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
record.position = 0;
|
|
74
|
+
return done(null, record.addresses[0]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if('IPv4' === family) {
|
|
78
|
+
if(Net.isIPv4(domain)) {
|
|
79
|
+
this._Add(domain, [domain]);
|
|
80
|
+
return done(null, domain);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
Dns.resolve4(domain, (err, addresses) => {
|
|
84
|
+
if(err) {
|
|
85
|
+
return done(err);
|
|
86
|
+
}
|
|
87
|
+
this._Add(domain, addresses);
|
|
88
|
+
return done(null, addresses[0]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if('IPv6' === family) {
|
|
93
|
+
if(Net.isIPv6(domain)) {
|
|
94
|
+
this._Add(domain, [domain]);
|
|
95
|
+
return done(null, domain);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
Dns.resolve6(domain, (err, addresses) => {
|
|
99
|
+
if(err) {
|
|
100
|
+
return done(err);
|
|
101
|
+
}
|
|
102
|
+
this._Add(domain, addresses);
|
|
103
|
+
return done(null, addresses[0]);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return done(new Error(`Unknown IP family '${family}'.`));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_Add(domain, addresses) {
|
|
113
|
+
this.cache.set(domain, {
|
|
114
|
+
position: 0,
|
|
115
|
+
addresses: addresses
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
override(address) {
|
|
120
|
+
if(address.proxy) {
|
|
121
|
+
this.cache.set(address.uri, {
|
|
122
|
+
position: 0,
|
|
123
|
+
addresses: [address]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
module.exports = DnsUrlCache;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Address = require('./address');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Interfaces {
|
|
8
|
+
constructor(loginReport) {
|
|
9
|
+
this.loginReport = loginReport;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
calculate(networks, srcs, dsts, srvs) {
|
|
13
|
+
const addresses = {
|
|
14
|
+
srcs: [],
|
|
15
|
+
dsts: [],
|
|
16
|
+
srvs: []
|
|
17
|
+
};
|
|
18
|
+
const addressesSutSearch = new Map();
|
|
19
|
+
const addressesServerSearch = new Map();
|
|
20
|
+
const addressesClientSearch = new Map();
|
|
21
|
+
const networkSearch = new Map();
|
|
22
|
+
|
|
23
|
+
networks.forEach((network) => {
|
|
24
|
+
networkSearch.set(network.networkName, network);
|
|
25
|
+
network.suts.forEach((sut) => {
|
|
26
|
+
addressesSutSearch.set(sut.interfaceName, sut);
|
|
27
|
+
});
|
|
28
|
+
network.servers.forEach((server) => {
|
|
29
|
+
addressesServerSearch.set(server.interfaceName, server);
|
|
30
|
+
});
|
|
31
|
+
network.clients.forEach((client) => {
|
|
32
|
+
addressesClientSearch.set(client.interfaceName, client);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
srcs.forEach((src) => {
|
|
36
|
+
const addressClient = addressesClientSearch.get(src.interfaceName);
|
|
37
|
+
if(!!addressClient) {
|
|
38
|
+
const network = networkSearch.get(addressClient.networkName);
|
|
39
|
+
if(!!network) {
|
|
40
|
+
addresses.srcs.push([src.addressName, new Address(src.addressName, addressClient.address, network.family, src.port, Address.CLIENT, src.page, src.incognitoBrowser)]);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.loginReport.networkLog(`Src network '${addressClient.networkName}' does not exist.`);
|
|
44
|
+
// TODO: create log
|
|
45
|
+
ddb.error(`src network '${addressClient.networkName}' does not exist.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// TODO: create log
|
|
50
|
+
ddb.error(`src address interface '${src.interfaceName}' does not exist.`);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
dsts.forEach((dst) => {
|
|
54
|
+
const addressSut = addressesSutSearch.get(dst.interfaceName);
|
|
55
|
+
if(!!addressSut) {
|
|
56
|
+
const network = networkSearch.get(addressSut.networkName);
|
|
57
|
+
if(!!network) {
|
|
58
|
+
addresses.dsts.push([dst.addressName, new Address(dst.addressName, addressSut.address, network.family, dst.port, Address.SUT, undefined, undefined, dst.uri)]);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.loginReport.networkLog(`Dst network '${addressSut.networkName}' does not exist.`);
|
|
62
|
+
// TODO: create log
|
|
63
|
+
ddb.error(`dst network '${addressSut.networkName}' does not exist.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if(!!dst.uri) {
|
|
67
|
+
addresses.dsts.push([dst.addressName, new Address(dst.addressName, null, null, dst.port, Address.SUT, undefined, undefined, dst.uri)]);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// TODO: create log
|
|
71
|
+
ddb.error(`dst address interface '${dst.interfaceName}' does not exist.`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const srvAddresses = new Map();
|
|
75
|
+
srvs.forEach((srv) => {
|
|
76
|
+
const addressServer = addressesServerSearch.get(srv.interfaceName);
|
|
77
|
+
if(!!addressServer) {
|
|
78
|
+
const network = networkSearch.get(addressServer.networkName);
|
|
79
|
+
if(!!network) {
|
|
80
|
+
addresses.srvs.push([srv.addressName, new Address(srv.addressName, addressServer.address, network.family, srv.port, Address.SERVER, undefined, undefined, srv.uri)]);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.loginReport.networkLog(`Srv network '${addressServer.networkName}' does not exist.`);
|
|
84
|
+
// TODO: create log
|
|
85
|
+
ddb.error(`srv network '${addressServer.networkName}' does not exist.`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if(!!srv.uri) {
|
|
89
|
+
addresses.srvs.push([srv.addressName, new Address(srv.addressName, null, null, srv.port, Address.SERVER, undefined, undefined, srv.uri)]);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// TODO: create log
|
|
93
|
+
ddb.error(`srv address interface '${srv.interfaceName}' does not exist.`);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return addresses;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = Interfaces;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ActorPathGenerated = require('z-abs-corelayer-server/server/path/actor-path-generated');
|
|
5
|
+
const Fs = require('fs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LocalDns {
|
|
9
|
+
static save(dns, done) {
|
|
10
|
+
Fs.writeFile(ActorPathGenerated.getLocalDnsFile(), JSON.stringify(dns, null, 2), (err) => {
|
|
11
|
+
done(err);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static load(localDns, done) {
|
|
16
|
+
Fs.readFile(ActorPathGenerated.getLocalDnsFile(), (err, data) => {
|
|
17
|
+
if(err) {
|
|
18
|
+
return done(err);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const parsedDns = JSON.parse(data);
|
|
22
|
+
parsedDns.forEach((dns) => {
|
|
23
|
+
localDns.set(dns[0], dns[1]);
|
|
24
|
+
});
|
|
25
|
+
done();
|
|
26
|
+
}
|
|
27
|
+
catch(e) {
|
|
28
|
+
done(e);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
module.exports = LocalDns;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class LoginReport {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.logs = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
addressLog(action, status, log) {
|
|
11
|
+
this.logs.push({
|
|
12
|
+
reportType: 'address',
|
|
13
|
+
action: action,
|
|
14
|
+
status: status,
|
|
15
|
+
log: log
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
realAddressLog(action, status, log) {
|
|
20
|
+
this.logs.push({
|
|
21
|
+
reportType: 'real-address',
|
|
22
|
+
action: action,
|
|
23
|
+
status: status,
|
|
24
|
+
log: log
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
networkLog(action, status, log) {
|
|
29
|
+
this.logs.push({
|
|
30
|
+
reportType: 'network',
|
|
31
|
+
action: action,
|
|
32
|
+
status: status,
|
|
33
|
+
log: log
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interfaceLog(action, status, log) {
|
|
38
|
+
this.logs.push({
|
|
39
|
+
reportType: 'interface',
|
|
40
|
+
action: action,
|
|
41
|
+
status: status,
|
|
42
|
+
log: log
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
dnsLog(action, status, log) {
|
|
47
|
+
this.logs.push({
|
|
48
|
+
reportType: 'dns',
|
|
49
|
+
action: action,
|
|
50
|
+
status: status,
|
|
51
|
+
log: log
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = LoginReport;
|