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

extract config, and add working config from patchbay #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const ssbKeys = require('ssb-keys')
const Config = require('ssb-config/inject')
const path = require('path')
const merge = require('lodash.merge')
// const minimist = require('minimist')

module.exports = function buildConfig ({ appname }) {
// mix: note ssb-config uses RC, which loads config opts from process.argv
Copy link
Member Author

@mixmix mixmix Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm on reading docs, I don't think RC actually loads things from process.argv ):

So this code should be reinstated. However, I still don't know what the last line does :

  argv = ~i ? argv.slice(0, i) : argv 

// let argv = process.argv.slice(2)
// let i = argv.indexOf('--')
// let conf = argv.slice(i + 1)
// argv = ~i ? argv.slice(0, i) : argv // mix: is this used ?
//

var config = Config(appname || process.env.ssb_appname)
config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
config = merge(
config,
Connections(config),
Remote(config)
)

return config
}

function Connections (config) {
const connections = (process.platform === 'win32')
? undefined // this seems wrong?
: { incoming: { unix: [{ 'scope': 'local', 'transform': 'noauth', server: true }] } }

return connections ? { connections } : {}
}

function Remote (config) {
const pubkey = config.keys.id.slice(1).replace(`.${config.keys.curve}`, '')
const remote = (process.platform === 'win32')
? undefined // `net:127.0.0.1:${config.port}~shs:${pubkey}` // currently broken
: `unix:${path.join(config.path, 'socket')}:~noauth:${pubkey}`

return remote ? { remote } : {}
}
Loading