@dxos/network-manager 0.1.58-main.f4192cb → 0.1.58-main.f69fa2f
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/dist/lib/browser/{chunk-HKHUCTRB.mjs → chunk-3KLH55NB.mjs} +114 -57
- package/dist/lib/browser/chunk-3KLH55NB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +5 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +10 -139
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +225 -56
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +91 -56
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/transport/index.d.ts +1 -0
- package/dist/types/src/transport/index.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.browser.d.ts +12 -0
- package/dist/types/src/transport/tcp-transport.browser.d.ts.map +1 -0
- package/package.json +18 -17
- package/src/swarm/connection.ts +4 -3
- package/src/swarm/peer.ts +5 -0
- package/src/transport/index.ts +1 -0
- package/src/transport/simplepeer-transport-service.ts +8 -1
- package/src/transport/simplepeer-transport.ts +5 -0
- package/src/transport/tcp-transport.browser.ts +28 -0
- package/dist/lib/browser/chunk-HKHUCTRB.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -527,6 +527,8 @@ __export(src_exports, {
|
|
|
527
527
|
Swarm: () => Swarm,
|
|
528
528
|
SwarmMapper: () => SwarmMapper,
|
|
529
529
|
SwarmMessenger: () => SwarmMessenger,
|
|
530
|
+
TcpTransport: () => TcpTransport,
|
|
531
|
+
TcpTransportFactory: () => TcpTransportFactory,
|
|
530
532
|
TransportKind: () => TransportKind,
|
|
531
533
|
cleanup: () => cleanup,
|
|
532
534
|
createLibDataChannelTransportFactory: () => createLibDataChannelTransportFactory,
|
|
@@ -735,7 +737,7 @@ var Connection = class {
|
|
|
735
737
|
this.closeReason = err?.message;
|
|
736
738
|
}
|
|
737
739
|
if (err instanceof import_protocols.ConnectionResetError) {
|
|
738
|
-
|
|
740
|
+
import_log.log.warn("aborting due to transport ConnectionResetError", void 0, {
|
|
739
741
|
F: __dxlog_file,
|
|
740
742
|
L: 197,
|
|
741
743
|
S: this,
|
|
@@ -743,7 +745,7 @@ var Connection = class {
|
|
|
743
745
|
});
|
|
744
746
|
this.abort().catch((err2) => this.errors.raise(err2));
|
|
745
747
|
} else if (err instanceof import_protocols.ConnectivityError) {
|
|
746
|
-
|
|
748
|
+
import_log.log.warn("aborting due to transport ConnectivityError", void 0, {
|
|
747
749
|
F: __dxlog_file,
|
|
748
750
|
L: 200,
|
|
749
751
|
S: this,
|
|
@@ -751,7 +753,7 @@ var Connection = class {
|
|
|
751
753
|
});
|
|
752
754
|
this.abort().catch((err2) => this.errors.raise(err2));
|
|
753
755
|
} else if (err instanceof import_protocols.UnknownProtocolError) {
|
|
754
|
-
|
|
756
|
+
import_log.log.warn("unsure what to do with UnknownProtocolError, will keep on truckin", {
|
|
755
757
|
err
|
|
756
758
|
}, {
|
|
757
759
|
F: __dxlog_file,
|
|
@@ -782,14 +784,14 @@ var Connection = class {
|
|
|
782
784
|
err
|
|
783
785
|
}, {
|
|
784
786
|
F: __dxlog_file,
|
|
785
|
-
L:
|
|
787
|
+
L: 225,
|
|
786
788
|
S: this,
|
|
787
789
|
C: (f, a) => f(...a)
|
|
788
790
|
});
|
|
789
791
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
790
792
|
(0, import_log.log)(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
791
793
|
F: __dxlog_file,
|
|
792
|
-
L:
|
|
794
|
+
L: 227,
|
|
793
795
|
S: this,
|
|
794
796
|
C: (f, a) => f(...a)
|
|
795
797
|
});
|
|
@@ -805,7 +807,7 @@ var Connection = class {
|
|
|
805
807
|
proto: this._protocol
|
|
806
808
|
}, {
|
|
807
809
|
F: __dxlog_file,
|
|
808
|
-
L:
|
|
810
|
+
L: 240,
|
|
809
811
|
S: this,
|
|
810
812
|
C: (f, a) => f(...a)
|
|
811
813
|
});
|
|
@@ -813,7 +815,7 @@ var Connection = class {
|
|
|
813
815
|
} catch (err2) {
|
|
814
816
|
import_log.log.catch(err2, void 0, {
|
|
815
817
|
F: __dxlog_file,
|
|
816
|
-
L:
|
|
818
|
+
L: 243,
|
|
817
819
|
S: this,
|
|
818
820
|
C: (f, a) => f(...a)
|
|
819
821
|
});
|
|
@@ -823,7 +825,7 @@ var Connection = class {
|
|
|
823
825
|
} catch (err2) {
|
|
824
826
|
import_log.log.catch(err2, void 0, {
|
|
825
827
|
F: __dxlog_file,
|
|
826
|
-
L:
|
|
828
|
+
L: 250,
|
|
827
829
|
S: this,
|
|
828
830
|
C: (f, a) => f(...a)
|
|
829
831
|
});
|
|
@@ -833,7 +835,7 @@ var Connection = class {
|
|
|
833
835
|
} catch (err2) {
|
|
834
836
|
import_log.log.catch(err2, void 0, {
|
|
835
837
|
F: __dxlog_file,
|
|
836
|
-
L:
|
|
838
|
+
L: 256,
|
|
837
839
|
S: this,
|
|
838
840
|
C: (f, a) => f(...a)
|
|
839
841
|
});
|
|
@@ -854,7 +856,7 @@ var Connection = class {
|
|
|
854
856
|
peerId: this.ownId
|
|
855
857
|
}, {
|
|
856
858
|
F: __dxlog_file,
|
|
857
|
-
L:
|
|
859
|
+
L: 278,
|
|
858
860
|
S: this,
|
|
859
861
|
C: (f, a) => f(...a)
|
|
860
862
|
});
|
|
@@ -864,7 +866,7 @@ var Connection = class {
|
|
|
864
866
|
} catch (err2) {
|
|
865
867
|
import_log.log.catch(err2, void 0, {
|
|
866
868
|
F: __dxlog_file,
|
|
867
|
-
L:
|
|
869
|
+
L: 285,
|
|
868
870
|
S: this,
|
|
869
871
|
C: (f, a) => f(...a)
|
|
870
872
|
});
|
|
@@ -874,7 +876,7 @@ var Connection = class {
|
|
|
874
876
|
} catch (err2) {
|
|
875
877
|
import_log.log.catch(err2, void 0, {
|
|
876
878
|
F: __dxlog_file,
|
|
877
|
-
L:
|
|
879
|
+
L: 292,
|
|
878
880
|
S: this,
|
|
879
881
|
C: (f, a) => f(...a)
|
|
880
882
|
});
|
|
@@ -884,7 +886,7 @@ var Connection = class {
|
|
|
884
886
|
peerId: this.ownId
|
|
885
887
|
}, {
|
|
886
888
|
F: __dxlog_file,
|
|
887
|
-
L:
|
|
889
|
+
L: 296,
|
|
888
890
|
S: this,
|
|
889
891
|
C: (f, a) => f(...a)
|
|
890
892
|
});
|
|
@@ -927,7 +929,7 @@ var Connection = class {
|
|
|
927
929
|
err
|
|
928
930
|
}, {
|
|
929
931
|
F: __dxlog_file,
|
|
930
|
-
L:
|
|
932
|
+
L: 333,
|
|
931
933
|
S: this,
|
|
932
934
|
C: (f, a) => f(...a)
|
|
933
935
|
});
|
|
@@ -940,7 +942,7 @@ var Connection = class {
|
|
|
940
942
|
async signal(msg) {
|
|
941
943
|
(0, import_invariant.invariant)(msg.sessionId, void 0, {
|
|
942
944
|
F: __dxlog_file,
|
|
943
|
-
L:
|
|
945
|
+
L: 342,
|
|
944
946
|
S: this,
|
|
945
947
|
A: [
|
|
946
948
|
"msg.sessionId",
|
|
@@ -950,7 +952,7 @@ var Connection = class {
|
|
|
950
952
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
951
953
|
(0, import_log.log)("dropping signal for incorrect session id", void 0, {
|
|
952
954
|
F: __dxlog_file,
|
|
953
|
-
L:
|
|
955
|
+
L: 344,
|
|
954
956
|
S: this,
|
|
955
957
|
C: (f, a) => f(...a)
|
|
956
958
|
});
|
|
@@ -958,7 +960,7 @@ var Connection = class {
|
|
|
958
960
|
}
|
|
959
961
|
(0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
960
962
|
F: __dxlog_file,
|
|
961
|
-
L:
|
|
963
|
+
L: 347,
|
|
962
964
|
S: this,
|
|
963
965
|
A: [
|
|
964
966
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -967,7 +969,7 @@ var Connection = class {
|
|
|
967
969
|
});
|
|
968
970
|
(0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
|
|
969
971
|
F: __dxlog_file,
|
|
970
|
-
L:
|
|
972
|
+
L: 348,
|
|
971
973
|
S: this,
|
|
972
974
|
A: [
|
|
973
975
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -976,7 +978,7 @@ var Connection = class {
|
|
|
976
978
|
});
|
|
977
979
|
(0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
|
|
978
980
|
F: __dxlog_file,
|
|
979
|
-
L:
|
|
981
|
+
L: 349,
|
|
980
982
|
S: this,
|
|
981
983
|
A: [
|
|
982
984
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -1000,7 +1002,7 @@ var Connection = class {
|
|
|
1000
1002
|
msg: msg.data
|
|
1001
1003
|
}, {
|
|
1002
1004
|
F: __dxlog_file,
|
|
1003
|
-
L:
|
|
1005
|
+
L: 358,
|
|
1004
1006
|
S: this,
|
|
1005
1007
|
C: (f, a) => f(...a)
|
|
1006
1008
|
});
|
|
@@ -1008,7 +1010,7 @@ var Connection = class {
|
|
|
1008
1010
|
} else {
|
|
1009
1011
|
(0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
|
|
1010
1012
|
F: __dxlog_file,
|
|
1011
|
-
L:
|
|
1013
|
+
L: 361,
|
|
1012
1014
|
S: this,
|
|
1013
1015
|
A: [
|
|
1014
1016
|
"this._transport",
|
|
@@ -1021,7 +1023,7 @@ var Connection = class {
|
|
|
1021
1023
|
msg: msg.data
|
|
1022
1024
|
}, {
|
|
1023
1025
|
F: __dxlog_file,
|
|
1024
|
-
L:
|
|
1026
|
+
L: 362,
|
|
1025
1027
|
S: this,
|
|
1026
1028
|
C: (f, a) => f(...a)
|
|
1027
1029
|
});
|
|
@@ -1039,13 +1041,13 @@ var Connection = class {
|
|
|
1039
1041
|
peerId: this.ownId
|
|
1040
1042
|
}, {
|
|
1041
1043
|
F: __dxlog_file,
|
|
1042
|
-
L:
|
|
1044
|
+
L: 373,
|
|
1043
1045
|
S: this,
|
|
1044
1046
|
C: (f, a) => f(...a)
|
|
1045
1047
|
});
|
|
1046
1048
|
(0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
|
|
1047
1049
|
F: __dxlog_file,
|
|
1048
|
-
L:
|
|
1050
|
+
L: 374,
|
|
1049
1051
|
S: this,
|
|
1050
1052
|
A: [
|
|
1051
1053
|
"state !== this._state",
|
|
@@ -1120,6 +1122,20 @@ var Peer = class {
|
|
|
1120
1122
|
*/
|
|
1121
1123
|
async onOffer(message) {
|
|
1122
1124
|
const remoteId = message.author;
|
|
1125
|
+
if (this.connection && ![
|
|
1126
|
+
ConnectionState.CREATED,
|
|
1127
|
+
ConnectionState.INITIAL
|
|
1128
|
+
].includes(this.connection.state)) {
|
|
1129
|
+
import_log2.log.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
|
|
1130
|
+
F: __dxlog_file2,
|
|
1131
|
+
L: 112,
|
|
1132
|
+
S: this,
|
|
1133
|
+
C: (f, a) => f(...a)
|
|
1134
|
+
});
|
|
1135
|
+
return {
|
|
1136
|
+
accept: false
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1123
1139
|
if (this.connection || this.initiating) {
|
|
1124
1140
|
if (remoteId.toHex() < this.localPeerId.toHex()) {
|
|
1125
1141
|
(0, import_log2.log)("close local connection", {
|
|
@@ -1129,7 +1145,7 @@ var Peer = class {
|
|
|
1129
1145
|
sessionId: this.connection?.sessionId
|
|
1130
1146
|
}, {
|
|
1131
1147
|
F: __dxlog_file2,
|
|
1132
|
-
L:
|
|
1148
|
+
L: 121,
|
|
1133
1149
|
S: this,
|
|
1134
1150
|
C: (f, a) => f(...a)
|
|
1135
1151
|
});
|
|
@@ -1146,7 +1162,7 @@ var Peer = class {
|
|
|
1146
1162
|
if (!this.connection) {
|
|
1147
1163
|
(0, import_invariant2.invariant)(message.sessionId, void 0, {
|
|
1148
1164
|
F: __dxlog_file2,
|
|
1149
|
-
L:
|
|
1165
|
+
L: 141,
|
|
1150
1166
|
S: this,
|
|
1151
1167
|
A: [
|
|
1152
1168
|
"message.sessionId",
|
|
@@ -1167,7 +1183,7 @@ var Peer = class {
|
|
|
1167
1183
|
err
|
|
1168
1184
|
}, {
|
|
1169
1185
|
F: __dxlog_file2,
|
|
1170
|
-
L:
|
|
1186
|
+
L: 151,
|
|
1171
1187
|
S: this,
|
|
1172
1188
|
C: (f, a) => f(...a)
|
|
1173
1189
|
});
|
|
@@ -1189,7 +1205,7 @@ var Peer = class {
|
|
|
1189
1205
|
async initiateConnection() {
|
|
1190
1206
|
(0, import_invariant2.invariant)(!this.initiating, "Initiation in progress.", {
|
|
1191
1207
|
F: __dxlog_file2,
|
|
1192
|
-
L:
|
|
1208
|
+
L: 168,
|
|
1193
1209
|
S: this,
|
|
1194
1210
|
A: [
|
|
1195
1211
|
"!this.initiating",
|
|
@@ -1198,7 +1214,7 @@ var Peer = class {
|
|
|
1198
1214
|
});
|
|
1199
1215
|
(0, import_invariant2.invariant)(!this.connection, "Already connected.", {
|
|
1200
1216
|
F: __dxlog_file2,
|
|
1201
|
-
L:
|
|
1217
|
+
L: 169,
|
|
1202
1218
|
S: this,
|
|
1203
1219
|
A: [
|
|
1204
1220
|
"!this.connection",
|
|
@@ -1213,7 +1229,7 @@ var Peer = class {
|
|
|
1213
1229
|
sessionId
|
|
1214
1230
|
}, {
|
|
1215
1231
|
F: __dxlog_file2,
|
|
1216
|
-
L:
|
|
1232
|
+
L: 171,
|
|
1217
1233
|
S: this,
|
|
1218
1234
|
C: (f, a) => f(...a)
|
|
1219
1235
|
});
|
|
@@ -1238,14 +1254,14 @@ var Peer = class {
|
|
|
1238
1254
|
remoteId: this.id
|
|
1239
1255
|
}, {
|
|
1240
1256
|
F: __dxlog_file2,
|
|
1241
|
-
L:
|
|
1257
|
+
L: 187,
|
|
1242
1258
|
S: this,
|
|
1243
1259
|
C: (f, a) => f(...a)
|
|
1244
1260
|
});
|
|
1245
1261
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
1246
1262
|
(0, import_log2.log)("ignoring response", void 0, {
|
|
1247
1263
|
F: __dxlog_file2,
|
|
1248
|
-
L:
|
|
1264
|
+
L: 189,
|
|
1249
1265
|
S: this,
|
|
1250
1266
|
C: (f, a) => f(...a)
|
|
1251
1267
|
});
|
|
@@ -1265,11 +1281,17 @@ var Peer = class {
|
|
|
1265
1281
|
remoteId: this.id
|
|
1266
1282
|
}, {
|
|
1267
1283
|
F: __dxlog_file2,
|
|
1268
|
-
L:
|
|
1284
|
+
L: 200,
|
|
1269
1285
|
S: this,
|
|
1270
1286
|
C: (f, a) => f(...a)
|
|
1271
1287
|
});
|
|
1272
1288
|
if (err instanceof import_protocols2.TimeoutError) {
|
|
1289
|
+
import_log2.log.warn("aborting connection due to signalling failure", void 0, {
|
|
1290
|
+
F: __dxlog_file2,
|
|
1291
|
+
L: 202,
|
|
1292
|
+
S: this,
|
|
1293
|
+
C: (f, a) => f(...a)
|
|
1294
|
+
});
|
|
1273
1295
|
await connection.abort(err);
|
|
1274
1296
|
}
|
|
1275
1297
|
await this.closeConnection(err);
|
|
@@ -1291,13 +1313,13 @@ var Peer = class {
|
|
|
1291
1313
|
sessionId
|
|
1292
1314
|
}, {
|
|
1293
1315
|
F: __dxlog_file2,
|
|
1294
|
-
L:
|
|
1316
|
+
L: 218,
|
|
1295
1317
|
S: this,
|
|
1296
1318
|
C: (f, a) => f(...a)
|
|
1297
1319
|
});
|
|
1298
1320
|
(0, import_invariant2.invariant)(!this.connection, "Already connected.", {
|
|
1299
1321
|
F: __dxlog_file2,
|
|
1300
|
-
L:
|
|
1322
|
+
L: 225,
|
|
1301
1323
|
S: this,
|
|
1302
1324
|
A: [
|
|
1303
1325
|
"!this.connection",
|
|
@@ -1333,7 +1355,7 @@ var Peer = class {
|
|
|
1333
1355
|
initiator
|
|
1334
1356
|
}, {
|
|
1335
1357
|
F: __dxlog_file2,
|
|
1336
|
-
L:
|
|
1358
|
+
L: 244,
|
|
1337
1359
|
S: this,
|
|
1338
1360
|
C: (f, a) => f(...a)
|
|
1339
1361
|
});
|
|
@@ -1346,14 +1368,14 @@ var Peer = class {
|
|
|
1346
1368
|
initiator
|
|
1347
1369
|
}, {
|
|
1348
1370
|
F: __dxlog_file2,
|
|
1349
|
-
L:
|
|
1371
|
+
L: 253,
|
|
1350
1372
|
S: this,
|
|
1351
1373
|
C: (f, a) => f(...a)
|
|
1352
1374
|
});
|
|
1353
1375
|
this._connectionLimiter.doneConnecting(sessionId);
|
|
1354
1376
|
(0, import_invariant2.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
|
|
1355
1377
|
F: __dxlog_file2,
|
|
1356
|
-
L:
|
|
1378
|
+
L: 258,
|
|
1357
1379
|
S: this,
|
|
1358
1380
|
A: [
|
|
1359
1381
|
"this.connection === connection",
|
|
@@ -1368,7 +1390,7 @@ var Peer = class {
|
|
|
1368
1390
|
initiator
|
|
1369
1391
|
}, {
|
|
1370
1392
|
F: __dxlog_file2,
|
|
1371
|
-
L:
|
|
1393
|
+
L: 260,
|
|
1372
1394
|
S: this,
|
|
1373
1395
|
C: (f, a) => f(...a)
|
|
1374
1396
|
});
|
|
@@ -1403,7 +1425,7 @@ var Peer = class {
|
|
|
1403
1425
|
err
|
|
1404
1426
|
}, {
|
|
1405
1427
|
F: __dxlog_file2,
|
|
1406
|
-
L:
|
|
1428
|
+
L: 300,
|
|
1407
1429
|
S: this,
|
|
1408
1430
|
C: (f, a) => f(...a)
|
|
1409
1431
|
});
|
|
@@ -1416,7 +1438,7 @@ var Peer = class {
|
|
|
1416
1438
|
err
|
|
1417
1439
|
}, {
|
|
1418
1440
|
F: __dxlog_file2,
|
|
1419
|
-
L:
|
|
1441
|
+
L: 301,
|
|
1420
1442
|
S: this,
|
|
1421
1443
|
C: (f, a) => f(...a)
|
|
1422
1444
|
});
|
|
@@ -1435,7 +1457,7 @@ var Peer = class {
|
|
|
1435
1457
|
sessionId: connection.sessionId
|
|
1436
1458
|
}, {
|
|
1437
1459
|
F: __dxlog_file2,
|
|
1438
|
-
L:
|
|
1460
|
+
L: 326,
|
|
1439
1461
|
S: this,
|
|
1440
1462
|
C: (f, a) => f(...a)
|
|
1441
1463
|
});
|
|
@@ -1445,7 +1467,7 @@ var Peer = class {
|
|
|
1445
1467
|
sessionId: connection.sessionId
|
|
1446
1468
|
}, {
|
|
1447
1469
|
F: __dxlog_file2,
|
|
1448
|
-
L:
|
|
1470
|
+
L: 332,
|
|
1449
1471
|
S: this,
|
|
1450
1472
|
C: (f, a) => f(...a)
|
|
1451
1473
|
});
|
|
@@ -1456,7 +1478,7 @@ var Peer = class {
|
|
|
1456
1478
|
message
|
|
1457
1479
|
}, {
|
|
1458
1480
|
F: __dxlog_file2,
|
|
1459
|
-
L:
|
|
1481
|
+
L: 337,
|
|
1460
1482
|
S: this,
|
|
1461
1483
|
C: (f, a) => f(...a)
|
|
1462
1484
|
});
|
|
@@ -1471,7 +1493,7 @@ var Peer = class {
|
|
|
1471
1493
|
topic: this.topic
|
|
1472
1494
|
}, {
|
|
1473
1495
|
F: __dxlog_file2,
|
|
1474
|
-
L:
|
|
1496
|
+
L: 347,
|
|
1475
1497
|
S: this,
|
|
1476
1498
|
C: (f, a) => f(...a)
|
|
1477
1499
|
});
|
|
@@ -3205,24 +3227,28 @@ var SimplePeerTransport = class {
|
|
|
3205
3227
|
switch (err.code) {
|
|
3206
3228
|
case "ERR_WEBRTC_SUPPORT":
|
|
3207
3229
|
this.errors.raise(new import_protocols7.ProtocolError("WebRTC not supported", err));
|
|
3230
|
+
break;
|
|
3208
3231
|
case "ERR_ICE_CONNECTION_FAILURE":
|
|
3209
3232
|
case "ERR_DATA_CHANNEL":
|
|
3210
3233
|
case "ERR_CONNECTION_FAILURE":
|
|
3211
3234
|
case "ERR_SIGNALING":
|
|
3212
3235
|
this.errors.raise(new import_protocols7.ConnectivityError("unknown communication failure", err));
|
|
3236
|
+
break;
|
|
3213
3237
|
case "ERR_CREATE_OFFER":
|
|
3214
3238
|
case "ERR_CREATE_ANSWER":
|
|
3215
3239
|
case "ERR_SET_LOCAL_DESCRIPTION":
|
|
3216
3240
|
case "ERR_SET_REMOTE_DESCRIPTION":
|
|
3217
3241
|
case "ERR_ADD_ICE_CANDIDATE":
|
|
3218
3242
|
this.errors.raise(new import_protocols7.UnknownProtocolError("unknown simple-peer library failure", err));
|
|
3243
|
+
break;
|
|
3219
3244
|
default:
|
|
3220
3245
|
this.errors.raise(new Error("unknown simple-peer error"));
|
|
3246
|
+
break;
|
|
3221
3247
|
}
|
|
3222
3248
|
} else {
|
|
3223
3249
|
import_log11.log.info("unknown peer connection error", err, {
|
|
3224
3250
|
F: __dxlog_file12,
|
|
3225
|
-
L:
|
|
3251
|
+
L: 101,
|
|
3226
3252
|
S: this,
|
|
3227
3253
|
C: (f, a) => f(...a)
|
|
3228
3254
|
});
|
|
@@ -3236,7 +3262,7 @@ var SimplePeerTransport = class {
|
|
|
3236
3262
|
stats
|
|
3237
3263
|
}, {
|
|
3238
3264
|
F: __dxlog_file12,
|
|
3239
|
-
L:
|
|
3265
|
+
L: 109,
|
|
3240
3266
|
S: this,
|
|
3241
3267
|
C: (f, a) => f(...a)
|
|
3242
3268
|
});
|
|
@@ -3245,7 +3271,7 @@ var SimplePeerTransport = class {
|
|
|
3245
3271
|
} catch (err2) {
|
|
3246
3272
|
import_log11.log.catch(err2, void 0, {
|
|
3247
3273
|
F: __dxlog_file12,
|
|
3248
|
-
L:
|
|
3274
|
+
L: 116,
|
|
3249
3275
|
S: this,
|
|
3250
3276
|
C: (f, a) => f(...a)
|
|
3251
3277
|
});
|
|
@@ -3256,7 +3282,7 @@ var SimplePeerTransport = class {
|
|
|
3256
3282
|
id: this._instanceId
|
|
3257
3283
|
}), {
|
|
3258
3284
|
F: __dxlog_file12,
|
|
3259
|
-
L:
|
|
3285
|
+
L: 121,
|
|
3260
3286
|
S: this,
|
|
3261
3287
|
C: (f, a) => f(...a)
|
|
3262
3288
|
});
|
|
@@ -3264,7 +3290,7 @@ var SimplePeerTransport = class {
|
|
|
3264
3290
|
async destroy() {
|
|
3265
3291
|
(0, import_log11.log)("closing...", void 0, {
|
|
3266
3292
|
F: __dxlog_file12,
|
|
3267
|
-
L:
|
|
3293
|
+
L: 125,
|
|
3268
3294
|
S: this,
|
|
3269
3295
|
C: (f, a) => f(...a)
|
|
3270
3296
|
});
|
|
@@ -3274,7 +3300,7 @@ var SimplePeerTransport = class {
|
|
|
3274
3300
|
this.closed.emit();
|
|
3275
3301
|
(0, import_log11.log)("closed", void 0, {
|
|
3276
3302
|
F: __dxlog_file12,
|
|
3277
|
-
L:
|
|
3303
|
+
L: 130,
|
|
3278
3304
|
S: this,
|
|
3279
3305
|
C: (f, a) => f(...a)
|
|
3280
3306
|
});
|
|
@@ -3376,7 +3402,8 @@ var SimplePeerTransportService = class {
|
|
|
3376
3402
|
const transportState = {
|
|
3377
3403
|
transport,
|
|
3378
3404
|
stream: duplex,
|
|
3379
|
-
writeCallbacks: []
|
|
3405
|
+
writeCallbacks: [],
|
|
3406
|
+
state: "OPEN"
|
|
3380
3407
|
};
|
|
3381
3408
|
ready();
|
|
3382
3409
|
this.transports.set(request.proxyId, transportState);
|
|
@@ -3386,7 +3413,7 @@ var SimplePeerTransportService = class {
|
|
|
3386
3413
|
async sendSignal({ proxyId, signal }) {
|
|
3387
3414
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3388
3415
|
F: __dxlog_file13,
|
|
3389
|
-
L:
|
|
3416
|
+
L: 112,
|
|
3390
3417
|
S: this,
|
|
3391
3418
|
A: [
|
|
3392
3419
|
"this.transports.has(proxyId)",
|
|
@@ -3396,9 +3423,17 @@ var SimplePeerTransportService = class {
|
|
|
3396
3423
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
3397
3424
|
}
|
|
3398
3425
|
async sendData({ proxyId, payload }) {
|
|
3426
|
+
if (this.transports.get(proxyId)?.state !== "OPEN") {
|
|
3427
|
+
import_log12.log.debug("transport is closed", void 0, {
|
|
3428
|
+
F: __dxlog_file13,
|
|
3429
|
+
L: 118,
|
|
3430
|
+
S: this,
|
|
3431
|
+
C: (f, a) => f(...a)
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3399
3434
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3400
3435
|
F: __dxlog_file13,
|
|
3401
|
-
L:
|
|
3436
|
+
L: 120,
|
|
3402
3437
|
S: this,
|
|
3403
3438
|
A: [
|
|
3404
3439
|
"this.transports.has(proxyId)",
|
|
@@ -3416,10 +3451,12 @@ var SimplePeerTransportService = class {
|
|
|
3416
3451
|
async close({ proxyId }) {
|
|
3417
3452
|
await this.transports.get(proxyId)?.transport.destroy();
|
|
3418
3453
|
await this.transports.get(proxyId)?.stream.end();
|
|
3419
|
-
this.transports.
|
|
3454
|
+
if (this.transports.get(proxyId)) {
|
|
3455
|
+
this.transports.get(proxyId).state = "CLOSED";
|
|
3456
|
+
}
|
|
3420
3457
|
(0, import_log12.log)("Closed.", void 0, {
|
|
3421
3458
|
F: __dxlog_file13,
|
|
3422
|
-
L:
|
|
3459
|
+
L: 136,
|
|
3423
3460
|
S: this,
|
|
3424
3461
|
C: (f, a) => f(...a)
|
|
3425
3462
|
});
|
|
@@ -3941,6 +3978,136 @@ var createLibDataChannelTransportFactory = (webrtcConfig) => ({
|
|
|
3941
3978
|
})
|
|
3942
3979
|
});
|
|
3943
3980
|
|
|
3981
|
+
// packages/core/mesh/network-manager/src/transport/tcp-transport.ts
|
|
3982
|
+
var import_node_net = require("node:net");
|
|
3983
|
+
var import_async12 = require("@dxos/async");
|
|
3984
|
+
var import_debug8 = require("@dxos/debug");
|
|
3985
|
+
var import_log15 = require("@dxos/log");
|
|
3986
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/tcp-transport.ts";
|
|
3987
|
+
var TcpTransportFactory = {
|
|
3988
|
+
createTransport: (params) => new TcpTransport(params)
|
|
3989
|
+
};
|
|
3990
|
+
var TcpTransport = class {
|
|
3991
|
+
constructor(options) {
|
|
3992
|
+
this.options = options;
|
|
3993
|
+
this._server = void 0;
|
|
3994
|
+
this._socket = void 0;
|
|
3995
|
+
this.closed = new import_async12.Event();
|
|
3996
|
+
this.connected = new import_async12.Event();
|
|
3997
|
+
this.errors = new import_debug8.ErrorStream();
|
|
3998
|
+
this._destroyed = false;
|
|
3999
|
+
this._connected = false;
|
|
4000
|
+
(0, import_log15.log)("creating", void 0, {
|
|
4001
|
+
F: __dxlog_file16,
|
|
4002
|
+
L: 34,
|
|
4003
|
+
S: this,
|
|
4004
|
+
C: (f, a) => f(...a)
|
|
4005
|
+
});
|
|
4006
|
+
if (this.options.initiator) {
|
|
4007
|
+
setTimeout(async () => {
|
|
4008
|
+
const { Server } = await import("node:net");
|
|
4009
|
+
this._server = new Server((socket) => {
|
|
4010
|
+
(0, import_log15.log)("new connection", void 0, {
|
|
4011
|
+
F: __dxlog_file16,
|
|
4012
|
+
L: 42,
|
|
4013
|
+
S: this,
|
|
4014
|
+
C: (f, a) => f(...a)
|
|
4015
|
+
});
|
|
4016
|
+
if (this._connected) {
|
|
4017
|
+
socket.destroy();
|
|
4018
|
+
}
|
|
4019
|
+
this._handleSocket(socket);
|
|
4020
|
+
});
|
|
4021
|
+
this._server.on("listening", () => {
|
|
4022
|
+
const { port } = this._server.address();
|
|
4023
|
+
(0, import_log15.log)("listening", {
|
|
4024
|
+
port
|
|
4025
|
+
}, {
|
|
4026
|
+
F: __dxlog_file16,
|
|
4027
|
+
L: 51,
|
|
4028
|
+
S: this,
|
|
4029
|
+
C: (f, a) => f(...a)
|
|
4030
|
+
});
|
|
4031
|
+
void this.options.sendSignal({
|
|
4032
|
+
payload: {
|
|
4033
|
+
port
|
|
4034
|
+
}
|
|
4035
|
+
}).catch((err) => {
|
|
4036
|
+
if (!this._destroyed) {
|
|
4037
|
+
this.errors.raise(err);
|
|
4038
|
+
}
|
|
4039
|
+
});
|
|
4040
|
+
});
|
|
4041
|
+
this._server.on("error", (err) => {
|
|
4042
|
+
this.errors.raise(err);
|
|
4043
|
+
});
|
|
4044
|
+
this._server.listen(0);
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
async destroy() {
|
|
4049
|
+
(0, import_log15.log)("closing", void 0, {
|
|
4050
|
+
F: __dxlog_file16,
|
|
4051
|
+
L: 72,
|
|
4052
|
+
S: this,
|
|
4053
|
+
C: (f, a) => f(...a)
|
|
4054
|
+
});
|
|
4055
|
+
this._socket?.destroy();
|
|
4056
|
+
this._server?.close();
|
|
4057
|
+
this._destroyed = true;
|
|
4058
|
+
}
|
|
4059
|
+
signal({ payload }) {
|
|
4060
|
+
(0, import_log15.log)("received signal", {
|
|
4061
|
+
payload
|
|
4062
|
+
}, {
|
|
4063
|
+
F: __dxlog_file16,
|
|
4064
|
+
L: 80,
|
|
4065
|
+
S: this,
|
|
4066
|
+
C: (f, a) => f(...a)
|
|
4067
|
+
});
|
|
4068
|
+
if (this.options.initiator || this._connected) {
|
|
4069
|
+
return;
|
|
4070
|
+
}
|
|
4071
|
+
const socket = new import_node_net.Socket();
|
|
4072
|
+
this._handleSocket(socket);
|
|
4073
|
+
socket.connect({
|
|
4074
|
+
port: payload.port,
|
|
4075
|
+
host: "localhost"
|
|
4076
|
+
});
|
|
4077
|
+
}
|
|
4078
|
+
_handleSocket(socket) {
|
|
4079
|
+
(0, import_log15.log)("handling socket", {
|
|
4080
|
+
remotePort: socket.remotePort,
|
|
4081
|
+
localPort: socket.localPort
|
|
4082
|
+
}, {
|
|
4083
|
+
F: __dxlog_file16,
|
|
4084
|
+
L: 91,
|
|
4085
|
+
S: this,
|
|
4086
|
+
C: (f, a) => f(...a)
|
|
4087
|
+
});
|
|
4088
|
+
this._socket = socket;
|
|
4089
|
+
this.connected.emit();
|
|
4090
|
+
this.options.stream.pipe(this._socket).pipe(this.options.stream);
|
|
4091
|
+
this._socket.on("connect", () => {
|
|
4092
|
+
(0, import_log15.log)("connected to", {
|
|
4093
|
+
port: this._socket?.remotePort
|
|
4094
|
+
}, {
|
|
4095
|
+
F: __dxlog_file16,
|
|
4096
|
+
L: 97,
|
|
4097
|
+
S: this,
|
|
4098
|
+
C: (f, a) => f(...a)
|
|
4099
|
+
});
|
|
4100
|
+
this._connected = true;
|
|
4101
|
+
});
|
|
4102
|
+
this._socket.on("error", (err) => {
|
|
4103
|
+
this.errors.raise(err);
|
|
4104
|
+
});
|
|
4105
|
+
this._socket.on("close", () => {
|
|
4106
|
+
this.closed.emit();
|
|
4107
|
+
});
|
|
4108
|
+
}
|
|
4109
|
+
};
|
|
4110
|
+
|
|
3944
4111
|
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
3945
4112
|
var import_teleport = require("@dxos/teleport");
|
|
3946
4113
|
var createTeleportProtocolFactory = (onConnection) => {
|
|
@@ -3986,6 +4153,8 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3986
4153
|
Swarm,
|
|
3987
4154
|
SwarmMapper,
|
|
3988
4155
|
SwarmMessenger,
|
|
4156
|
+
TcpTransport,
|
|
4157
|
+
TcpTransportFactory,
|
|
3989
4158
|
TransportKind,
|
|
3990
4159
|
cleanup,
|
|
3991
4160
|
createLibDataChannelTransportFactory,
|