Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
chore: Remove secure sockets, proxy panel, enginepath file
Browse files Browse the repository at this point in the history
Remove secure sockets (no longer supported in buttplug),
the unused proxy panel, and the enginepath file (no longer
needed after moving to buttplug-rs).
  • Loading branch information
qdot committed Apr 10, 2021
1 parent e3ad1c9 commit 33cdb84
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 1,868 deletions.
2 changes: 0 additions & 2 deletions packages/core/src/GithubReleaseManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ export class GithubReleaseManager extends EventEmitter {
if (os.platform() !== "win32") {
await chmod(engineExecutable, 0o755);
}
const enginePathFile = path.join(IntifaceUtils.UserConfigDirectory, "enginepath.txt");
await writeFile(enginePathFile, engineDirectory, { encoding: "utf-8" });
// TODO Should download some sort of checksum to check against.
// TODO Should probably emit some sort of installerFinished event?
}
Expand Down
51 changes: 0 additions & 51 deletions packages/core/src/IntifaceBackendManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,42 +212,6 @@ export class IntifaceBackendManager extends EventEmitter {
}
}

private async MaybeGenerateCert() {
if (await this._certManager.HasGeneratedCerts()) {
return;
}
await this._certManager.GenerateCerts();
// Use the certificate check to update the new configuration file values
await this.CheckForCertificates();
this.UpdateFrontendConfiguration();
}

private async GenerateCert(aMsg: IntifaceProtocols.IntifaceFrontendMessage) {
await this.MaybeGenerateCert();
this._connector.SendMessage(IntifaceProtocols.IntifaceBackendMessage.create({
certificateGenerated: IntifaceProtocols.IntifaceBackendMessage.CertificateGenerated.create(),
}));
this._connector.SendOk(aMsg);
}

private async RunCertificateAcceptanceServer(aMsg: IntifaceProtocols.IntifaceFrontendMessage) {
await this.MaybeGenerateCert();
await this._certManager.RunCertAcceptanceServer(this._configManager.Config.WebsocketServerSecurePort);
const msg = IntifaceProtocols.IntifaceBackendMessage.create({
certificateAcceptanceServerRunning:
IntifaceProtocols.IntifaceBackendMessage.CertificateAcceptanceServerRunning.create({
insecurePort: this._certManager.InsecurePort,
}),
});
msg.index = aMsg.index;
this._connector.SendMessage(msg);
}

private async StopCertificateAcceptanceServer(aMsg: IntifaceProtocols.IntifaceFrontendMessage) {
this._certManager.StopServer();
this._connector.SendOk(aMsg);
}

private async CheckForUpdates(aMsg: IntifaceProtocols.IntifaceFrontendMessage | null) {
if (!this._configManager.Config.IsOnline) {
this._logger.debug("Uncertain of online status, not running update check.");
Expand Down Expand Up @@ -350,21 +314,6 @@ export class IntifaceBackendManager extends EventEmitter {
return;
}

if (aMsg.generateCertificate !== null) {
await this.GenerateCert(aMsg);
return;
}

if (aMsg.runCertificateAcceptanceServer !== null) {
await this.RunCertificateAcceptanceServer(aMsg);
return;
}

if (aMsg.stopCertificateAcceptanceServer !== null) {
await this.StopCertificateAcceptanceServer(aMsg);
return;
}

if (aMsg.checkForUpdates !== null) {
await this.CheckForUpdates(aMsg);
return;
Expand Down
46 changes: 0 additions & 46 deletions packages/core/src/IntifaceConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ export class IntifaceConfiguration extends EventEmitter {
private serverName: string = "Intiface Server";
private serverMaxPingTime: number = 0;
private useWebsocketServerInsecure: boolean = true;
private useWebsocketServerSecure: boolean = false;
private useProxyServer: boolean = false;
// private deviceListUpdateURL: string;
private websocketServerAllInterfaces: boolean = false;
private websocketServerInsecurePort: number = 12345;
private websocketServerSecurePort: number = 12346;
private serverLogLevel: ButtplugLogLevel = "Info";
private proxyServerPort: number = 12347;
private usePrereleaseEngine: boolean = false;
private currentEngineVersion: string = "";
private currentDeviceFileVersion: number = 0;
Expand Down Expand Up @@ -84,24 +80,6 @@ export class IntifaceConfiguration extends EventEmitter {
this.emit("update");
}

public get UseWebsocketServerSecure(): boolean {
return this.useWebsocketServerSecure;
}

public set UseWebsocketServerSecure(aShouldListen: boolean) {
this.useWebsocketServerSecure = aShouldListen;
this.emit("update");
}

public get UseProxyServer(): boolean {
return this.useProxyServer;
}

public set UseProxyServer(aShouldListen: boolean) {
this.useProxyServer = aShouldListen;
this.emit("update");
}

public get WebsocketServerInsecurePort(): number {
return this.websocketServerInsecurePort;
}
Expand All @@ -114,30 +92,6 @@ export class IntifaceConfiguration extends EventEmitter {
this.emit("update");
}

public get WebsocketServerSecurePort(): number {
return this.websocketServerSecurePort;
}

public set WebsocketServerSecurePort(aPort: number) {
if (aPort < 1 || aPort > 65536) {
throw new Error("Invalid network port number.");
}
this.websocketServerSecurePort = aPort;
this.emit("update");
}

public get ProxyServerPort(): number {
return this.proxyServerPort;
}

public set ProxyServerPort(aPort: number) {
if (aPort < 1 || aPort > 65536) {
throw new Error("Invalid network port number.");
}
this.proxyServerPort = aPort;
this.emit("update");
}

public get CurrentEngineVersion(): string {
return this.currentEngineVersion;
}
Expand Down
11 changes: 0 additions & 11 deletions packages/core/src/ProxyServer.ts

This file was deleted.

16 changes: 2 additions & 14 deletions packages/core/src/ServerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,13 @@ export class ServerProcess extends EventEmitter {
// process
args.push(`--frontendpipe`);
args.push(`--stayopen`);
if (this._config.UseWebsocketServerInsecure || this._config.UseWebsocketServerSecure) {
if (this._config.UseWebsocketServerInsecure) {
if (this._config.WebsocketServerAllInterfaces) {
args.push(`--wsallinterfaces`);
}
if (this._config.UseWebsocketServerInsecure) {
args.push(`--wsinsecureport`, `${this._config.WebsocketServerInsecurePort}`);
}
if (this._config.UseWebsocketServerSecure && this._config.HasCertificates) {
const cg = new CertManager(IntifaceUtils.UserConfigDirectory);
if (await cg.HasGeneratedCerts()) {
args.push(`--wssecureport`, `${this._config.WebsocketServerSecurePort}`);
args.push(`--wscertfile`, `${cg.CertFilePath}`);
args.push(`--wsprivfile`, `${cg.PrivKeyFilePath}`);
}
}
}
if (this._config.ServerLogLevel !== "Off") {
args.push(`--log`, `${this._config.ServerLogLevel}`);
Expand Down Expand Up @@ -228,11 +220,7 @@ export class ServerProcess extends EventEmitter {
private async GetServerExecutablePath(): Promise<string> {
const exists = promisify(fs.exists);
const readFile = promisify(fs.readFile);
const exePathFile = path.join(IntifaceUtils.UserConfigDirectory, "enginepath.txt");
if (!(await exists(exePathFile))) {
return Promise.reject(new Error(`Cannot find engine path file at ${exePathFile}.`));
}
const exePath = (await readFile(exePathFile, { encoding: "utf8" })).trim();
const exePath = path.join(IntifaceUtils.UserConfigDirectory, "engine");
if (!(await exists(exePath))) {
return Promise.reject(new Error(`Server executable install location ${exePath} does not exist.`));
}
Expand Down
9 changes: 0 additions & 9 deletions packages/intiface/src/components/ProxyPanel/ProxyPanel.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/intiface/src/components/ProxyPanel/ProxyPanel.vue

This file was deleted.

12 changes: 1 addition & 11 deletions packages/intiface/src/components/ServerPanel/ServerPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,10 @@
<v-checkbox v-model="config.UseWebsocketServerInsecure" :disabled="serverRunning"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Regular Websockets (on {{config.websocketServerAllInterfaces ? "[All Interfaces]" : "127.0.0.1"}}:{{ config.websocketServerInsecurePort }})</v-list-item-title>
<v-list-item-title>Websockets (on {{config.websocketServerAllInterfaces ? "[All Interfaces]" : "127.0.0.1"}}:{{ config.websocketServerInsecurePort }})</v-list-item-title>
<v-list-item-subtitle>Used for local applications (games, movie sync, etc...), or web applications in Chrome/Firefox/Edge, etc....</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-action>
<v-checkbox v-model="config.UseWebsocketServerSecure" :disabled="serverRunning || !config.HasCertificates"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>SSL Websockets (on {{config.websocketServerAllInterfaces ? "[All Interfaces]" : "127.0.0.1"}}:{{ config.websocketServerSecurePort }})</v-list-item-title>
<v-list-item-subtitle v-if="!config.HasCertificates">Disabled because cert generation has not happened. Cert generation is available on the Setting tab.</v-list-item-subtitle>
<v-list-item-subtitle>Only needed in special instances, such as web applications on other machines, etc...</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
<v-flex v-if="config.HasUsableEngineExecutable && config.Engine === config.InstalledEngineType && config.currentDeviceFileVersion >= 48" shrink>
<v-btn outlined class="my-3" :disabled="!config.UseIpcServer && !config.UseWebsocketServerInsecure && !config.UseWebsocketServerSecure" @click="ToggleServer()">{{ serverRunning ? serverStates[1] : serverStates[0] }}</v-btn>
Expand Down
45 changes: 1 addition & 44 deletions packages/intiface/src/components/SettingsPanel/SettingsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ export default class SettingsPanel extends Vue {
private panelExpand: boolean[] = [];
private panelOpen: number[] = [0, 1, 2, 3, 4];
private factoryResetDialog: boolean = false;
private certAcceptDialog: boolean = false;
private internalInsecureWebsocketPort: number = 1;
private internalSecureWebsocketPort: number = 1;
private internalErrors: string[] = [];

private mounted() {
this.UpdateRequirements();
this.internalInsecureWebsocketPort = this.config.WebsocketServerInsecurePort;
this.internalSecureWebsocketPort = this.config.WebsocketServerSecurePort;
if (window.location.hash === "#version") {
this.panelExpand = [true];
}
Expand Down Expand Up @@ -86,22 +83,6 @@ export default class SettingsPanel extends Vue {
}
}

private async StartCertServer() {
if (!this.config.HasCertificates) {
await this.connector.GenerateCertificate();
}
let maybe_port = await this.connector.RunCertificateAcceptanceServer();
if (maybe_port.certificateAcceptanceServerRunning) {
let port = maybe_port.certificateAcceptanceServerRunning!.insecurePort!;
window.open(`http://127.0.0.1:${port}`, "_blank");
}
}

private async StopCertServer() {
await this.connector.StopCertificateAcceptanceServer();
this.certAcceptDialog = false;
}

private async ResetIntiface() {
await this.connector.ResetIntifaceConfiguration();
}
Expand All @@ -113,34 +94,10 @@ export default class SettingsPanel extends Vue {
private set InsecureWebsocketPort(port: number) {
try {
this.internalInsecureWebsocketPort = port;
if (this.internalInsecureWebsocketPort == this.internalSecureWebsocketPort) {
this.internalErrors = ["Regular and SSL Websocket port numbers must be different"]
return;
} else {
this.internalErrors = []
}
this.internalErrors = []
this.config.WebsocketServerInsecurePort = port;
} catch {
// pass here, vee-validate will handle the error on the frontend.
}
}

private get SecureWebsocketPort(): number {
return this.internalSecureWebsocketPort;
}

private set SecureWebsocketPort(port: number) {
try {
this.internalSecureWebsocketPort = port;
if (this.internalInsecureWebsocketPort == this.internalSecureWebsocketPort) {
this.internalErrors = ["Regular and SSL Websocket port numbers must be different"]
return;
} else {
this.internalErrors = []
}
this.config.WebsocketServerSecurePort = port;
} catch {
// pass here, vee-validate will handle the error on the frontend.
}
}
}
43 changes: 0 additions & 43 deletions packages/intiface/src/components/SettingsPanel/SettingsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,6 @@
</ValidationProvider>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<ValidationProvider
v-slot="{ errors }"
rules="required|numeric|min_value:1|max_value:65535"
>
<v-text-field
data-vv-name="websocketSecurePort"
:error-messages="errors.length > 0 ? errors : internalErrors"
label="SSL Websocket Port"
:disabled="connector.IsServerProcessRunning"
v-model="SecureWebsocketPort"
></v-text-field>
</ValidationProvider>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-action>
<v-checkbox
Expand All @@ -161,33 +145,6 @@
<v-expansion-panel>
<v-expansion-panel-header>Other Settings</v-expansion-panel-header>
<v-expansion-panel-content class="transparent" popout>
<div>
<v-card class="transparent">
<v-card-text>
<v-btn color="primary" @click="RunSetup()">Run Initial Setup</v-btn>
</v-card-text>
</v-card>
</div>
<div>
<v-card class="transparent">
<v-card-text>
<v-dialog v-model="certAcceptDialog" persistent max-width="400">
<template v-slot:activator="{ on, attrs }">
<v-btn color="primary" dark v-bind="attrs" v-on="on">Run Certificate Configuration</v-btn>
</template>
<v-card>
<v-card-title class="headline">Certificate Acceptance</v-card-title>
<v-card-text>Your certs have been generated, but you will now need to accept them in Firefox. Hit the "Launch" button below to open the webpage, or "Cancel" to quit. Note that this will not work in Chrome, and Chrome does not require local certs.</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="StartCertServer()">Launch</v-btn>
<v-btn text @click="StopCertServer()">Cancel</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-card-text>
</v-card>
</div>
<div>
<v-card class="transparent">
<v-card-text>
Expand Down
18 changes: 0 additions & 18 deletions packages/intiface/src/components/SetupPanel/SetupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { FrontendConnector, IntifaceConfiguration, IntifaceUtils } from "intifac
export default class SetupPanel extends Vue {
private setupStep: number = 1;
private updateFinished: boolean = false;
private usingFirefox: boolean = false;
private certAcceptDialog: boolean = false;
@Prop()
private connector!: FrontendConnector;
@Prop()
Expand All @@ -23,20 +21,4 @@ export default class SetupPanel extends Vue {
this.config.HasRunSetup = true;
router.push("home");
}

private async StartCertServer() {
if (!this.config.HasCertificates) {
await this.connector.GenerateCertificate();
}
let maybe_port = await this.connector.RunCertificateAcceptanceServer();
if (maybe_port.certificateAcceptanceServerRunning) {
let port = maybe_port.certificateAcceptanceServerRunning!.insecurePort!;
window.open(`http://127.0.0.1:${port}`, "_blank");
}
}

private async StopCertServer() {
await this.connector.StopCertificateAcceptanceServer();
this.certAcceptDialog = false;
}
}
Loading

0 comments on commit 33cdb84

Please sign in to comment.