Skip to content

Commit

Permalink
Merge pull request #27 from vergecurrency/create-tor-control-panel
Browse files Browse the repository at this point in the history
Create tor control panel
  • Loading branch information
SwenVanZanten authored Jun 1, 2020
2 parents b5edf9b + b725143 commit b26bbf8
Show file tree
Hide file tree
Showing 23 changed files with 421 additions and 48 deletions.
5 changes: 4 additions & 1 deletion src/assets/locales/ar.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const ar = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const ar: LocaleDefinition = {}
export default ar
5 changes: 4 additions & 1 deletion src/assets/locales/bn.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const bn = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const bn: LocaleDefinition = {}
export default bn
5 changes: 4 additions & 1 deletion src/assets/locales/de.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const de = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const de: LocaleDefinition = {}
export default de
16 changes: 15 additions & 1 deletion src/assets/locales/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const en = {
import { LocaleDefinition } from '@/locale/locale'

const en: LocaleDefinition = {
main: {
menu: {
wallets: 'Wallets',
Expand All @@ -7,6 +9,18 @@ const en = {
contacts: 'Contacts'
}
},
tor: {
status: {
title: 'Tor Status',
ip: 'IP Address',
region: 'Region',
unableToConnect: 'Unable to connect',
loading: 'Loading ...',
connected: 'Connected',
disconnected: 'Disconnected'
},
toggle: 'Tor enabled'
},
unlock: {
unlockYourWallet: 'Unlock your wallet',
password: 'Password',
Expand Down
5 changes: 4 additions & 1 deletion src/assets/locales/es.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const es = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const es: LocaleDefinition = {}
export default es
5 changes: 4 additions & 1 deletion src/assets/locales/fr.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const fr = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const fr: LocaleDefinition = {}
export default fr
5 changes: 4 additions & 1 deletion src/assets/locales/hi.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const hi = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const hi: LocaleDefinition = {}
export default hi
5 changes: 4 additions & 1 deletion src/assets/locales/it.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const it = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const it: LocaleDefinition = {}
export default it
5 changes: 4 additions & 1 deletion src/assets/locales/ja.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const ja = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const ja: LocaleDefinition = {}
export default ja
16 changes: 15 additions & 1 deletion src/assets/locales/nl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const nl = {
import { LocaleDefinition } from '@/locale/locale'

const nl: LocaleDefinition = {
main: {
menu: {
wallets: 'Wallets',
Expand All @@ -7,6 +9,18 @@ const nl = {
contacts: 'Contacten'
}
},
tor: {
status: {
title: 'Tor status',
ip: 'IP adres',
region: 'Regio',
unableToConnect: 'verbinding verbroken',
loading: 'Laden ...',
connected: 'Verbonden',
disconnected: 'Niet verbonden'
},
toggle: 'Tor ingeschakeld'
},
unlock: {
unlockYourWallet: 'Ontgrendel uw wallet',
password: 'Wachtwoord',
Expand Down
5 changes: 4 additions & 1 deletion src/assets/locales/pt.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const pt = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const pt: LocaleDefinition = {}
export default pt
5 changes: 4 additions & 1 deletion src/assets/locales/ru.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const ru = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const ru: LocaleDefinition = {}
export default ru
5 changes: 4 additions & 1 deletion src/assets/locales/zh.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const zh = {}
import { LocaleDefinition } from '@/locale/locale'

// @ts-ignore
const zh: LocaleDefinition = {}
export default zh
6 changes: 6 additions & 0 deletions src/assets/tor-icons/onion-connected.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
/>
</svg>
</template>

<script>
export default {
name: 'tor-connected'
}
</script>
6 changes: 6 additions & 0 deletions src/assets/tor-icons/onion-disconnected.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
/>
</svg>
</template>

<script>
export default {
name: 'tor-disconnected'
}
</script>
6 changes: 6 additions & 0 deletions src/assets/tor-icons/onion-error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@
/>
</svg>
</template>

<script>
export default {
name: 'tor-error'
}
</script>
6 changes: 6 additions & 0 deletions src/assets/tor-icons/onion-loading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
</svg>
</template>

<script>
export default {
name: 'tor-loading'
}
</script>

<style lang="scss">
#inner-layer {
animation: inner 3s ease-in-out infinite;
Expand Down
31 changes: 23 additions & 8 deletions src/background.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict'

import { app, protocol, nativeTheme, BrowserWindow, Menu } from 'electron'
import { app, protocol, nativeTheme, BrowserWindow, Menu, ipcMain } from 'electron'
import { autoUpdater } from 'electron-updater'
import { createProtocol, installVueDevtools } from 'vue-cli-plugin-electron-builder/lib'
import logger from 'electron-log'
Expand All @@ -10,6 +8,7 @@ import { generateMenuTemplate, dockTemplate } from '@/toolbar/menu'
import Tor from '@/http/tor'
import '@/utils/keytar/main'
import * as Utils from './utils'
import { eventConstants } from './utils/constants'

logger.transports.file.level = 'debug'

Expand All @@ -20,6 +19,13 @@ const TOR_SOCKS_PORT = 9999
// Scheme must be registered before the app is ready
protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }])

const activateTorProxy = (win: BrowserWindow) => win.webContents.session.setProxy({
proxyRules: `socks5://127.0.0.1:${TOR_SOCKS_PORT}`,
proxyBypassRules: '<local>, 192.168.1.1/16, fefe:13::abc/33'
})

const deactivateTorProxy = (win: BrowserWindow) => win.webContents.session.setProxy({ proxyRules: undefined })

function createWindow () {
Menu.setApplicationMenu(Menu.buildFromTemplate(generateMenuTemplate()))

Expand Down Expand Up @@ -57,10 +63,7 @@ function createWindow () {

mainWindowState.manage(win)

win.webContents.session.setProxy({
proxyRules: `socks5://127.0.0.1:${TOR_SOCKS_PORT}`,
proxyBypassRules: '<local>, 192.168.1.1/16, fefe:13::abc/33'
}).then(() => {
activateTorProxy(win).then(() => {
if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
win!.loadURL(process.env.WEBPACK_DEV_SERVER_URL as string)
Expand Down Expand Up @@ -97,6 +100,8 @@ function createWindow () {
win.once('ready-to-show', () => {
win!.show()
})

return win
}

// Quit when all windows are closed.
Expand Down Expand Up @@ -157,7 +162,17 @@ app.on('ready', async () => {
console.error('Vue Devtools failed to install:', e.toString())
}
}
createWindow()
const window = createWindow()
ipcMain.on(eventConstants.toggleTor, async (event, arg: any) => {
if (arg.activate === true) {
await activateTorProxy(window)
} else {
await deactivateTorProxy(window)
}

event.returnValue = 'received'
event.reply(eventConstants.toggledTor)
})
})
})

Expand Down
153 changes: 153 additions & 0 deletions src/locale/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
export interface LocaleDefinition {
main: {
menu: {
wallets: string,
add: string,
explorer: string,
contacts: string
}
},
tor: {
status: {
title: string,
region: string,
ip: string,
unableToConnect: string,
loading: string,
connected: string,
disconnected: string
},
toggle: string
},
unlock: {
unlockYourWallet: string,
password: string,
forgotPassword: string
},
wallet: {
send: string,
receive: string
},
transaction: {
transaction: string,
sent: string,
sending: string,
received: string,
receiving: string,
moved: string,
pending: string,
amount: string,
date: string,
details: string,
address: string,
confirmations: string,
txid: string
},
send: {
formDescription: string,
confirmDescription: string,
sendingDescription: string,
send: string,
fillForm: string,
confirm: string,
sending: string,
sent: string,
recipient: string,
recipientDetails: string,
amount: string,
amountDetails: string,
internalMemo: string,
internalMemoDetails: string,
sendMax: string,
reset: string,
confirmTransaction: string,
cancel: string,
transactionFee: string,
total: string,
transactionWarning: string,
signing: string,
publishing: string,
broadcasting: string,
transactionSent: string,
transactionSentSubtitle: string,
done: string
},
createWallet: {
createNewWallet: string,
restoreExistingWallet: string,
addYourFirstWallet: string,
itsReallyEasy: string,
aWalletName: string,
aWalletNameDescription: string,
walletName: string,
enterYourWalletName: string,
walletColor: string,
advanced: string,
singleAddress: string,
serviceURL: string,
writeDownPaperKey: string,
preferences: string,
paperKey: string,
aPaperKey: string,
aPaperKeyDescription: string,
fillInYourPaperKey: string,
fillInYourPaperKeyDesc: string,
confirmPaperKey: string,
invalidPaperkeySelected: string,
passPhrase: string,
passPhraseDescription: string,
setupPassphraseReq1: string,
setupPassphraseReq2: string,
setupPassphraseReq3: string,
setupPassphrasePassPlaceholder: string,
confirmPassphrase: string,
passphraseInvalid: string,
confirm: string,
back: string,
proceed: string,
almostReady: string,
almostReadyDesc: string,
awesomeYouveDoneIt: string,
createTerm1: string,
createTerm2: string,
createTerm3: string,
termsOfUse: string,
openTermsOfUseConfirm: string,
createWallet: string,
creatingWallet: string,
walletCreated: string,
whatToDoNext: string,
exportYourWallet: string,
exportYourWalletDesc: string,
exportWallet: string,
sendXvgToYourWallet: string,
sendXvgToYourWalletDesc: string,
receiveXvg: string,
orGoToWallet: string,
orGoToWalletDesc: string,
goToWallet: string
},
walletSettings: {
walletSettings: string,
dangerZone: string,
delete: string,
deleteWallet: string,
deleteWalletDesc: string,
deleteWalletConfirm: string,
walletDeleted: string
},
settings: {
settings: string,
security: string,
language: string,
currency: string,
currencyDetails: string,
password: string,
changePassword: string,
lockAfter: string,
lockAfterDetails: string,
connection: string,
torConnection: string,
manageTorConnection: string
}
}
Loading

0 comments on commit b26bbf8

Please sign in to comment.