Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read preferredPort from config, send to core #67

Merged
merged 1 commit into from
Jan 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Client {
* @param {object} opts.config
* @param {boolean} opts.config.temp if `temp` is true no data is persisted to disk.
* @param {string} [opts.config.dbdir] the directory to store the cabal data
* @param {string} [opts.config.preferredPort] the port cabal will listen on for traffic
* @param {number} [opts.maxFeeds=1000] max amount of feeds to sync
* @param {object} [opts.persistentCache] specify a `read` and `write` to create a persistent DNS cache
* @param {function} opts.persistentCache.read async cache lookup function
Expand All @@ -32,7 +33,8 @@ class Client {
opts = {
config: {
temp: true,
dbdir: null
dbdir: null,
preferredPort: 0 // use cabal-core's default port
}
}
}
Expand Down Expand Up @@ -176,7 +178,8 @@ class Client {
dnsFailed = true
return
}
let { temp, dbdir } = this.config
let { temp, dbdir, preferredPort } = this.config
preferredPort = preferredPort || 0
dbdir = dbdir || path.join(Client.getCabalDirectory(), 'archives')
const storage = temp ? ram : path.join(dbdir, scrubbedKey)
if (!temp) try { mkdirp.sync(path.join(dbdir, scrubbedKey, 'views')) } catch (e) {}
Expand All @@ -187,7 +190,7 @@ class Client {
const modKeys = uri.searchParams.getAll('mod')
const adminKeys = uri.searchParams.getAll('admin')

var cabal = Cabal(storage, scrubbedKey, { modKeys, adminKeys, db: db, maxFeeds: this.maxFeeds })
var cabal = Cabal(storage, scrubbedKey, { modKeys, adminKeys, db, preferredPort, maxFeeds: this.maxFeeds })
this._keyToCabal[scrubbedKey] = cabal
return cabal
})
Expand Down