Skip to content

Commit

Permalink
fix a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Dec 21, 2023
1 parent 9bf9b12 commit 113cd23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
8 changes: 4 additions & 4 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
},
"url": {
"type": "string",
"title": "Name",
"default": "URL",
"title": "URL",
"placeholder": "http://localhost:8581",
"pattern": "^https?://",
"required": false
},
Expand All @@ -29,8 +29,8 @@
},
"hostname": {
"type": "string",
"title": "Name",
"default": "hostname",
"title": "hostname",
"placeholder": "homebridge.local",
"required": true
},
"protocol": {
Expand Down
12 changes: 4 additions & 8 deletions src/platform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { startTunnel } from "ctun";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { startTunnel } = require('ctun');
import { CloudflaredTunnelPlatformConfig } from './settings';
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';

Expand Down Expand Up @@ -77,7 +78,7 @@ export class CloudflaredTunnelPlatform implements DynamicPlatformPlugin {
if (this.config.url && this.config.hostname) {
this.debugLog(`URL: ${this.config.url}`);
this.debugLog(`Hostname: ${this.config.hostname}`);
throw new Error(`Cannot have both url and hostname in config. Please remove one.`);
throw new Error('Cannot have both url and hostname in config. Please remove one.');
}
if (!this.config.logging) {
this.config.logging = 'standard';
Expand Down Expand Up @@ -106,12 +107,7 @@ export class CloudflaredTunnelPlatform implements DynamicPlatformPlugin {
//Default: {protocol}://{hostname}:{port}
//The local server URL to tunnel.

const tunnel = await startTunnel(
{
url: url,
verifyTLS: this.config.verifyTLS,
}
); // pass in the port of the server you want to tunnel
const tunnel = await startTunnel({ url: url, verifyTLS: this.config.verifyTLS});
this.infoLog(`Tunnel URL: ${tunnel}`);
} catch {
this.errorLog('Failed to Start Tunnel');
Expand Down
10 changes: 5 additions & 5 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const PLUGIN_NAME = 'homebridge-cloudflared-tunnel';

//Config
export interface CloudflaredTunnelPlatformConfig extends PlatformConfig {
url: string;
port: number;
hostname: string;
protocol: string;
verifyTLS: boolean;
url?: string;
port?: number;
hostname?: string;
protocol?: string;
verifyTLS?: boolean;
logging?: string;
}

0 comments on commit 113cd23

Please sign in to comment.