Skip to content

Commit

Permalink
Fix filtering tab for Bedrock and start to switch to electron-store
Browse files Browse the repository at this point in the history
  • Loading branch information
Heath123 committed Dec 23, 2020
1 parent b8af0ff commit fe2a7d8
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 23 deletions.
Binary file modified data/proxypass-pakkit.jar
Binary file not shown.
30 changes: 16 additions & 14 deletions html/startPage/script.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
/* global localStorage */

const { ipcRenderer } = require('electron')
const Store = require('electron-store');

const store = new Store();

/* const customTitlebar = require('custom-electron-titlebar');
new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#FFF')
}); */

if (localStorage.getItem('authConsentGiven') !== 'true') {
if (!store.get('authConsentGiven')) {
document.getElementById('consent-box').style.display = 'contents'
}

let isLoading = false

let connectAddress
let connectPort


let listenPort
let platform
let version
Expand All @@ -33,19 +35,19 @@ function loadSettings (newPlatform) {
}

function saveSettings (thePlatform) {
localStorage.setItem('lastPlatform', platform)
localStorage.setItem(thePlatform + 'LastVersion', version)
localStorage.setItem(thePlatform + 'LastConnectAddress', connectAddress)
localStorage.setItem(thePlatform + 'LastConnectPort', connectPort)
localStorage.setItem(thePlatform + 'LastListenPort', listenPort)
store.set('lastPlatform', platform)
store.set(thePlatform + 'LastVersion', version)
store.set(thePlatform + 'LastConnectAddress', connectAddress)
store.set(thePlatform + 'LastConnectPort', connectPort)
store.set(thePlatform + 'LastListenPort', listenPort)
}

function loadSetting (name, varname, elementID, defaultValue) {
if (!localStorage.getItem(name)) {
localStorage.setItem(name, defaultValue)
if (!store.get(name)) {
store.set(name, defaultValue)
}

window[varname] = localStorage.getItem(name)
window[varname] = store.get(name)
document.getElementById(elementID).value = window[varname]
}

Expand Down Expand Up @@ -92,11 +94,11 @@ window.startProxy = function (event) {
listenPort = (listenPort === '') ? '25566' : listenPort
}
if (document.getElementById('consent').checked) {
localStorage.setItem('authConsentGiven', 'true')
store.set('authConsentGiven', true)
}
// TODO: Validate data (e.g. port range)
ipcRenderer.send('startProxy', JSON.stringify({
consent: localStorage.getItem('authConsentGiven') === 'true',
consent: store.get('authConsentGiven'),
connectAddress: connectAddress,
connectPort: connectPort,
listenPort: listenPort,
Expand Down
147 changes: 138 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"clusterize.js": "^0.18.1",
"electron-localshortcut": "^3.2.1",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^6.0.1",
"electron-unhandled": "^3.0.2",
"electron-window-state": "^5.0.3",
"escape-html": "^1.0.3",
Expand Down
11 changes: 11 additions & 0 deletions src/proxy/bedrock/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ exports.capabilities = {
jsonData: true,
rawData: true,
scriptingSupport: false,
clientboundPackets: {},
serverboundPackets: {},
wikiVgPage: 'https://wiki.vg/Bedrock_Protocol'
}

Expand All @@ -27,6 +29,15 @@ exports.startProxy = function (host, port, listenPort, version, authConsent, cal
proxyPass = java.import('com.nukkitx.proxypass.ProxyPass')
proxyPlayerSession = java.import('com.nukkitx.proxypass.network.bedrock.session.ProxyPlayerSession')

const packetTypes = JSON.parse(proxyPlayerSession.getIdBiMapStaticSync())
for (const index in packetTypes) {
const idString = '0x' + Number(index).toString(16).padStart(2, '0')
const name = packetTypes[index].toLowerCase()
// There isn't much of a distinction between serverbound and clientbound in Bedrock and many packets can be sent both ways
exports.capabilities.clientboundPackets[idString] = name
exports.capabilities.serverboundPackets[idString] = name
}

storedCallback = callback

console.log(proxyPass)
Expand Down

0 comments on commit fe2a7d8

Please sign in to comment.