Archived
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79a161d303 | ||
|
|
24553a38e8 | ||
|
|
66cc11d43d | ||
|
|
00ab8ef053 | ||
|
|
71a98fbff7 | ||
|
|
90c6aee83b |
@@ -1,4 +1,5 @@
|
|||||||
resources/netbird*
|
resources/netbird*
|
||||||
|
resources/*.dll
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vynte-connect",
|
"name": "vynte-connect",
|
||||||
"productName": "Vynte Connect",
|
"productName": "Vynte Connect",
|
||||||
"version": "1.0.0-rc.1",
|
"version": "1.0.0-rc.2",
|
||||||
"description": "VPN used to access internal Vynte services",
|
"description": "VPN used to access internal Vynte services",
|
||||||
"main": ".vite/build/main.js",
|
"main": ".vite/build/main.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
+3
-2
@@ -1,13 +1,14 @@
|
|||||||
|
import { NetworkStatus } from "./types";
|
||||||
|
|
||||||
export const MANAGEMENT_URL = 'https://vpn.vyntehome.com';
|
export const MANAGEMENT_URL = 'https://vpn.vyntehome.com';
|
||||||
export const GATEWAY_HOST = new URL(MANAGEMENT_URL).host;
|
export const GATEWAY_HOST = new URL(MANAGEMENT_URL).host;
|
||||||
export const APP_NAME = "Vynte Connect";
|
export const APP_NAME = "Vynte Connect";
|
||||||
export const POLL_INTERVAL_MS = 5000;
|
export const POLL_INTERVAL_MS = 5000;
|
||||||
export const WINDOW_WIDTH = 384;
|
export const WINDOW_WIDTH = 384;
|
||||||
export const WINDOW_HEIGHT = 420;
|
export const WINDOW_HEIGHT = 420;
|
||||||
export const DEFAULT_STATUS = {
|
export const DEFAULT_STATUS: NetworkStatus = {
|
||||||
state: "checking",
|
state: "checking",
|
||||||
title: `Checking ${GATEWAY_HOST}`,
|
title: `Checking ${GATEWAY_HOST}`,
|
||||||
message: "Preparing the Vynte access client.",
|
message: "Preparing the Vynte access client.",
|
||||||
connectedSince: null,
|
|
||||||
gatewayHost: GATEWAY_HOST
|
gatewayHost: GATEWAY_HOST
|
||||||
};
|
};
|
||||||
+7
-4
@@ -4,6 +4,7 @@ import started from 'electron-squirrel-startup';
|
|||||||
import { APP_NAME, DEFAULT_STATUS, GATEWAY_HOST, MANAGEMENT_URL, POLL_INTERVAL_MS, WINDOW_HEIGHT, WINDOW_WIDTH } from './config';
|
import { APP_NAME, DEFAULT_STATUS, GATEWAY_HOST, MANAGEMENT_URL, POLL_INTERVAL_MS, WINDOW_HEIGHT, WINDOW_WIDTH } from './config';
|
||||||
import { NetBirdClient } from './netbird';
|
import { NetBirdClient } from './netbird';
|
||||||
import { baseStatus, normalizeStatus } from './status';
|
import { baseStatus, normalizeStatus } from './status';
|
||||||
|
import { NetworkStatus, UIStatus } from './types';
|
||||||
|
|
||||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||||
if (started) {
|
if (started) {
|
||||||
@@ -57,7 +58,7 @@ let tray: Tray;
|
|||||||
let window: BrowserWindow;
|
let window: BrowserWindow;
|
||||||
let pollTimer: NodeJS.Timeout;
|
let pollTimer: NodeJS.Timeout;
|
||||||
let autoConnect = false;
|
let autoConnect = false;
|
||||||
let cachedStatus = { ...DEFAULT_STATUS };
|
let cachedStatus = DEFAULT_STATUS;
|
||||||
|
|
||||||
function resourcePath(name: string) {
|
function resourcePath(name: string) {
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
@@ -70,7 +71,7 @@ function netbirdClient() {
|
|||||||
return new NetBirdClient(resourcePath(process.platform === "win32" ? 'netbird.exe' : 'netbird'));
|
return new NetBirdClient(resourcePath(process.platform === "win32" ? 'netbird.exe' : 'netbird'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function withAutoConnect(status: Record<string, any>) {
|
function withAutoConnect(status: NetworkStatus): UIStatus {
|
||||||
return { ...status, autoConnect };
|
return { ...status, autoConnect };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ function updateTray() {
|
|||||||
tray.setContextMenu(Menu.buildFromTemplate(template));
|
tray.setContextMenu(Menu.buildFromTemplate(template));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus(status: Record<string, any>) {
|
function setStatus(status: NetworkStatus) {
|
||||||
cachedStatus = {
|
cachedStatus = {
|
||||||
...cachedStatus,
|
...cachedStatus,
|
||||||
...status,
|
...status,
|
||||||
@@ -126,7 +127,9 @@ async function refreshStatus() {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return setStatus(normalizeStatus(result.stdout, cachedStatus));
|
const status = normalizeStatus(result.stdout, cachedStatus);
|
||||||
|
if (status.state === "disconnected" && cachedStatus.state === "connecting") return;
|
||||||
|
setStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function connect() {
|
async function connect() {
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@
|
|||||||
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
||||||
|
|
||||||
import { contextBridge, ipcRenderer } from "electron";
|
import { contextBridge, ipcRenderer } from "electron";
|
||||||
|
import { UIStatus } from "./types";
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('vynte', {
|
contextBridge.exposeInMainWorld('vynte', {
|
||||||
getStatus: () => ipcRenderer.invoke('status:get'),
|
getStatus: () => ipcRenderer.invoke('status:get'),
|
||||||
@@ -12,5 +13,5 @@ contextBridge.exposeInMainWorld('vynte', {
|
|||||||
toggleAuto: () => ipcRenderer.invoke('auto:toggle'),
|
toggleAuto: () => ipcRenderer.invoke('auto:toggle'),
|
||||||
quit: () => ipcRenderer.invoke('app:quit'),
|
quit: () => ipcRenderer.invoke('app:quit'),
|
||||||
openGateway: () => ipcRenderer.invoke('external:openGateway'),
|
openGateway: () => ipcRenderer.invoke('external:openGateway'),
|
||||||
onStatus: (callback: Function) => ipcRenderer.on('status', (_, status) => callback(status))
|
onStatus: (callback: (status: UIStatus) => void) => ipcRenderer.on('status', (_, status) => callback(status))
|
||||||
})
|
})
|
||||||
+2
-7
@@ -27,7 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import type { NetworkStatus } from './status';
|
import { UIStatus } from './types';
|
||||||
|
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
|
|
||||||
@@ -40,10 +40,6 @@ const auto = document.getElementById('auto') as HTMLElement;
|
|||||||
const logout = document.getElementById('logout') as HTMLElement;
|
const logout = document.getElementById('logout') as HTMLElement;
|
||||||
const quit = document.getElementById('quit') as HTMLElement;
|
const quit = document.getElementById('quit') as HTMLElement;
|
||||||
|
|
||||||
interface UIStatus extends NetworkStatus {
|
|
||||||
autoConnect?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
let currentStatus: Partial<UIStatus> = {
|
let currentStatus: Partial<UIStatus> = {
|
||||||
state: 'checking',
|
state: 'checking',
|
||||||
};
|
};
|
||||||
@@ -72,11 +68,10 @@ function setStatus(status: UIStatus): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
orb.addEventListener('click', async () => {
|
orb.addEventListener('click', async () => {
|
||||||
if (currentStatus.state === 'connected') {
|
if (['connected', 'connecting'].includes(currentStatus.state ?? '')) {
|
||||||
await window.vynte.disconnect();
|
await window.vynte.disconnect();
|
||||||
} else if (
|
} else if (
|
||||||
![
|
![
|
||||||
'connecting',
|
|
||||||
'disconnecting',
|
'disconnecting',
|
||||||
'loggingOut',
|
'loggingOut',
|
||||||
'checking',
|
'checking',
|
||||||
|
|||||||
+2
-12
@@ -1,12 +1,5 @@
|
|||||||
import { GATEWAY_HOST } from './config';
|
import { GATEWAY_HOST } from './config';
|
||||||
|
import { NetworkStatus } from './types';
|
||||||
export interface NetworkStatus {
|
|
||||||
state?: string;
|
|
||||||
title?: string;
|
|
||||||
message?: string;
|
|
||||||
connectedSince: number | null;
|
|
||||||
gatewayHost: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NetBirdStatusResponse {
|
interface NetBirdStatusResponse {
|
||||||
daemonStatus?: string;
|
daemonStatus?: string;
|
||||||
@@ -22,11 +15,8 @@ interface NetBirdStatusResponse {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function baseStatus(
|
export function baseStatus(overrides: NetworkStatus): NetworkStatus {
|
||||||
overrides: Partial<NetworkStatus> = {}
|
|
||||||
): NetworkStatus {
|
|
||||||
return {
|
return {
|
||||||
connectedSince: null,
|
|
||||||
gatewayHost: GATEWAY_HOST,
|
gatewayHost: GATEWAY_HOST,
|
||||||
...overrides,
|
...overrides,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export interface NetworkStatus {
|
||||||
|
state: string;
|
||||||
|
title: string;
|
||||||
|
message: string;
|
||||||
|
connectedSince?: number;
|
||||||
|
gatewayHost?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UIStatus extends NetworkStatus {
|
||||||
|
autoConnect?: boolean;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user