Skip to content

Commit

Permalink
Initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blu3mania committed Jul 18, 2022
1 parent fda6221 commit b1f5274
Show file tree
Hide file tree
Showing 24 changed files with 1,092 additions and 14 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
types: [ opened, synchronize ]
branches: [ main ]
schedule:
- cron: '29 1 12 * *'

jobs:
analyze:
name: Analyze
runs-on: windows-latest

strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: javascript

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
package-lock.json
yarn.lock
/src/daemon/
45 changes: 45 additions & 0 deletions .yarnclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# test directories
__tests__
test
tests
powered-test

# asset directories
docs
doc
website
images
assets

# examples
example
examples

# code coverage directories
coverage
.nyc_output

# build scripts
Makefile
Gulpfile.js
Gruntfile.js

# configs
appveyor.yml
circle.yml
codeship-services.yml
codeship-steps.yml
wercker.yml
.tern-project
.gitattributes
.editorconfig
.*ignore
.eslintrc
.jshintrc
.flowconfig
.documentup.json
.yarn-metadata.json
.travis.yml

# misc
*.md
79 changes: 79 additions & 0 deletions DNS-Providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# DNS Provider Instructions

## [Dynu](https://www.dynu.com/)

To obtain your access key and domain ID:
1. Go to https://www.dynu.com/en-US/ControlPanel/APICredentials.
2. In "API Credentials" section, click "View" icon in Action column for API Key.
3. The key is now displayed. Use it as accessKey in settings.json.
4. In a command window, run 'curl https://api.dynu.com/v2/dns -H "API-Key:ACCESSKEY"'. If not already
installed, curl can be downloaded from https://curl.se/windows/.
5. The returned string is in JSON format. Under "domains", each domain entry comes with id, name, along with
other properties. Find the id value for the domain name you want to update.
6. Use this id as domainID in settings.json.

API to update IP address:

POST https://api.dynu.com/v2/dns/{DOMAINID}

Header: "API-Key: {ACCESSKEY}"

Body: { "name": "{DOMAINNAME}"[, "ipv4Address": "ddd.ddd.ddd.ddd"][, "ipv6Address": "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx"] }

## [FreeDNS](https://freedns.afraid.org/)

To enable programmically updating DNS entry and obtain your access key:
1. Go to https://freedns.afraid.org/dynamic/v2/.
2. Select the domain(s) you want to enable.
3. Make sure you select "Enable Dynamic DNS..." in Action dropdown list.
4. Click "Apply" button.
5. These domains should now appear under "Active dynamic entries" section.
6. For the domain you want to update, grab the API key in the URL shown in the last column. It is the last
segment in the URL displayed, i.e. http://sync.afraid.org/u/{ACCESSKEY}/.
7. Use this key as accessKey in settings.json.
8. domainID in settings.json is not needed. FreeDNS assigns unique API key per domain.

API to update IP address:

GET http://[v6.]sync.afraid.org/u/{ACCESSKEY}/?ip=[ddd.ddd.ddd.ddd][xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]

## [DuckDNS](https://www.duckdns.org/)

To obtain your access key and domain ID:
1. Go to https://www.duckdns.org/
2. "token" displayed on this page (near the top) is the API token. Use it as accessKey in settings.json.
3. Domains are listed below. The first column is domain ID. It is essentially the subdomain name in
DOMAINID.duckdns.org.
4. Use this id as domainID in settings.json.

API to update IP address:

GET https://www.duckdns.org/update?domains={DOMAINID}&token={ACCESSKEY}[&ip=ddd.ddd.ddd.ddd][&ipv6=xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]

## [YDNS](https://ydns.io/)

To obtain your access key:
1. Your access key is either your account username:password, or API username:password which can be found here:
https://ydns.io/user/api.

For example, if your email is "[email protected]" and password is "MySuperSecretPwd" then use
"[email protected]:MySuperSecretPwd" as accessKey in settings.json.
2. domainID in settings.json is not needed. YDNS uses domain name to update.

API to update IP address:

GET https://ydns.io/api/v1/update/?host={DOMAINNAME}&ip=[ddd.ddd.ddd.ddd][xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]

Header: "Authorization: Basic {base64-encoded ACCESSKEY}"

## [No-IP](https://www.noip.com/)

To obtain your access key:
1. Your access key is username:password. See [YDNS](#ydns-httpsydnsio) section for example.
2. domainID in settings.json is not needed. NoIP uses domain name to update.

API to update IP address:

GET https://dynupdate.no-ip.com/nic/update?hostname={DOMAINNAME}[&myip==ddd.ddd.ddd.ddd][&myipv6=xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]

Header: "Authorization: Basic {base64-encoded ACCESSKEY}"
17 changes: 3 additions & 14 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
https://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

Expand Down Expand Up @@ -175,24 +175,13 @@

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2021 blu3mania.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Update-Dynamic-DNS-with-VPN
![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-yellow)
![node.js 10+](https://img.shields.io/badge/node.js-10.16.3-blue?logo=node.js)
![Latest Release](https://img.shields.io/github/v/release/blu3mania/update-dynamic-dns-with-vpn)

Auto update a dynamic DNS registration based on a given network interface, such as VPN. **Note**, it does
not update dynamic DNS with your public IP. If that's what you are looking for, there are already many other
apps doing just that.

It can be run as a standalone application or as a Windows service. When running in standalone mode, it can
also be used to just monitor a network interface without auto DNS update.

## Run these steps first:

1. One of the packages, "ffi-napi", uses native modules and relies on "node-gyp" to build the project. As a
result, there are some prerequisites that need to be installed/configured. Please refer to [node-gyp's
instructions](https://github.com/nodejs/node-gyp#installation).
2. Run "npm run show \[addessFamily\]" or "node src/show-interfaces.js \[addessFamily\]".

addessFamily is optional, which can be "ipv4" or "ipv6" if you only care about one type of IP address.
Shortened forms of parameter are accepted as well, which are "4", "6", "v4", "v6".

Find the network interface you want to monitor, and note down the key to that interface, e.g. "Local Area
Connection", "Wi-Fi".
3. Edit src/settings.json.
* networkInterface is the network interface you wrote down in the previous step.
* addressFamily is the IP address family to monitor and register on dynamic DNS.

Valid values are "IPv4" and "IPv6".
* dnsProvider is the provider of your domain.

Supported values are: "Dynu", "FreeDNS", "DuckDNS", "YDNS", "NoIP".

**Note**, if only using the script to monitor a network interface, leave this setting empty.
* domainName is the domain name to be updated on that provider.
* domainID is the ID assigned to the given domain by that provider.

Not all providers support this. Some of them map access key to individual domains or simply use domain
name as id.
* accessKey is the access key or token assigned by the DNS provider that can be used to update your domain.

How to obtain this info is provider specific. Please refer to [DNS Provider Instructions](DNS-Providers.md).
* showNotification allows showing Windows notification when an action is taken, such as domain is updated
in provider, or domain update is queued (due to update interval).

**Note**, this only works when running in standalone mode instead of as a Windows service.
* notificationTypes is an array of string values that defines what types of notification should be shown.

Supported values are: "DNS Registration", "Scheduled DNS Registration", "IP Changed", "IP Assigned", "IP
Removed".
4. Run "npm install". Accept UAC prompts if any (there could be up to 4). "npm link" can be used as well,
which will create a command "showip" that can be used as a shortcut to "src/show-interfaces.js".

**Note**, this step installs the script as a Windows service. If it's not desired, run "npm run uninstall"
afterwards.

## To run the script manually:

Run "npm start" or "node src/app.js".

## To install and run the script as a Windows service:

Run "npm run install" or "node src/install-service.js". Accept UAC prompts if any (there could be up to 4).

**Note**, if settings.json is updated when service is running, restart it in Windows Services control panel.

## To uninstall the Windows service:

Run "npm run uninstall" or "node src/uninstall-service.js". Accept UAC prompts if any (there could be up to 4).
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "update-dynamic-dns-with-vpn",
"version": "1.0.0",
"description": "Automatically update a dynamic DNS registration based on a given network interface, such as VPN",
"main": "src/app.js",
"scripts": {
"start": "node src/app.js",
"install": "node src/install-service.js",
"uninstall": "node src/uninstall-service.js",
"show": "node src/show-interfaces.js"
},
"bin": {
"showip": "src/show-interfaces.js"
},
"keywords": [
"dynamic",
"dns",
"dynamic-dns",
"network-interface",
"vpn"
],
"author": "blu3mania <[email protected]>",
"license": "Apache-2.0",
"homepage": "https://github.com/blu3mania/update-dynamic-dns-with-vpn#readme",
"bugs": {
"url": "https://github.com/blu3mania/update-dynamic-dns-with-vpn/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/blu3mania/update-dynamic-dns-with-vpn.git"
},
"os": [
"win32"
],
"dependencies": {
"chalk": "^4.1.0",
"ffi-napi": "^3.1.0",
"node-notifier": "^9.0.0",
"node-windows": "^1.0.0-beta.5"
},
"devDependencies": {},
"resolutions": {
"**/minimist": "^1.2.5"
}
}
Loading

0 comments on commit b1f5274

Please sign in to comment.