braidfs 0.0.122 → 0.0.124
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/index.js +22 -12
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -59,7 +59,8 @@ if (require('fs').existsSync(sync_base)) {
|
|
|
59
59
|
cookies: { 'example.com': 'secret_pass' },
|
|
60
60
|
port: 45678,
|
|
61
61
|
scan_interval_ms: 1000 * 20,
|
|
62
|
-
reconnect_delay_ms: 1000 * 3
|
|
62
|
+
reconnect_delay_ms: 1000 * 3,
|
|
63
|
+
retry_delay_ms: 1000,
|
|
63
64
|
}
|
|
64
65
|
require('fs').mkdirSync(braidfs_config_dir, { recursive: true })
|
|
65
66
|
require('fs').writeFileSync(braidfs_config_file, JSON.stringify(config, null, 4))
|
|
@@ -133,11 +134,6 @@ async function main() {
|
|
|
133
134
|
|
|
134
135
|
if (req.url === '/favicon.ico') return
|
|
135
136
|
|
|
136
|
-
if (!['::ffff:127.0.0.1', '127.0.0.1', '::1'].includes(req.socket.remoteAddress)) {
|
|
137
|
-
res.writeHead(403, { 'Content-Type': 'text/plain' })
|
|
138
|
-
return res.end('Access denied: only accessible from localhost')
|
|
139
|
-
}
|
|
140
|
-
|
|
141
137
|
// Free the CORS
|
|
142
138
|
free_the_cors(req, res)
|
|
143
139
|
if (req.method === 'OPTIONS') return
|
|
@@ -200,7 +196,7 @@ async function main() {
|
|
|
200
196
|
res.writeHead(500, { 'Error-Message': '' + e })
|
|
201
197
|
res.end('' + e)
|
|
202
198
|
}
|
|
203
|
-
}).listen(config.port, () => {
|
|
199
|
+
}).listen(config.port, 'localhost', () => {
|
|
204
200
|
console.log(`daemon started on port ${config.port}`)
|
|
205
201
|
console.log('!! only accessible from localhost !!')
|
|
206
202
|
|
|
@@ -525,18 +521,31 @@ async function sync_url(url) {
|
|
|
525
521
|
if (freed || closed) return
|
|
526
522
|
var p = self.disconnect()
|
|
527
523
|
|
|
528
|
-
|
|
524
|
+
var delay = waitTime * (config.retry_delay_ms ?? 1000)
|
|
525
|
+
console.log(`reconnecting in ${(delay / 1000).toFixed(2)}s: ${url} after error: ${e}`)
|
|
529
526
|
last_connect_timer = setTimeout(async () => {
|
|
530
527
|
await p
|
|
531
528
|
last_connect_timer = null
|
|
532
529
|
connect()
|
|
533
|
-
},
|
|
530
|
+
}, delay)
|
|
534
531
|
waitTime = Math.min(waitTime + 1, 3)
|
|
535
532
|
}
|
|
536
533
|
|
|
537
534
|
try {
|
|
538
535
|
var a = new AbortController()
|
|
539
536
|
aborts.add(a)
|
|
537
|
+
|
|
538
|
+
var fork_point
|
|
539
|
+
if (self.version) {
|
|
540
|
+
// Check if server has our version
|
|
541
|
+
var r = await braid_fetch(url, {
|
|
542
|
+
signal: a.signal,
|
|
543
|
+
method: "HEAD",
|
|
544
|
+
version: ['' + self.version]
|
|
545
|
+
})
|
|
546
|
+
if (r.ok) fork_point = ['' + self.version]
|
|
547
|
+
}
|
|
548
|
+
|
|
540
549
|
var res = await braid_fetch(url, {
|
|
541
550
|
signal: a.signal,
|
|
542
551
|
headers: {
|
|
@@ -545,7 +554,7 @@ async function sync_url(url) {
|
|
|
545
554
|
subscribe: true,
|
|
546
555
|
heartbeats: 120,
|
|
547
556
|
peer: self.peer,
|
|
548
|
-
parents:
|
|
557
|
+
parents: fork_point || []
|
|
549
558
|
})
|
|
550
559
|
if (freed || closed) return
|
|
551
560
|
|
|
@@ -1031,12 +1040,13 @@ async function sync_url(url) {
|
|
|
1031
1040
|
if (freed || closed) return
|
|
1032
1041
|
var p = self.disconnect()
|
|
1033
1042
|
|
|
1034
|
-
|
|
1043
|
+
var delay = waitTime * (config.retry_delay_ms ?? 1000)
|
|
1044
|
+
console.log(`reconnecting in ${(delay / 1000).toFixed(2)}s: ${url} after error: ${e}`)
|
|
1035
1045
|
last_connect_timer = setTimeout(async () => {
|
|
1036
1046
|
await p
|
|
1037
1047
|
last_connect_timer = null
|
|
1038
1048
|
connect()
|
|
1039
|
-
},
|
|
1049
|
+
}, delay)
|
|
1040
1050
|
waitTime = Math.min(waitTime + 1, 3)
|
|
1041
1051
|
}
|
|
1042
1052
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braidfs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.124",
|
|
4
4
|
"description": "braid technology synchronizing files and webpages",
|
|
5
5
|
"author": "Braid Working Group",
|
|
6
6
|
"repository": "braid-org/braidfs",
|
|
7
7
|
"homepage": "https://braid.org",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"braid-http": "~1.3.
|
|
10
|
-
"braid-text": "~0.2.
|
|
11
|
-
"braid-blob": "~0.0.
|
|
12
|
-
"chokidar": "^
|
|
9
|
+
"braid-http": "~1.3.83",
|
|
10
|
+
"braid-text": "~0.2.83",
|
|
11
|
+
"braid-blob": "~0.0.30",
|
|
12
|
+
"chokidar": "^5.0.0"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
15
|
"braidfs": "./index.sh"
|