From 696ae700896e1cf4cac1cd8df4447ed45ca2708a Mon Sep 17 00:00:00 2001 From: Ihor Savchenko Date: Sun, 21 Mar 2021 12:28:48 +0200 Subject: [PATCH] add passwordless access point --- src/index.ts | 2 +- src/nm.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index af09aa4..03d32e2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ import { // defaults const AP_SSID = process.env.AP_SSID || `WiFi Repeater`; -const AP_PASSWORD = process.env.AP_PASSWORD || 'charlietheunicorn'; +const AP_PASSWORD = process.env.AP_PASSWORD || ''; const WIFI_SSID = process.env.WIFI_SSID; const WIFI_PASSWORD = process.env.WIFI_PASSWORD; diff --git a/src/nm.ts b/src/nm.ts index c48e8a8..ad532d7 100644 --- a/src/nm.ts +++ b/src/nm.ts @@ -48,10 +48,6 @@ export const createAccessPoint = async (device: WirelessNetwork): Promise = ['ssid', ['ay', stringToArrayOfBytes(device.ssid)]], ['mode', ['s', 'ap']], ]], - ['802-11-wireless-security', [ - ['key-mgmt', ['s', 'wpa-psk']], - ['psk', ['s', device.password]], - ]], ['ipv4', [ ['method', ['s', 'shared']], ]], @@ -60,6 +56,15 @@ export const createAccessPoint = async (device: WirelessNetwork): Promise = ]], ]; + if (device.password) { + connectionParams.push( + ['802-11-wireless-security', [ + ['key-mgmt', ['s', 'wpa-psk']], + ['psk', ['s', device.password]], + ]] + ); + } + const dbusPath = await getPathByIface(device.iface); const connection = await addConnection(connectionParams); const result = await activateConnection(connection, dbusPath);