Skip to content

Commit 72c34f4

Browse files
committed
fix: default to External node
Embedded node with chrome.sockets is not ready yet. Key blockers in js-ipfs need to be resolved first: - /ipns/<fqdn>/ load fine - sharded directories (e.g. wikipedia) load fine We may also decide to keep External as default and just add a button on Welcome screen that activates embedded note.
1 parent 295c3fc commit 72c34f4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

add-on/src/lib/options.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
const isFQDN = require('is-fqdn')
44
const { hasChromeSocketsForTcp } = require('./runtime-checks')
55

6+
// Detect Beta Channel on Brave via: chrome.runtime.id === 'hjoieblefckbooibpepigmacodalfndh'
7+
// TODO: enable by default when key blockers are resolved
8+
// - [ ] /ipns/<fqdn>/ load fine
9+
// - [ ] sharded directories (e.g. wikipedia) load fine
10+
const DEFAULT_TO_EMBEDDED_GATEWAY = false && hasChromeSocketsForTcp()
11+
612
exports.optionDefaults = Object.freeze({
713
active: true, // global ON/OFF switch, overrides everything else
814
ipfsNodeType: buildDefaultIpfsNodeType(),
@@ -25,19 +31,19 @@ exports.optionDefaults = Object.freeze({
2531

2632
function buildCustomGatewayUrl () {
2733
// TODO: make more robust (sync with buildDefaultIpfsNodeConfig)
28-
const port = hasChromeSocketsForTcp() ? 9091 : 8080
34+
const port = DEFAULT_TO_EMBEDDED_GATEWAY ? 9091 : 8080
2935
return `http://127.0.0.1:${port}`
3036
}
3137

3238
function buildIpfsApiUrl () {
3339
// TODO: make more robust (sync with buildDefaultIpfsNodeConfig)
34-
const port = hasChromeSocketsForTcp() ? 5003 : 5001
40+
const port = DEFAULT_TO_EMBEDDED_GATEWAY ? 5003 : 5001
3541
return `http://127.0.0.1:${port}`
3642
}
3743

3844
function buildDefaultIpfsNodeType () {
3945
// Right now Brave is the only vendor giving us access to chrome.sockets
40-
return hasChromeSocketsForTcp() ? 'embedded:chromesockets' : 'external'
46+
return DEFAULT_TO_EMBEDDED_GATEWAY ? 'embedded:chromesockets' : 'external'
4147
}
4248

4349
function buildDefaultIpfsNodeConfig () {
@@ -134,8 +140,7 @@ exports.migrateOptions = async (storage) => {
134140
// Upgrade js-ipfs to js-ipfs + chrome.sockets
135141
const { ipfsNodeType } = await storage.get('ipfsNodeType')
136142
if (ipfsNodeType === 'embedded' && hasChromeSocketsForTcp()) {
137-
console.log(`[ipfs-companion] migrating ipfsNodeType to 'embedded:chromesockets'`)
138-
// Overwrite old config
143+
console.log(`[ipfs-companion] migrating ipfsNodeType: ${ipfsNodeType} → embedded:chromesockets`)
139144
await storage.set({
140145
ipfsNodeType: 'embedded:chromesockets',
141146
ipfsNodeConfig: buildDefaultIpfsNodeConfig()

0 commit comments

Comments
 (0)