Commit f58e9faba879514abb7c3cccc40a4d93d8421ba4
Add tor only mode to settings
Anders Rune Jensen committed on 2/9/2019, 10:00:22 AMParent: 3bd137609d70f9a0d68010c74ec5af5af8d59863
Files changed
app/html/settings/tor-only.js | added |
config.js | changed |
package-lock.json | changed |
app/html/settings/tor-only.js | ||
---|---|---|
@@ -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.js | ||
---|---|---|
@@ -15,9 +15,10 @@ | ||
15 | 15 … | config = Config(process.env.ssb_appname || 'ssb') |
16 | 16 … | |
17 | 17 … | config = addSockets(config) |
18 | 18 … | config = fixLocalhost(config) |
19 | - config = PubHopSettings(config) | |
19 … | + config = pubHopSettings(config) | |
20 … | + config = torOnly(config) | |
20 | 21 … | |
21 | 22 … | return config |
22 | 23 … | }) |
23 | 24 … | } |
@@ -46,9 +47,9 @@ | ||
46 | 47 … | config.host = '127.0.0.1' |
47 | 48 … | return config |
48 | 49 … | } |
49 | 50 … | |
50 | -function PubHopSettings (config) { | |
51 … | +function pubHopSettings (config) { | |
51 | 52 … | const pubHopAll = 3 |
52 | 53 … | let pubHopConnections = settings.create().settings.sync.get('patchbay.pubHopConnections', pubHopAll) |
53 | 54 … | if (pubHopConnections != pubHopAll) { |
54 | 55 … | return merge( |
@@ -62,4 +63,20 @@ | ||
62 | 63 … | }) |
63 | 64 … | } else |
64 | 65 … | return config |
65 | 66 … | } |
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.json | ||
---|---|---|
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