Skip to content

Commit

Permalink
Merge pull request #89 from Grizzelbee/development
Browse files Browse the repository at this point in the history
v1.5.11
  • Loading branch information
Grizzelbee committed Aug 30, 2023
2 parents acaf763 + 8e23648 commit a749b02
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 138 deletions.
128 changes: 81 additions & 47 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Test and Release
on:
push:
branches:
- "master"
- "*"
tags:
# normal versions
- "v[0-9]+.[0-9]+.[0-9]+"
Expand All @@ -20,64 +20,98 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

steps:
- uses: ioBroker/testing-action-check@v1
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: '14.x'
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
lint: true
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm ci

- name: Lint source code
run: npm run lint
- name: Test package files
run: npm run test:package

# Runs adapter tests on all supported node versions and OSes
adapter-tests:
if: contains(github.event.head_commit.message, '[skip ci]') == false

needs: [check-and-lint]

runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]

exclude:
# Don't test Node.js 8 on Windows. npm is weird here
- os: windows-latest
node-version: 8.x
steps:
- uses: ioBroker/testing-action-adapter@v1
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'

# TODO: To enable automatic npm releases, create a token on npmjs.org
# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
# Then uncomment the following block:

# # Deploys the final package to NPM
# deploy:
# needs: [check-and-lint, adapter-tests]
#
# # Trigger this step only when a commit on any branch is tagged with a version number
# if: |
# contains(github.event.head_commit.message, '[skip ci]') == false &&
# github.event_name == 'push' &&
# startsWith(github.ref, 'refs/tags/v')
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: ioBroker/testing-action-deploy@v1
# with:
# node-version: '14.x'
# # Uncomment the following line if your adapter cannot be installed using 'npm ci'
# # install-command: 'npm install'
# npm-token: ${{ secrets.NPM_TOKEN }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
#
# # When using Sentry for error reporting, Sentry can be informed about new releases
# # To enable create a API-Token in Sentry (User settings, API keys)
# # Enter this token as a GitHub secret (with name SENTRY_AUTH_TOKEN) in the repository options
# # Then uncomment and customize the following block:
# sentry: true
# sentry-token: ${{ secrets.SENTRY_AUTH_TOKEN }}
# sentry-project: "iobroker-mielecloudservice"
# sentry-version-prefix: "iobroker.mielecloudservice"
# # If your sentry project is linked to a GitHub repository, you can enable the following option
# # sentry-github-integration: true

- name: Install Dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit

- name: Run integration tests (unix only)
if: startsWith(runner.OS, 'windows') == false
run: DEBUG=testing:* npm run test:integration

- name: Run integration tests (windows only)
if: startsWith(runner.OS, 'windows')
run: set DEBUG=testing:* & npm run test:integration

# TODO: To enable automatic npm releases, create a token on npmjs.org
# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
# Then uncomment the following block:

# # Deploys the final package to NPM
deploy:
needs: [adapter-tests]

# Trigger this step only when a commit on master is tagged with a version number
if: |
contains(github.event.head_commit.message, '[skip ci]') == false &&
github.event_name == 'push' &&
github.event.base_ref == 'refs/heads/master' &&
startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Publish package to npm
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
npm publish
# Dummy job for skipped builds - without this, github reports the build as failed
skip-ci:
if: contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- name: Skip build
run: echo "Build skipped!"
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ Basically there are three ways to execute the command:
## Changelog
### **WORK IN PROGRESS**

### 1.5.11 (2023-08-30)
* (grizzelbee) Fix: [#88](https://github.com/Grizzelbee/ioBroker.wireguard/issues/88) Avoid warning: Cannot read properties of undefined (reading 'at') when user- or devicename is empty

### 1.5.10 (2023-08-17)
* (grizzelbee) Fix: Adapter doesn't crash anymore when user or device name is missing in config.

Expand All @@ -128,8 +131,8 @@ Basically there are three ways to execute the command:
* (grizzelbee) Fix: Some fixes to make iobroker.adapterchecker happy

### 1.5.1 (2023-08-08)
* (grizzelbee) Fix: [#65](https://github.com/Grizzelbee/ioBroker.wireguard/issues/65) No names in object tree
* (grizzelbee) Fix: [#64](https://github.com/Grizzelbee/ioBroker.wireguard/issues/64) Online state of interface isn't set correctly if more than one server is queried
* (grizzelbee) Fix: [#65](https://github.com/Grizzelbee/ioBroker.wireguard/issues/65) No names in object tree
* (grizzelbee) Fix: [#64](https://github.com/Grizzelbee/ioBroker.wireguard/issues/64) Online state of interface isn't set correctly if more than one server is queried
* (grizzelbee) Upd: Dependencies got updated

### 1.5.0 (2023-06-27)
Expand Down
15 changes: 14 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"common": {
"name": "wireguard",
"version": "1.5.10",
"version": "1.5.11",
"news": {
"1.5.11": {
"en": "Avoid warning: Cannot read properties of undefined (reading 'at') when user- or devicename is empty",
"de": "Warnung vermeiden: Eigenschaften von undefiniert (Lesen von „at“) können nicht gelesen werden, wenn der Benutzer- oder Gerätename leer ist",
"ru": "Избегайте предупреждений: невозможно прочитать свойства неопределенного значения (чтение «at»), если имя пользователя или имя устройства пусто.",
"pt": "Evite aviso: não é possível ler propriedades de indefinido (lendo 'at') quando o nome do usuário ou do dispositivo está vazio",
"nl": "Vermijd waarschuwing: Kan de eigenschappen van ongedefinieerd (lees 'at') niet lezen als de gebruikers- of apparaatnaam leeg is",
"fr": "Éviter les avertissements : impossible de lire les propriétés d'undéfini (lecture « at ») lorsque le nom de l'utilisateur ou du périphérique est vide.",
"it": "Evita avvertimenti: impossibile leggere le proprietà di unfine (leggendo 'at') quando il nome utente o dispositivo è vuoto",
"es": "Evite la advertencia: no se pueden leer las propiedades de indefinido (se lee 'en') cuando el nombre de usuario o dispositivo está vacío",
"pl": "Unikaj ostrzeżenia: nie można odczytać właściwości niezdefiniowanych (odczyt „at”), gdy nazwa użytkownika lub urządzenia jest pusta",
"uk": "Уникайте попередження: неможливо прочитати властивості undefined (читання 'at'), якщо ім'я користувача або пристрою порожнє",
"zh-cn": "避免警告:当用户名或设备名为空时,无法读取未定义的属性(读取“at”)"
},
"1.5.10": {
"en": "Adapter doesn't crash anymore when user or device name is missing in config.",
"de": "Der Adapter stürzt nicht mehr ab, wenn der Benutzer- oder Gerätename in der Konfiguration fehlt.",
Expand Down
10 changes: 5 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,19 +387,19 @@ class Wireguard extends utils.Adapter {
wg[iFace].peers[peer].persistentKeepalive = data[i][8];
if (wg[iFace].peers[peer].connected) connectedPeers.push(peer);
if (wg[iFace].peers[peer].connected) {
if (!connectedUsers.includes(wg[iFace].peers[peer].user)) connectedUsers.push(wg[iFace].peers[peer].user);
if (!connectedUsers.includes(user)) connectedUsers.push(user);
}
// build users perspective
if (user !== '' && user.at(-1) !== '.') {
if (user && (user !== '') && (user.at(-1) !== '.') ) {
// there is a username
if ( Object.prototype.hasOwnProperty.call(wg[iFace].users, wg[iFace].peers[peer].user) ){
if ( Object.prototype.hasOwnProperty.call(wg[iFace].users, user) ){
// there is already a connected state
wg[iFace].users[user].connected = ( wg[iFace].users[wg[iFace].peers[peer].user].connected || wg[iFace].peers[peer].connected );
wg[iFace].users[user].connected = ( wg[iFace].users[user].connected || wg[iFace].peers[peer].connected );
} else {
// create new connected state
wg[iFace].users[user] = {'connected' : wg[iFace].peers[peer].connected};
}
if (device !== '' && device.at(-1) !== '.') {
if (device && (device !== '') && (device.at(-1) !== '.') ) {
wg[iFace].users[user][device] = wg[iFace].peers[peer].connected ;
} else {
adapter.log.debug(`There is no device defined for public key: [${peer}] - or it's name is ending in a dot. Skipped creating user object.`);
Expand Down

0 comments on commit a749b02

Please sign in to comment.