Skip to content

Commit

Permalink
adding github actions (#58)
Browse files Browse the repository at this point in the history
* adding github actions

* tests

* more fixes

* more fixes

* more tweaks
  • Loading branch information
ekristen authored Jun 7, 2021
1 parent 448b97e commit 4a90244
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 52 deletions.
50 changes: 50 additions & 0 deletions .github/auto-release.yml
Original file line number Diff line number Diff line change
@@ -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: |
<details>
<summary>$TITLE @$AUTHOR (#$NUMBER)</summary>
$BODY
</details>
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: ""
File renamed without changes.
38 changes: 38 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -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/*
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"javascript.format.insertSpaceBeforeFunctionParenthesis": true
}
20 changes: 10 additions & 10 deletions dns-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(',')

Expand All @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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')
Expand Down
40 changes: 16 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"pkg": "4.4.8",
"standard": "14.3.3"
}
}
}
18 changes: 9 additions & 9 deletions util.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 4a90244

Please sign in to comment.