From 4a902440b18ee93c04e06b9b33822edec348c3c7 Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 7 Jun 2021 13:14:14 -0600 Subject: [PATCH] adding github actions (#58) * adding github actions * tests * more fixes * more fixes * more tweaks --- .github/auto-release.yml | 50 ++++++++++++++++++++++++++ renovate.json => .github/renovate.json | 0 .github/workflows/auto-release.yml | 38 ++++++++++++++++++++ .github/workflows/tests.yml | 24 +++++++++++++ .travis.yml | 8 ----- .vscode/settings.json | 3 ++ dns-proxy.js | 20 +++++------ package-lock.json | 40 +++++++++------------ package.json | 2 +- util.js | 18 +++++----- 10 files changed, 151 insertions(+), 52 deletions(-) create mode 100644 .github/auto-release.yml rename renovate.json => .github/renovate.json (100%) create mode 100644 .github/workflows/auto-release.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml create mode 100644 .vscode/settings.json diff --git a/.github/auto-release.yml b/.github/auto-release.yml new file mode 100644 index 0000000..d0ee597 --- /dev/null +++ b/.github/auto-release.yml @@ -0,0 +1,50 @@ +name-template: "v$RESOLVED_VERSION" +tag-template: "$RESOLVED_VERSION" +version-template: "$MAJOR.$MINOR.$PATCH" +version-resolver: + major: + labels: + - "major" + minor: + labels: + - "minor" + - "enhancement" + patch: + labels: + - "auto-update" + - "patch" + - "fix" + - "bugfix" + - "bug" + - "hotfix" + default: "patch" + +categories: + - title: "🚀 Enhancements" + labels: + - "enhancement" + - "patch" + - title: "🐛 Bug Fixes" + labels: + - "fix" + - "bugfix" + - "bug" + - "hotfix" + - title: "🤖 Automatic Updates" + labels: + - "auto-update" + +change-template: | +
+ $TITLE @$AUTHOR (#$NUMBER) + $BODY +
+template: | + $CHANGES +replacers: + # Remove irrelevant information from Renovate bot + - search: '/---\s+^#.*Renovate configuration(?:.|\n)*?This PR has been generated .*/gm' + replace: "" + # Remove Renovate bot banner image + - search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm' + replace: "" diff --git a/renovate.json b/.github/renovate.json similarity index 100% rename from renovate.json rename to .github/renovate.json diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..d94ada0 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,38 @@ +name: auto-release + +on: + push: + branches: + - master + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + with: + publish: true + prerelease: false + config-name: auto-release.yml + outputs: + upload_url: ${{ steps.publish.outputs.upload_url }} + + build: + runs-on: ubuntu-latest + needs: + - publish + strategy: + matrix: + node-version: [10.x, 12.x, 14.x, 15.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm pkg + - uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: release/* diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d3d6a84 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,24 @@ +name: tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [10.x, 12.x, 14.x, 15.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a6c7fa0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: node_js - -sudo: false - -node_js: - - 4 - - 5 - - 6 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..63d36ac --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "javascript.format.insertSpaceBeforeFunctionParenthesis": true +} \ No newline at end of file diff --git a/dns-proxy.js b/dns-proxy.js index bf030c2..ea62364 100755 --- a/dns-proxy.js +++ b/dns-proxy.js @@ -18,10 +18,10 @@ const defaults = { ], servers: {}, domains: { - 'xdev': '127.0.0.1' + xdev: '127.0.0.1' }, hosts: { - 'devlocal': '127.0.0.1' + devlocal: '127.0.0.1' }, fallback_timeout: 350, reload_config: true @@ -31,7 +31,7 @@ let config = rc('dnsproxy', defaults) process.env.DEBUG_FD = process.env.DEBUG_FD || 1 process.env.DEBUG = process.env.DEBUG || config.logging -let d = process.env.DEBUG.split(',') +const d = process.env.DEBUG.split(',') d.push('dnsproxy:error') process.env.DEBUG = d.join(',') @@ -40,7 +40,7 @@ const logdebug = require('debug')('dnsproxy:debug') const logquery = require('debug')('dnsproxy:query') const logerror = require('debug')('dnsproxy:error') -if (config.reload_config === true) { +if (config.reload_config === true && typeof config.config !== 'undefined') { var configFile = config.config fs.watchFile(configFile, function (curr, prev) { loginfo('config file changed, reloading config options') @@ -85,7 +85,7 @@ server.on('message', function (message, rinfo) { logquery('type: host, domain: %s, answer: %s, source: %s:%s, size: %d', domain, config.hosts[h], rinfo.address, rinfo.port, rinfo.size) - let res = util.createAnswer(query, answer) + const res = util.createAnswer(query, answer) server.send(res, 0, res.length, rinfo.port, rinfo.address) returner = true @@ -97,8 +97,8 @@ server.on('message', function (message, rinfo) { } Object.keys(config.domains).forEach(function (s) { - let sLen = s.length - let dLen = domain.length + const sLen = s.length + const dLen = domain.length if ((domain.indexOf(s) >= 0 && domain.indexOf(s) === (dLen - sLen)) || wildcard(domain, s)) { let answer = config.domains[s] @@ -108,7 +108,7 @@ server.on('message', function (message, rinfo) { logquery('type: server, domain: %s, answer: %s, source: %s:%s, size: %d', domain, config.domains[s], rinfo.address, rinfo.port, rinfo.size) - let res = util.createAnswer(query, answer) + const res = util.createAnswer(query, answer) server.send(res, 0, res.length, rinfo.port, rinfo.address) returner = true @@ -124,9 +124,9 @@ server.on('message', function (message, rinfo) { nameserver = config.servers[s] } }) - let nameParts = nameserver.split(':') + const nameParts = nameserver.split(':') nameserver = nameParts[0] - let port = nameParts[1] || 53 + const port = nameParts[1] || 53 let fallback (function queryns (message, nameserver) { const sock = dgram.createSocket('udp4') diff --git a/package-lock.json b/package-lock.json index 57389c7..93807ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1173,9 +1173,9 @@ "dev": true }, "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, "http-signature": { @@ -1237,9 +1237,9 @@ "dev": true }, "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" }, "inquirer": { "version": "7.1.0", @@ -1549,9 +1549,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "loose-envify": { @@ -1610,25 +1610,17 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } + "minimist": "^1.2.5" } }, "ms": { diff --git a/package.json b/package.json index d5cc77e..9b7f76e 100644 --- a/package.json +++ b/package.json @@ -26,4 +26,4 @@ "pkg": "4.4.8", "standard": "14.3.3" } -} \ No newline at end of file +} diff --git a/util.js b/util.js index 8b110bc..ce8339e 100644 --- a/util.js +++ b/util.js @@ -1,18 +1,18 @@ const packet = require('native-dns-packet') module.exports.records = { - '1': 'A', - '2': 'NS', - '5': 'CNAME', - '6': 'SOA', - '12': 'PTR', - '15': 'MX', - '16': 'TXT', - '28': 'AAAA' + 1: 'A', + 2: 'NS', + 5: 'CNAME', + 6: 'SOA', + 12: 'PTR', + 15: 'MX', + 16: 'TXT', + 28: 'AAAA' } module.exports.listAnswer = function (response) { - let results = [] + const results = [] const res = packet.parse(response) res.answer.map(function (r) { results.push(r.address || r.data)