Updated 9 files, added 12 files and renamed .idea/ponieswatch.iml (automated)

mane
Mia Raindrops 2 weeks ago
parent 8ecde1d333
commit 9b42afa8d7
Signed by: Mia Raindrops
GPG Key ID: EFBDC68435A574B7

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ponieswatch.iml" filepath="$PROJECT_DIR$/.idea/ponieswatch.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/luna.iml" filepath="$PROJECT_DIR$/.idea/luna.iml" />
</modules>
</component>
</project>

150
app.js

@ -1,10 +1,92 @@
const { app, desktopCapturer, dialog } = require('electron');
const { app, desktopCapturer, dialog, Tray, Menu, shell } = require('electron');
const { platform, hostname } = require('node:os');
const { writeFileSync, existsSync, readFileSync } = require('node:fs');
const axios = require('axios');
const si = require('systeminformation');
global.luna_version = "1.1.0";
global.luna_version = "1.2.0";
global.lastSentData = {};
global.clientsList = {};
global.lastDataUpdate = 0;
global.proxyStatus = 0;
global.computerId = "";
function timeAgo(time) {
if (!isNaN(parseInt(time))) {
time = new Date(time).getTime();
}
if (time === 0) return "never";
let periods = ["sec", "min", "hr", "d", "wk", "mo", "y", "ages"];
let lengths = ["60", "60", "24", "7", "4.35", "12", "100"];
let now = new Date().getTime();
let difference = Math.round((now - time) / 1000);
let tense;
let period;
if (difference <= 10 && difference >= 0) {
return "now";
} else if (difference > 0) {
tense = "ago";
} else {
tense = "later";
}
let j;
for (j = 0; difference >= lengths[j] && j < lengths.length - 1; j++) {
difference /= lengths[j];
}
difference = Math.round(difference);
period = periods[j];
return `${difference} ${period} ${tense}`;
}
app.whenReady().then(() => {
global.tray = new Tray(__dirname + '/icons/tray/16x16Template@2x.png');
updateTray();
})
function updateTray() {
let template = [
{ label: 'Luna ' + luna_version, type: 'normal', enabled: false, icon: __dirname + "/icons/menu/16x16@2x.png" },
{ type: 'separator' },
{ label: global.proxyStatus === 0 ? "Disconnected" : (global.proxyStatus === 1 ? "Connecting..." : "Connected to proxy"), type: 'normal', enabled: false },
{ label: 'Last updated ' + timeAgo(global.lastDataUpdate), type: 'normal', enabled: false },
{ type: 'separator' },
{ label: 'Connected clients:', type: 'normal', enabled: false },
];
if (Object.values(global.clientsList).filter(i => i).length > 0) {
for (let client of Object.values(global.clientsList)) {
template.push({ label: ' ' + client.name + ' (' + client.location + ", " + client.ip + ")", type: 'normal', click: () => {
client.socket.close();
} });
}
} else {
template.push({ label: ' (no connections)', type: 'normal', enabled: false })
}
template.push(...[
{ type: 'separator' },
{ label: "View on Cold Haze", accelerator: "CmdOrCtrl+O", click: () => {
shell.openExternal("https://ponies.equestria.horse/-/computers/" + global.computerId)
} },
{ label: 'Quit', type: 'normal', role: 'quit', accelerator: "CmdOrCtrl+Q" }
]);
const contextMenu = Menu.buildFromTemplate(template);
tray.setToolTip('Luna ' + luna_version);
tray.setContextMenu(contextMenu);
}
process.on('uncaughtException', (e) => {
console.error(e);
@ -63,6 +145,8 @@ async function systemProfile() {
})
}
global.lastSentData = data;
let sources = await desktopCapturer.getSources({ types: ['screen'], thumbnailSize: { width: 445, height: 256 } });
for (let source of sources) {
@ -75,11 +159,17 @@ async function systemProfile() {
});
}
await axios("https://ponies.equestria.horse/api/computer?type=data", {
method: "post",
data,
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
});
try {
global.computerId = (await axios("https://ponies.equestria.horse/api/computer?type=data", {
method: "post",
data,
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
})).data;
global.lastDataUpdate = new Date().getTime();
} catch (e) {
console.error(e);
}
writeFileSync("./data.json", JSON.stringify(data));
}
@ -90,15 +180,19 @@ async function refresh() {
for (let source of sources) {
console.log(`Screen ${source.id} (${source.name})`);
console.log((await axios("https://ponies.equestria.horse/api/computer?type=screenshot", {
method: "post",
data: {
host: hostname(),
id: source.display_id,
data: source.thumbnail.toJPEG(80).toString("base64")
},
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
})).data);
try {
console.log((await axios("https://ponies.equestria.horse/api/computer?type=screenshot", {
method: "post",
data: {
host: hostname(),
id: source.display_id,
data: source.thumbnail.toJPEG(80).toString("base64")
},
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
})).data);
} catch (e) {
console.error(e);
}
}
}
@ -122,16 +216,24 @@ app.whenReady().then(async () => {
refresh();
systemProfile();
setInterval(async () => {
await axios("https://ponies.equestria.horse/api/computer?type=heartbeat", {
method: "POST",
data: {
host: hostname()
},
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
});
setInterval(() => {
updateTray();
}, 1000);
setInterval(async () => {
try {
await axios("https://ponies.equestria.horse/api/computer?type=heartbeat", {
method: "POST",
data: {
host: hostname()
},
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
});
} catch (e) {
console.error(e);
}
}, 5000);
setInterval(() => {
refresh();
}, 60000);

@ -1,5 +1,5 @@
#!/bin/bash
npx electron-packager --overwrite ./
npx electron-packager --overwrite --platform linux ./
npx electron-packager --overwrite --platform linux --arch x64 ./
npx electron-packager --overwrite --platform win32 --arch x64 ./
npx electron-packager --icon ./icons/logo-macos.png --overwrite --platform darwin --arch arm64 ./
npx electron-packager --icon ./icons/logo.png --overwrite --platform linux --arch arm64 ./
npx electron-packager --icon ./icons/logo.png --overwrite --platform linux --arch x64 ./
npx electron-packager --icon ./icons/logo.png --overwrite --platform win32 --arch x64 ./

@ -0,0 +1,2 @@
#!/bin/bash
npx electron-packager --icon ./icons/logo-macos.png --overwrite --platform darwin --arch arm64 ./

@ -0,0 +1,20 @@
#!/usr/bin/env bash
dir=$(dirname $PWD/$0)
input_filepath="icons/logo-macos.png"
output_iconset_name="icons/logo-macos.iconset"
mkdir $output_iconset_name
sips -z 16 16 $input_filepath --out "${output_iconset_name}/icon_16x16.png"
sips -z 32 32 $input_filepath --out "${output_iconset_name}/icon_16x16@2x.png"
sips -z 32 32 $input_filepath --out "${output_iconset_name}/icon_32x32.png"
sips -z 64 64 $input_filepath --out "${output_iconset_name}/icon_32x32@2x.png"
sips -z 128 128 $input_filepath --out "${output_iconset_name}/icon_128x128.png"
sips -z 256 256 $input_filepath --out "${output_iconset_name}/icon_128x128@2x.png"
sips -z 256 256 $input_filepath --out "${output_iconset_name}/icon_256x256.png"
sips -z 512 512 $input_filepath --out "${output_iconset_name}/icon_256x256@2x.png"
sips -z 512 512 $input_filepath --out "${output_iconset_name}/icon_512x512.png"
iconutil -c icns $output_iconset_name
rm -R $output_iconset_name

File diff suppressed because one or more lines are too long

@ -2,6 +2,7 @@ const { WebSocketServer } = require('ws');
const { desktopCapturer, screen, dialog } = require('electron');
const { mouse, keyboard, Point, Key } = require("@nut-tree/nut-js");
const axios = require('axios');
const uuid = require('uuid-v4');
const wss = new WebSocketServer({ host: "127.0.0.1", port: 38071 });
const clients = [];
@ -40,6 +41,14 @@ wss.on('connection', function connection(ws) {
let ip = (await axios.get("https://api.iplocation.net/?ip=" + address)).data;
ws.userIdentity = {
id: null,
socket: ws,
location: ip['country_name'],
ip: address,
name: name
}
dialog.showMessageBox({
type: "question",
buttons: [
@ -74,7 +83,12 @@ wss.on('connection', function connection(ws) {
function setup() {
let currentScreen = 0;
ws.id = uuid();
clients.push(ws);
ws.userIdentity.id = ws.id;
global.clientsList[ws.id] = ws.userIdentity;
ws.send(JSON.stringify({
type: "command_stdout",
@ -500,6 +514,7 @@ wss.on('connection', function connection(ws) {
});
ws.on('close', () => {
delete global.clientsList[ws.id];
clients.splice(clients.indexOf(ws), 1);
if (ws.cmd) {

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

10
node_modules/.package-lock.json generated vendored

@ -1,5 +1,5 @@
{
"name": "ponieswatch",
"name": "Luna",
"lockfileVersion": 2,
"requires": true,
"packages": {
@ -4097,6 +4097,14 @@
"uuid": "bin/uuid"
}
},
"node_modules/uuid-v4": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/uuid-v4/-/uuid-v4-0.1.0.tgz",
"integrity": "sha512-m11RYDtowtAIihBXMoGajOEKpAXrKbpKlpmxqyztMYQNGSY5nZAZ/oYch/w2HNS1RMA4WLGcZvuD8/wFMuCEzA==",
"engines": {
"node": "*"
}
},
"node_modules/validate-npm-package-license": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",

28
node_modules/uuid-v4/index.js generated vendored

@ -0,0 +1,28 @@
exports = module.exports = function() {
var ret = '', value;
for (var i = 0; i < 32; i++) {
value = exports.random() * 16 | 0;
// Insert the hypens
if (i > 4 && i < 21 && ! (i % 4)) {
ret += '-';
}
// Add the next random character
ret += (
(i === 12) ? 4 : (
(i === 16) ? (value & 3 | 8) : value
)
).toString(16);
}
return ret;
};
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
exports.isUUID = function(uuid) {
return uuidRegex.test(uuid);
};
exports.random = function() {
return Math.random();
};

13
node_modules/uuid-v4/package.json generated vendored

@ -0,0 +1,13 @@
{
"author": "James Brumond <james@jbrumond.me> (http://jbrumond.me)",
"name": "uuid-v4",
"description": "A simple v4 UUID generator",
"version": "0.1.0",
"main": "index.js",
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"engines": {
"node": "*"
}
}

33
node_modules/uuid-v4/readme.md generated vendored

@ -0,0 +1,33 @@
# uuid-v4
A Node.js module for generating and validation V4 UUIDs
## Install
```bash
$ npm install uuid-v4
```
## Usage
```javascript
var uuid = require('uuid-v4');
// Generate a new UUID
var myUUID = uuid();
// Validate a UUID as proper V4 format
uuid.isUUID(myUUID); // true
```
## MIT License
Copyright (c) 2012 James Brumond
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

17
package-lock.json generated

@ -1,15 +1,17 @@
{
"name": "ponieswatch",
"name": "Luna",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "Luna",
"dependencies": {
"@nut-tree/nut-js": "^2.3.0",
"axios": "^1.1.3",
"electron": "^21.2.2",
"electron-packager": "^17.1.1",
"systeminformation": "^5.12.12",
"uuid-v4": "^0.1.0",
"ws": "^8.10.0"
}
},
@ -4107,6 +4109,14 @@
"uuid": "bin/uuid"
}
},
"node_modules/uuid-v4": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/uuid-v4/-/uuid-v4-0.1.0.tgz",
"integrity": "sha512-m11RYDtowtAIihBXMoGajOEKpAXrKbpKlpmxqyztMYQNGSY5nZAZ/oYch/w2HNS1RMA4WLGcZvuD8/wFMuCEzA==",
"engines": {
"node": "*"
}
},
"node_modules/validate-npm-package-license": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
@ -7435,6 +7445,11 @@
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
},
"uuid-v4": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/uuid-v4/-/uuid-v4-0.1.0.tgz",
"integrity": "sha512-m11RYDtowtAIihBXMoGajOEKpAXrKbpKlpmxqyztMYQNGSY5nZAZ/oYch/w2HNS1RMA4WLGcZvuD8/wFMuCEzA=="
},
"validate-npm-package-license": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",

@ -7,6 +7,7 @@
"electron": "^21.2.2",
"electron-packager": "^17.1.1",
"systeminformation": "^5.12.12",
"uuid-v4": "^0.1.0",
"ws": "^8.10.0"
}
}

@ -14,9 +14,11 @@ async function main() {
console.log(username);
try {
global.proxyStatus = 1;
global.pws = new WebSocket("wss://ponies.equestria.horse/_Computers-RemoteControl-EntryPoint/socket");
pws.closed = false;
} catch (e) {
global.proxyStatus = 0;
console.error(e);
console.log("Failed");
@ -27,6 +29,8 @@ async function main() {
pws.on("open", () => {
console.log("Connected");
global.proxyStatus = 2;
pws.send(JSON.stringify({
type: "server",
id: username + "-" + require('node:crypto').createHash("md5").update(require('node:os').hostname()).digest("hex")
@ -56,7 +60,9 @@ async function main() {
}));
})
} else if (data.type === "close") {
clients[data.id].close();
try {
clients[data.id].close();
} catch (e) {}
} else if (data._id) {
clients[data._id].send(_data);
}
@ -66,6 +72,7 @@ async function main() {
})
pws.on('close', () => {
global.proxyStatus = 0;
pws.closed = true;
console.log("Disconnected");

Loading…
Cancel
Save