webpeerjs 0.0.1
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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/webpeerjs.d.ts +16 -0
- package/dist/esm/webpeerjs.js +1600 -0
- package/dist/umd/package.json +1 -0
- package/dist/umd/webpeerjs.js +44177 -0
- package/package.json +83 -0
- package/src/config.js +286 -0
- package/src/umd.js +3 -0
- package/src/utils.js +178 -0
- package/src/webpeerjs.js +1188 -0
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "webpeerjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Simple peer-to-peer with IPFS",
|
|
5
|
+
"main": "./dist/umd/webpeerjs.js",
|
|
6
|
+
"module": "./dist/esm/webpeerjs.js",
|
|
7
|
+
"imports": {
|
|
8
|
+
"#/pubsub-peer-discovery/*.js": "./node_modules/@libp2p/pubsub-peer-discovery/dist/src/*.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/esm/webpeerjs.js",
|
|
13
|
+
"require": "./dist/umd/webpeerjs.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/",
|
|
18
|
+
"src/",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "npm run dev",
|
|
23
|
+
"dev": "vite serve test",
|
|
24
|
+
"eslint": "eslint ./src",
|
|
25
|
+
"eslint:fix": "eslint ./src --fix",
|
|
26
|
+
|
|
27
|
+
"removedir": "node -e \"var fs = require('fs'); try{process.argv.slice(1).map((fpath) => fs.rmdirSync(fpath, { recursive: true }))}catch(err){console.log(`Dist not found`)}; process.exit(0);\"",
|
|
28
|
+
"build-all": "tsc -p config/tsconfig-rollup.json && rollup -c temp/config/rollup.config.build.js && echo {\"type\": \"commonjs\",\"types\": \"webpeerjs.d.ts\"}>dist\\umd\\package.json && echo {\"type\": \"module\",\"types\": \"webpeerjs.d.ts\"}>dist\\esm\\package.json",
|
|
29
|
+
"build-types": "tsc -p config/tsconfig-esm.json",
|
|
30
|
+
"build": "npm run removedir dist temp && npm run build-all && npm run build-types",
|
|
31
|
+
|
|
32
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/nuzulul/webpeerjs.git"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"p2p",
|
|
40
|
+
"ipfs",
|
|
41
|
+
"peer",
|
|
42
|
+
"peer to peer",
|
|
43
|
+
"decentralized",
|
|
44
|
+
"browser to browser"
|
|
45
|
+
],
|
|
46
|
+
"author": {
|
|
47
|
+
"name": "Nuzulul Zulkarnain",
|
|
48
|
+
"url": "https://nuzulul.github.io"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/nuzulul/webpeerjs/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/nuzulul/webpeerjs#readme",
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@chainsafe/libp2p-gossipsub": "^13.0.0",
|
|
57
|
+
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
58
|
+
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
59
|
+
"@helia/delegated-routing-v1-http-api-client": "^3.0.1",
|
|
60
|
+
"@libp2p/circuit-relay-v2": "^1.0.24",
|
|
61
|
+
"@libp2p/identify": "^2.0.2",
|
|
62
|
+
"@libp2p/kad-dht": "^12.0.17",
|
|
63
|
+
"@libp2p/peer-id": "^4.1.2",
|
|
64
|
+
"@libp2p/pubsub-peer-discovery": "^10.0.2",
|
|
65
|
+
"@libp2p/simple-metrics": "^1.0.2",
|
|
66
|
+
"@libp2p/webtransport": "^4.0.32",
|
|
67
|
+
"@multiformats/multiaddr": "^12.2.3",
|
|
68
|
+
"datastore-idb": "^2.1.9",
|
|
69
|
+
"libp2p": "^1.6.0"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@eslint/js": "^9.4.0",
|
|
73
|
+
"eslint": "^9.4.0",
|
|
74
|
+
"globals": "^15.3.0",
|
|
75
|
+
"vite": "^5.2.11",
|
|
76
|
+
"@rollup/plugin-commonjs": "^25.0.8",
|
|
77
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
78
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
79
|
+
"rollup": "^4.18.0",
|
|
80
|
+
"tslib": "^2.6.2",
|
|
81
|
+
"typescript": "^5.4.5"
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
const prefix = 'webpeerjs'
|
|
2
|
+
export const CONFIG_PREFIX = prefix
|
|
3
|
+
export const CONFIG_BLOCKSTORE_PATH = prefix+'-blockstore'
|
|
4
|
+
export const CONFIG_DATASTORE_PATH = prefix+'-datastore'
|
|
5
|
+
export const CONFIG_DBSTORE_PATH = prefix+'-dbstore'
|
|
6
|
+
export const CONFIG_MAX_CONNECTIONS = 50
|
|
7
|
+
export const CONFIG_MIN_CONNECTIONS = 0
|
|
8
|
+
export const CONFIG_DISCOVER_RELAYS = 2
|
|
9
|
+
export const CONFIG_PEER_DISCOVERY_UNIVERSAL_CONNECTIVITY = 'universal-connectivity-browser-peer-discovery'
|
|
10
|
+
export const CONFIG_PUBSUB_PEER_DISCOVERY = ['_peer-discovery._p2p._pubsub',CONFIG_PEER_DISCOVERY_UNIVERSAL_CONNECTIVITY,prefix+'-peer-discovery']
|
|
11
|
+
export const CONFIG_PUPSUB_TOPIC = prefix+'-room'
|
|
12
|
+
export const CONFIG_DELEGATED_API = 'https://delegated-ipfs.dev'
|
|
13
|
+
export const CONFIG_DNS_RESOLVER = 'https://dns.google/resolve'
|
|
14
|
+
export const CONFIG_KNOWN_BOOTSTRAP_DNS = '_dnsaddr.bootstrap.libp2p.io'
|
|
15
|
+
export const CONFIG_JOIN_ROOM_VERSION = 1
|
|
16
|
+
|
|
17
|
+
export const CONFIG_KNOWN_BOOTSTRAP_PEERS_ADDRS = [
|
|
18
|
+
{
|
|
19
|
+
"Peers": [
|
|
20
|
+
{
|
|
21
|
+
"Addrs": [
|
|
22
|
+
"/ip4/147.28.186.157/udp/9091/quic-v1",
|
|
23
|
+
"/ip4/147.28.186.157/udp/9090/webrtc-direct/certhash/uEiBbC9bbdvraVWDvcvCEdJAWDymmUqiJQ964FuyEq0hELw"
|
|
24
|
+
],
|
|
25
|
+
"ID": "12D3KooWGahRw3ZnM4gAyd9FK75v4Bp5keFYTvkcAwhpEm28wbV3",
|
|
26
|
+
"Schema": "peer"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"Peers": [
|
|
32
|
+
{
|
|
33
|
+
"Addrs": [
|
|
34
|
+
"/ip6/2604:1380:4642:6600::3/udp/9095/quic-v1/webtransport/certhash/uEiCU6MjDlUhqtik_vc8Ps5_MJtGhJKn-XSqvuzn8SJGL9A/certhash/uEiDlk15VyYoXwTaB608Y80ch3OptpMiKFblYdduSVLy2sQ",
|
|
35
|
+
"/ip4/147.28.186.157/udp/9095/quic-v1",
|
|
36
|
+
"/ip6/2604:1380:4642:6600::3/udp/9095/quic-v1",
|
|
37
|
+
"/ip4/147.28.186.157/udp/9095/quic-v1/webtransport/certhash/uEiCU6MjDlUhqtik_vc8Ps5_MJtGhJKn-XSqvuzn8SJGL9A/certhash/uEiDlk15VyYoXwTaB608Y80ch3OptpMiKFblYdduSVLy2sQ"
|
|
38
|
+
],
|
|
39
|
+
"ID": "12D3KooWFhXabKDwALpzqMbto94sB7rvmZ6M28hs9Y9xSopDKwQr",
|
|
40
|
+
"Schema": "peer"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"Peers": [
|
|
46
|
+
{
|
|
47
|
+
"Addrs": [
|
|
48
|
+
"/ip6/2607:f2f8:a880:0:5054:ff:fe9f:4913/udp/4001/quic-v1/webtransport/certhash/uEiD84ZvAnGWTQx_WlOAqreebO036a5RRB5zfJBo9QJfDBA/certhash/uEiAOMkIVxeNye76-f5ADnLCSNqNlnhOYdkwyRlqLFbhIkQ",
|
|
49
|
+
"/ip6/2607:f2f8:a880::70/udp/4001/quic-v1/webtransport/certhash/uEiD84ZvAnGWTQx_WlOAqreebO036a5RRB5zfJBo9QJfDBA/certhash/uEiAOMkIVxeNye76-f5ADnLCSNqNlnhOYdkwyRlqLFbhIkQ",
|
|
50
|
+
"/ip6/2607:f2f8:a880:0:5054:ff:fe9f:4913/tcp/4001",
|
|
51
|
+
"/ip6/2607:f2f8:a880:0:5054:ff:fe9f:4913/udp/4001/quic-v1",
|
|
52
|
+
"/ip4/174.136.97.180/udp/4001/quic-v1/webtransport/certhash/uEiD84ZvAnGWTQx_WlOAqreebO036a5RRB5zfJBo9QJfDBA/certhash/uEiAOMkIVxeNye76-f5ADnLCSNqNlnhOYdkwyRlqLFbhIkQ",
|
|
53
|
+
"/ip4/174.136.97.180/udp/4001/quic-v1",
|
|
54
|
+
"/ip6/2607:f2f8:a880::70/udp/4001/quic-v1",
|
|
55
|
+
"/ip4/174.136.97.180/tcp/4001"
|
|
56
|
+
],
|
|
57
|
+
"ID": "12D3KooWPEDBmt7vm6FNNYuqaA4n2qMUZ6wPK5NcRc8t6KpqgRkV",
|
|
58
|
+
"Schema": "peer"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"Peers": [
|
|
64
|
+
{
|
|
65
|
+
"Addrs": [
|
|
66
|
+
"/ip4/174.136.97.179/udp/4001/quic-v1",
|
|
67
|
+
"/ip6/2607:f2f8:a880::50/udp/4002/quic-v1/webtransport/certhash/uEiBF7KOka9hhb2IjhUd-OkfgTFOf-VpgV7fwvMkKOkMrdQ/certhash/uEiDxVhDwzFlnorujU_rjTnO_TTLRMlXxzPLEgaG-1xOPkA",
|
|
68
|
+
"/ip4/174.136.97.179/udp/4001/quic-v1/webtransport/certhash/uEiBF7KOka9hhb2IjhUd-OkfgTFOf-VpgV7fwvMkKOkMrdQ/certhash/uEiDxVhDwzFlnorujU_rjTnO_TTLRMlXxzPLEgaG-1xOPkA",
|
|
69
|
+
"/ip6/2607:f2f8:a880::50/udp/4001/quic-v1",
|
|
70
|
+
"/ip4/174.136.97.179/udp/4002/quic-v1/webtransport/certhash/uEiBF7KOka9hhb2IjhUd-OkfgTFOf-VpgV7fwvMkKOkMrdQ/certhash/uEiDxVhDwzFlnorujU_rjTnO_TTLRMlXxzPLEgaG-1xOPkA",
|
|
71
|
+
"/ip6/2607:f2f8:a880::50/tcp/4001",
|
|
72
|
+
"/ip6/2607:f2f8:a880::50/udp/4001/quic-v1/webtransport/certhash/uEiBF7KOka9hhb2IjhUd-OkfgTFOf-VpgV7fwvMkKOkMrdQ/certhash/uEiDxVhDwzFlnorujU_rjTnO_TTLRMlXxzPLEgaG-1xOPkA",
|
|
73
|
+
"/ip4/174.136.97.179/tcp/4001"
|
|
74
|
+
],
|
|
75
|
+
"ID": "12D3KooWSHbugDEQeWm2LjtRRMpNgLu6oZ8zkX8XcTwYMAewVekP",
|
|
76
|
+
"Schema": "peer"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"Peers": [
|
|
82
|
+
{
|
|
83
|
+
"Addrs": [
|
|
84
|
+
"/ip6/2a03:4000:46:26e::c17/udp/443/quic-v1/webtransport/certhash/uEiAortGu7HNi8-pV9onPFkTwykrnWuJEqYf7zbQVE1FEtg/certhash/uEiB5Z8j3pdTJU_TDYoJ-GgUQSaXOmvKIGmASL9s-p3VHQA",
|
|
85
|
+
"/ip4/45.83.104.156/udp/443/quic-v1",
|
|
86
|
+
"/ip4/45.83.104.156/udp/443/quic-v1/webtransport/certhash/uEiAortGu7HNi8-pV9onPFkTwykrnWuJEqYf7zbQVE1FEtg/certhash/uEiB5Z8j3pdTJU_TDYoJ-GgUQSaXOmvKIGmASL9s-p3VHQA",
|
|
87
|
+
"/ip6/2a03:4000:46:26e::c17/tcp/443",
|
|
88
|
+
"/ip6/2a03:4000:46:26e::c17/udp/443/quic-v1",
|
|
89
|
+
"/ip4/45.83.104.156/tcp/443"
|
|
90
|
+
],
|
|
91
|
+
"ID": "12D3KooWASoxFpwwy8JDdu4Tm57mhESsnbFPogam9VVmhR95FGXr",
|
|
92
|
+
"Schema": "peer"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"Peers": [
|
|
98
|
+
{
|
|
99
|
+
"Addrs": [
|
|
100
|
+
"/ip4/139.178.91.71/udp/4001/quic-v1",
|
|
101
|
+
"/ip6/2604:1380:45e3:6e00::1/tcp/4001",
|
|
102
|
+
"/ip4/139.178.91.71/tcp/4001",
|
|
103
|
+
"/ip4/139.178.91.71/udp/4001/quic-v1/webtransport/certhash/uEiDYGZMqjz8wsz59DHA4iJin4nqTUfuJhq9AeAZlHBrmvg/certhash/uEiBXLv0dkEqbhmcinRbwj8b_3vWs0kWwf1-fiaz5wS-tew",
|
|
104
|
+
"/ip6/2604:1380:45e3:6e00::1/udp/4001/quic-v1/webtransport/certhash/uEiDYGZMqjz8wsz59DHA4iJin4nqTUfuJhq9AeAZlHBrmvg/certhash/uEiBXLv0dkEqbhmcinRbwj8b_3vWs0kWwf1-fiaz5wS-tew",
|
|
105
|
+
"/dnsaddr/bootstrap.libp2p.io",
|
|
106
|
+
"/dns6/sv15.bootstrap.libp2p.io/tcp/443/wss",
|
|
107
|
+
"/ip6/2604:1380:45e3:6e00::1/udp/4001/quic-v1",
|
|
108
|
+
"/ip4/139.178.91.71/tcp/443/tls/sni/sv15.bootstrap.libp2p.io/ws",
|
|
109
|
+
"/ip6/2604:1380:45e3:6e00::1/tcp/443/tls/sni/sv15.bootstrap.libp2p.io/ws",
|
|
110
|
+
"/dns4/sv15.bootstrap.libp2p.io/tcp/443/wss"
|
|
111
|
+
],
|
|
112
|
+
"ID": "QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
|
113
|
+
"Schema": "peer"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"Peers": [
|
|
119
|
+
{
|
|
120
|
+
"Addrs": [
|
|
121
|
+
"/ip4/139.178.65.157/udp/4001/quic-v1",
|
|
122
|
+
"/dns6/ny5.bootstrap.libp2p.io/tcp/443/wss",
|
|
123
|
+
"/ip6/2604:1380:45d2:8100::1/tcp/4001",
|
|
124
|
+
"/dns4/ny5.bootstrap.libp2p.io/tcp/443/wss",
|
|
125
|
+
"/ip4/139.178.65.157/tcp/4001",
|
|
126
|
+
"/ip6/2604:1380:45d2:8100::1/udp/4001/quic-v1"
|
|
127
|
+
],
|
|
128
|
+
"ID": "QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
|
|
129
|
+
"Schema": "peer"
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"Peers": [
|
|
135
|
+
{
|
|
136
|
+
"Addrs": [
|
|
137
|
+
"/dns4/am6.bootstrap.libp2p.io/tcp/443/wss",
|
|
138
|
+
"/ip6/2604:1380:4602:5c00::3/udp/4001/quic-v1/webtransport/certhash/uEiD3Q2mfd5EYt6Y2M9rsge_nna4hVyCgUVlfSz3IjAK8ew/certhash/uEiAHt8JR08mlUCCGnN8VpqG9G4sfvdjAd0v5ZM5W1lqntw",
|
|
139
|
+
"/ip6/2604:1380:4602:5c00::3/tcp/4001",
|
|
140
|
+
"/ip4/147.75.87.27/udp/4001/quic-v1",
|
|
141
|
+
"/ip6/2604:1380:4602:5c00::3/udp/4001/quic-v1",
|
|
142
|
+
"/ip4/147.75.87.27/tcp/4001",
|
|
143
|
+
"/dns6/am6.bootstrap.libp2p.io/tcp/443/wss",
|
|
144
|
+
"/ip4/147.75.87.27/udp/4001/quic-v1/webtransport/certhash/uEiD3Q2mfd5EYt6Y2M9rsge_nna4hVyCgUVlfSz3IjAK8ew/certhash/uEiAHt8JR08mlUCCGnN8VpqG9G4sfvdjAd0v5ZM5W1lqntw"
|
|
145
|
+
],
|
|
146
|
+
"ID": "QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
|
|
147
|
+
"Schema": "peer"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"Peers": [
|
|
153
|
+
{
|
|
154
|
+
"Addrs": [
|
|
155
|
+
"/ip6/2604:1380:40e1:9c00::1/udp/4001/quic-v1/webtransport/certhash/uEiBENNd9IIPnU1cTGoVATo6cly-O2fQAjKpIyFi0msoJew/certhash/uEiD8N0sSnHOUIsKxz4pDuVqx4szt-huTZWafW_EY19H7MQ",
|
|
156
|
+
"/ip6/2604:1380:40e1:9c00::1/tcp/4001",
|
|
157
|
+
"/dnsaddr/bootstrap.libp2p.io",
|
|
158
|
+
"/ip4/145.40.118.135/udp/4001/quic-v1/webtransport/certhash/uEiBENNd9IIPnU1cTGoVATo6cly-O2fQAjKpIyFi0msoJew/certhash/uEiD8N0sSnHOUIsKxz4pDuVqx4szt-huTZWafW_EY19H7MQ",
|
|
159
|
+
"/ip4/145.40.118.135/udp/4001/quic-v1",
|
|
160
|
+
"/dns4/sg1.bootstrap.libp2p.io/tcp/443/wss",
|
|
161
|
+
"/ip6/2604:1380:40e1:9c00::1/udp/4001/quic-v1",
|
|
162
|
+
"/ip4/145.40.118.135/tcp/4001",
|
|
163
|
+
"/dns6/sg1.bootstrap.libp2p.io/tcp/443/wss",
|
|
164
|
+
"/ip4/145.40.118.135/tcp/443/tls/sni/sg1.bootstrap.libp2p.io/ws",
|
|
165
|
+
"/ip6/2604:1380:40e1:9c00::1/tcp/443/tls/sni/sg1.bootstrap.libp2p.io/ws"
|
|
166
|
+
],
|
|
167
|
+
"ID": "QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
|
|
168
|
+
"Schema": "peer"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"Peers": [
|
|
174
|
+
{
|
|
175
|
+
"Addrs": [
|
|
176
|
+
"/ip4/104.131.131.82/udp/4001/quic-v1/webtransport/certhash/uEiCIMEw_vvBwFLEqWbOj_wx7I90HmfMabSyVZ9Vn5srjPA/certhash/uEiBy22YtYUPU8T3aJ4rL3jC0lLR8MFZZNkFP-rWRxMrqQA",
|
|
177
|
+
"/ip4/104.131.131.82/udp/4001/quic-v1",
|
|
178
|
+
"/ip4/104.131.131.82/tcp/4001",
|
|
179
|
+
"/ip4/104.131.131.82/udp/4001/quic"
|
|
180
|
+
],
|
|
181
|
+
"ID": "QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
|
182
|
+
"Schema": "peer"
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"Peers": [
|
|
188
|
+
{
|
|
189
|
+
"Addrs": [
|
|
190
|
+
"/ip4/16.170.214.173/udp/4001/quic-v1/webtransport/certhash/uEiAKAeeOxU7ExDc81y7d53D96nFaRmmXwSFj0429Ij9T9A/certhash/uEiB4ttGGuaUzqF84q5RFhUTVArF4mb9t_UN_kcsfd4qYEQ",
|
|
191
|
+
"/ip4/16.170.214.173/tcp/4001",
|
|
192
|
+
"/ip4/16.170.214.173/udp/4001/quic-v1"
|
|
193
|
+
],
|
|
194
|
+
"ID": "12D3KooWHh98YpAkJsn3ULjMjK1n9QVkXmi8Sb3gTDMatHxCmDP5",
|
|
195
|
+
"Schema": "peer"
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"Peers": [
|
|
201
|
+
{
|
|
202
|
+
"Addrs": [
|
|
203
|
+
"/ip4/18.119.248.24/udp/4001/quic-v1",
|
|
204
|
+
"/ip4/18.119.248.24/tcp/4001",
|
|
205
|
+
"/ip4/18.119.248.24/udp/4001/quic-v1/webtransport/certhash/uEiDwG2YnjoUpoKqmUMX-aYJeLi1UNEsqa8EFhpHFUVs0AQ/certhash/uEiCqy6-Pk3S2iYS0puQ0UhtTZ1s_nw-sIsoB-bX0Le6lFA"
|
|
206
|
+
],
|
|
207
|
+
"ID": "12D3KooWS79EhkPU7ESUwgG4vyHHzW9FDNZLoWVth9b5N5NSrvaj",
|
|
208
|
+
"Schema": "peer"
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"Peers": [
|
|
214
|
+
{
|
|
215
|
+
"Addrs": [
|
|
216
|
+
"/ip4/83.173.236.99/udp/4001/quic-v1/webtransport/certhash/uEiD8mhYDW_6kgJAb07RlZnA-YSScG38df5wb9IxFtZmQwQ/certhash/uEiACG9e-sG_ild6y5t-jvb_dfsNi_gPgZ7nn7Qa5ctT-Wg",
|
|
217
|
+
"/ip6/2a02:121e:21e:1:546f:18ff:fea8:8e/tcp/4001",
|
|
218
|
+
"/ip4/83.173.236.99/tcp/10201",
|
|
219
|
+
"/dns4/ipfs-ws.neaweb.ch/tcp/443/wss",
|
|
220
|
+
"/ip4/89.251.251.195/udp/4001/quic-v1",
|
|
221
|
+
"/ip4/89.251.251.195/udp/4001/quic-v1/webtransport/certhash/uEiD8mhYDW_6kgJAb07RlZnA-YSScG38df5wb9IxFtZmQwQ/certhash/uEiACG9e-sG_ild6y5t-jvb_dfsNi_gPgZ7nn7Qa5ctT-Wg",
|
|
222
|
+
"/ip6/2a02:121e:21e:1:546f:18ff:fea8:8e/udp/4001/quic-v1",
|
|
223
|
+
"/ip4/89.251.251.195/tcp/4001/quic-v1/webtransport",
|
|
224
|
+
"/ip6/2a02:121e:21e:1:546f:18ff:fea8:8e/tcp/4011/ws",
|
|
225
|
+
"/ip4/89.251.251.195/tcp/4001",
|
|
226
|
+
"/dns4/ipfs-ws.neaweb.tech/tcp/443/wss",
|
|
227
|
+
"/ip4/89.251.251.195/tcp/4001/quic-v1",
|
|
228
|
+
"/ip4/83.173.236.99/tcp/4001",
|
|
229
|
+
"/ip6/2a02:121e:21e:1:546f:18ff:fea8:8e/udp/4001/quic-v1/webtransport/certhash/uEiD8mhYDW_6kgJAb07RlZnA-YSScG38df5wb9IxFtZmQwQ/certhash/uEiACG9e-sG_ild6y5t-jvb_dfsNi_gPgZ7nn7Qa5ctT-Wg",
|
|
230
|
+
"/ip4/83.173.236.99/udp/4001/quic-v1",
|
|
231
|
+
"/ip4/83.173.236.99/udp/19707/quic-v1",
|
|
232
|
+
"/ip4/83.173.236.99/udp/19707/quic-v1/webtransport/certhash/uEiD8mhYDW_6kgJAb07RlZnA-YSScG38df5wb9IxFtZmQwQ/certhash/uEiACG9e-sG_ild6y5t-jvb_dfsNi_gPgZ7nn7Qa5ctT-Wg"
|
|
233
|
+
],
|
|
234
|
+
"ID": "12D3KooWBbkCD5MpJhMc1mfPAVGEyVkQnyxPKGS7AHwDqQM2JUsk",
|
|
235
|
+
"Schema": "peer"
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"Peers": [
|
|
241
|
+
{
|
|
242
|
+
"Addrs": [
|
|
243
|
+
"/ip4/89.58.11.155/udp/4001/quic-v1/webtransport/certhash/uEiDDgTBtcIstrvU4MRSfcD7tYDIsQrnGAxW6Oh5AoLm4Ig/certhash/uEiAXHXsg1wBb-sPvpBw8BVpRFxso1milPa801TxjPNYQ3w",
|
|
244
|
+
"/ip4/89.58.11.155/udp/4001/quic",
|
|
245
|
+
"/ip6/64:ff9b::593a:b9b/udp/4001/quic-v1/webtransport/certhash/uEiDDgTBtcIstrvU4MRSfcD7tYDIsQrnGAxW6Oh5AoLm4Ig/certhash/uEiAXHXsg1wBb-sPvpBw8BVpRFxso1milPa801TxjPNYQ3w",
|
|
246
|
+
"/ip6/64:ff9b::593a:b9b/udp/4001/quic-v1",
|
|
247
|
+
"/ip4/89.58.11.155/udp/4001/quic-v1",
|
|
248
|
+
"/ip4/89.58.11.155/tcp/4001"
|
|
249
|
+
],
|
|
250
|
+
"ID": "12D3KooWKLdecs31Zmo2pLBjR9HY2vWo3VwM4eBm21Czeucbe6FL",
|
|
251
|
+
"Schema": "peer"
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"Peers": [
|
|
257
|
+
{
|
|
258
|
+
"Addrs": [
|
|
259
|
+
"/ip4/205.198.64.76/tcp/4001",
|
|
260
|
+
"/ip4/205.198.64.76/udp/4001/quic-v1",
|
|
261
|
+
"/ip4/205.198.64.76/udp/4001/quic-v1/webtransport/certhash/uEiCT4khDdgvF2NHCw-fu3qUk2qRqx0AgTEt0PHZct8jq5g/certhash/uEiA2RYkSCyOOtJmrpm_Dn8jJr-LLwS0S7K3HX3dbJJlN_w"
|
|
262
|
+
],
|
|
263
|
+
"ID": "12D3KooWBdF3g6vSJFRPoZQo7BNnkNzaWb59gpyaVzsgtNTVeu8H",
|
|
264
|
+
"Schema": "peer"
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
]
|
|
269
|
+
|
|
270
|
+
export const CONFIG_KNOWN_BOOTSTRAP_PEER_IDS = [
|
|
271
|
+
'12D3KooWFhXabKDwALpzqMbto94sB7rvmZ6M28hs9Y9xSopDKwQr',
|
|
272
|
+
'12D3KooWGahRw3ZnM4gAyd9FK75v4Bp5keFYTvkcAwhpEm28wbV3',
|
|
273
|
+
'12D3KooWPEDBmt7vm6FNNYuqaA4n2qMUZ6wPK5NcRc8t6KpqgRkV',
|
|
274
|
+
'12D3KooWSHbugDEQeWm2LjtRRMpNgLu6oZ8zkX8XcTwYMAewVekP',
|
|
275
|
+
'12D3KooWASoxFpwwy8JDdu4Tm57mhESsnbFPogam9VVmhR95FGXr',
|
|
276
|
+
'QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
|
|
277
|
+
'QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa',
|
|
278
|
+
'QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
|
|
279
|
+
'QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt',
|
|
280
|
+
'QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
|
|
281
|
+
'12D3KooWHh98YpAkJsn3ULjMjK1n9QVkXmi8Sb3gTDMatHxCmDP5',
|
|
282
|
+
'12D3KooWS79EhkPU7ESUwgG4vyHHzW9FDNZLoWVth9b5N5NSrvaj',
|
|
283
|
+
'12D3KooWBbkCD5MpJhMc1mfPAVGEyVkQnyxPKGS7AHwDqQM2JUsk',
|
|
284
|
+
'12D3KooWKLdecs31Zmo2pLBjR9HY2vWo3VwM4eBm21Czeucbe6FL',
|
|
285
|
+
'12D3KooWBdF3g6vSJFRPoZQo7BNnkNzaWb59gpyaVzsgtNTVeu8H'
|
|
286
|
+
]
|
package/src/umd.js
ADDED
package/src/utils.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import * as config from './config'
|
|
2
|
+
|
|
3
|
+
import { Peer as PBPeer } from '#/pubsub-peer-discovery/peer.js'
|
|
4
|
+
|
|
5
|
+
import { Key } from 'interface-datastore'
|
|
6
|
+
|
|
7
|
+
import { sha256 } from 'multiformats/hashes/sha2'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const prefix = config.CONFIG_PREFIX
|
|
12
|
+
|
|
13
|
+
export const mkErr = msg => new Error(`${prefix}: ${msg}`)
|
|
14
|
+
|
|
15
|
+
export {PBPeer}
|
|
16
|
+
|
|
17
|
+
export function uint8ArrayToString(uint8Array){
|
|
18
|
+
const string = new TextDecoder().decode(uint8Array)
|
|
19
|
+
return string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function uint8ArrayFromString(string){
|
|
23
|
+
const uint8Array = new TextEncoder().encode(string)
|
|
24
|
+
return uint8Array
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function first(farr){
|
|
28
|
+
for await(const data of farr){
|
|
29
|
+
return data
|
|
30
|
+
//break
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {Key}
|
|
35
|
+
|
|
36
|
+
//Add id to pupsub message
|
|
37
|
+
export async function msgIdFnStrictNoSign(msg){
|
|
38
|
+
var enc = new TextEncoder()
|
|
39
|
+
const signedMessage = msg
|
|
40
|
+
const encodedSeqNum = enc.encode(signedMessage.sequenceNumber.toString())
|
|
41
|
+
return await sha256.encode(encodedSeqNum)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let totals = {
|
|
45
|
+
readyErrored: 0,
|
|
46
|
+
noiseErrored: 0,
|
|
47
|
+
upgradeErrored: 0,
|
|
48
|
+
readyTimedout: 0,
|
|
49
|
+
noiseTimedout: 0,
|
|
50
|
+
success: 0
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let stats = {
|
|
54
|
+
pending: 0,
|
|
55
|
+
open: 0,
|
|
56
|
+
|
|
57
|
+
ready_error: 0,
|
|
58
|
+
noise_error: 0,
|
|
59
|
+
upgrade_error: 0,
|
|
60
|
+
|
|
61
|
+
ready_timeout: 0,
|
|
62
|
+
noise_timeout: 0,
|
|
63
|
+
|
|
64
|
+
close: 0,
|
|
65
|
+
abort: 0,
|
|
66
|
+
remote_close: 0,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let lastStats = {
|
|
70
|
+
pending: 0,
|
|
71
|
+
ready_error: 0,
|
|
72
|
+
noise_error: 0,
|
|
73
|
+
upgrade_error: 0,
|
|
74
|
+
close: 0,
|
|
75
|
+
remote_close: 0,
|
|
76
|
+
ready: 0,
|
|
77
|
+
abort: 0,
|
|
78
|
+
ready_timeout: 0,
|
|
79
|
+
noise_timeout: 0,
|
|
80
|
+
open: 0
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let isDialEnabled = true
|
|
84
|
+
let lastfailtreshold = 0
|
|
85
|
+
|
|
86
|
+
export function metrics(data){
|
|
87
|
+
try{
|
|
88
|
+
const webTransportEvents = data.libp2p_webtransport_dialer_events_total
|
|
89
|
+
|
|
90
|
+
const newPending = (webTransportEvents.pending ?? 0) - (lastStats.pending ?? 0)
|
|
91
|
+
const newReadyError = (webTransportEvents.ready_error ?? 0) - (lastStats.ready_error ?? 0)
|
|
92
|
+
const newNoiseError = (webTransportEvents.noise_error ?? 0) - (lastStats.noise_error ?? 0)
|
|
93
|
+
const newUpgradeError = (webTransportEvents.upgrade_error ?? 0) - (lastStats.upgrade_error ?? 0)
|
|
94
|
+
const newClose = (webTransportEvents.close ?? 0) - (lastStats.close ?? 0)
|
|
95
|
+
const newReady = (webTransportEvents.ready ?? 0) - (lastStats.ready ?? 0)
|
|
96
|
+
const newAbort = (webTransportEvents.abort ?? 0) - (lastStats.abort ?? 0)
|
|
97
|
+
const newReadyTimeout = (webTransportEvents.ready_timeout ?? 0) - (lastStats.ready_timeout ?? 0)
|
|
98
|
+
const newNoiseTimeout = (webTransportEvents.noise_timeout ?? 0) - (lastStats.noise_timeout ?? 0)
|
|
99
|
+
const newOpen = (webTransportEvents.open ?? 0) - (lastStats.open ?? 0)
|
|
100
|
+
const newRemoteClose = (webTransportEvents.remote_close ?? 0) - (lastStats.remote_close ?? 0)
|
|
101
|
+
|
|
102
|
+
stats.pending += newPending
|
|
103
|
+
stats.pending -= newReadyTimeout
|
|
104
|
+
stats.pending -= newNoiseTimeout
|
|
105
|
+
stats.pending -= newReadyError
|
|
106
|
+
stats.pending -= newNoiseError
|
|
107
|
+
stats.pending -= newUpgradeError
|
|
108
|
+
stats.pending -= newOpen
|
|
109
|
+
|
|
110
|
+
stats.open += newOpen
|
|
111
|
+
stats.open -= newClose
|
|
112
|
+
stats.open -= newRemoteClose
|
|
113
|
+
stats.open -= newAbort
|
|
114
|
+
|
|
115
|
+
stats.ready_error = newReadyError
|
|
116
|
+
stats.noise_error = newNoiseError
|
|
117
|
+
stats.upgrade_error = newUpgradeError
|
|
118
|
+
stats.ready_timeout = newReadyTimeout
|
|
119
|
+
stats.noise_timeout = newNoiseTimeout
|
|
120
|
+
stats.close = newClose
|
|
121
|
+
stats.abort = newAbort
|
|
122
|
+
stats.remote_close = newRemoteClose
|
|
123
|
+
|
|
124
|
+
totals.success += newReady
|
|
125
|
+
totals.readyErrored += newReadyError
|
|
126
|
+
totals.noiseErrored += newNoiseError
|
|
127
|
+
totals.upgradeErrored += newUpgradeError
|
|
128
|
+
totals.readyTimedout += newReadyTimeout
|
|
129
|
+
totals.noiseTimedout += newNoiseTimeout
|
|
130
|
+
|
|
131
|
+
const errors = totals.readyErrored + totals.noiseErrored + totals.upgradeErrored
|
|
132
|
+
const timeouts = totals.readyTimedout + totals.noiseTimedout
|
|
133
|
+
//const failureRate = ((errors + timeouts) / (errors + timeouts + totals.success) * 100).toFixed(2)
|
|
134
|
+
|
|
135
|
+
lastStats = webTransportEvents
|
|
136
|
+
|
|
137
|
+
const fail = errors+timeouts
|
|
138
|
+
const treshold = errors+timeouts+stats.open+stats.pending
|
|
139
|
+
|
|
140
|
+
if(treshold>50){
|
|
141
|
+
//console.log(`Treeshold hit : ${treshold}`)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if(fail>50){
|
|
145
|
+
//console.log(`Open : ${stats.open} , Pending : ${stats.pending} , Succes : ${totals.success} , Fail : ${fail} `)
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if ((fail-lastfailtreshold)>50){
|
|
150
|
+
if(isDialEnabled){
|
|
151
|
+
isDialEnabled = false
|
|
152
|
+
//const str = JSON.stringify({isDialEnabled,fail,lastfailtreshold})
|
|
153
|
+
//console.warn(str)
|
|
154
|
+
setTimeout(()=>{
|
|
155
|
+
if(!isDialEnabled){
|
|
156
|
+
isDialEnabled = true
|
|
157
|
+
lastfailtreshold = fail
|
|
158
|
+
//const str = JSON.stringify({isDialEnabled,fail,lastfailtreshold})
|
|
159
|
+
//console.warn(str)
|
|
160
|
+
}
|
|
161
|
+
},6*60*1000)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return isDialEnabled
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
catch{
|
|
169
|
+
console.debug('Metrics error')
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/*
|
|
174
|
+
onunhandledrejection = function(evt) {
|
|
175
|
+
console.warn(evt.reason);
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
*/
|