git ssb

16+

Dominic / patchbay



Commit f58e9faba879514abb7c3cccc40a4d93d8421ba4

Add tor only mode to settings

Anders Rune Jensen committed on 2/9/2019, 10:00:22 AM
Parent: 3bd137609d70f9a0d68010c74ec5af5af8d59863

Files changed

app/html/settings/tor-only.jsadded
config.jschanged
package-lock.jsonchanged
app/html/settings/tor-only.jsView
@@ -1,0 +1,41 @@
1 +const nest = require('depnest')
2 +const { h } = require('mutant')
3 +
4 +exports.gives = nest({
5 + 'app.html.settings': true
6 +})
7 +
8 +exports.needs = nest({
9 + 'app.html.settings': 'map',
10 + 'settings.obs.get': 'first',
11 + 'settings.sync.set': 'first'
12 +})
13 +
14 +exports.create = function (api) {
15 + return nest({
16 + 'app.html.settings': torOnly
17 + })
18 +
19 + function torOnly () {
20 + const torOnly = api.settings.obs.get('patchbay.torOnly', false)
21 + const toggleTorOnly = (ev) => {
22 + api.settings.sync.set({patchbay: {torOnly: ev.target.checked}})
23 +
24 + alert("please restart patchbay for this to take effect")
25 + }
26 +
27 + return {
28 + title: 'Tor only connections',
29 + body: h('DefaultTabs', [
30 + h('p', [
31 + 'Preserve your ip privacy by only connecting to other nodes using tor',
32 + h('input', {
33 + type: 'checkbox',
34 + checked: torOnly,
35 + 'ev-change': toggleTorOnly
36 + })
37 + ])
38 + ])
39 + }
40 + }
41 +}
config.jsView
@@ -15,9 +15,10 @@
1515 config = Config(process.env.ssb_appname || 'ssb')
1616
1717 config = addSockets(config)
1818 config = fixLocalhost(config)
19- config = PubHopSettings(config)
19 + config = pubHopSettings(config)
20 + config = torOnly(config)
2021
2122 return config
2223 })
2324 }
@@ -46,9 +47,9 @@
4647 config.host = '127.0.0.1'
4748 return config
4849 }
4950
50-function PubHopSettings (config) {
51 +function pubHopSettings (config) {
5152 const pubHopAll = 3
5253 let pubHopConnections = settings.create().settings.sync.get('patchbay.pubHopConnections', pubHopAll)
5354 if (pubHopConnections != pubHopAll) {
5455 return merge(
@@ -62,4 +63,20 @@
6263 })
6364 } else
6465 return config
6566 }
67 +
68 +function torOnly (config) {
69 + if (settings.create().settings.sync.get('patchbay.torOnly', false)) {
70 + config = merge(config, {
71 + connections: {
72 + outgoing: {
73 + "onion": [{ "transform": "shs" }]
74 + }
75 + }
76 + })
77 +
78 + delete config.connections.outgoing.net
79 + return config
80 + } else
81 + return config
82 +}
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 616412 bytes
New file size: 592749 bytes

Built with git-ssb-web