-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement base code structure (#5)
- Loading branch information
Showing
32 changed files
with
2,634 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# Unbound Configuration Path | ||
# Select one of the following options: | ||
# - unix: Unix Domain Socket | ||
# - tls: TLS Socket | ||
UNBOUND_CONF_PATH=./unbound-config/unix | ||
# UNBOUND_CONF_PATH=./unbound-config/tls | ||
# default: ./unbound-config/unix | ||
# UNBOUND_CONF_PATH=./unbound-config/unix | ||
# UNBOUND_CONF_PATH=./unbound-config/tls | ||
|
||
# Unbound Version | ||
# default: latest | ||
# UNBOUND_VERSION=latest | ||
|
||
# Unbound DNS, Control Port | ||
# UNBOUND_DNS_PORT=53 | ||
# UNBOUND_CONTROL_PORT=8953 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Unbound Configuration Path | ||
# default: ./unbound-config/unix | ||
# UNBOUND_CONF_PATH=./unbound-config/unix | ||
# UNBOUND_CONF_PATH=./unbound-config/tls | ||
|
||
# Unbound Version | ||
# default: latest | ||
# UNBOUND_VERSION=latest | ||
|
||
# Unbound DNS, Control Port | ||
# UNBOUND_DNS_PORT=53 | ||
# UNBOUND_CONTROL_PORT=8953 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# TODO: Fix Unix domain socket permissions | ||
|
||
# name: Test Unbound with Multiple Versions | ||
|
||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
# pull_request: | ||
# branches: | ||
# - main | ||
|
||
# jobs: | ||
# test-unbound: | ||
# runs-on: ubuntu-latest | ||
|
||
# strategy: | ||
# matrix: | ||
# include: | ||
# # TODO: Multiple versions of Unbound can be tested by adding more versions here. | ||
# # - fix: unbound.conf, test file's socket path | ||
# # - unbound-version: 1.18.0 | ||
# # unbound-port: 5318 | ||
# # unbound-control-port: 8918 | ||
# # - unbound-version: 1.19.3 | ||
# # unbound-port: 5319 | ||
# # unbound-control-port: 8919 | ||
# # - unbound-version: 1.20.0 | ||
# # unbound-port: 5320 | ||
# # unbound-control-port: 8920 | ||
# # - unbound-version: 1.21.1 | ||
# # unbound-port: 5321 | ||
# # unbound-control-port: 8921 | ||
# - unbound-version: 1.22.0 | ||
# unbound-port: 5322 | ||
# unbound-control-port: 8922 | ||
|
||
# steps: | ||
# - uses: actions/checkout@v4 | ||
|
||
# - name: Set up Docker Compose | ||
# run: sudo apt-get update && sudo apt-get install -y docker-compose | ||
|
||
# - name: Start Unbound containers | ||
# run: | | ||
# UNBOUND_VERSION=${{ matrix.unbound-version }} \ | ||
# UNBOUND_DNS_PORT=${{ matrix.unbound-port }} \ | ||
# UNBOUND_CONTROL_PORT=${{ matrix.unbound-control-port }} \ | ||
# docker-compose up -d | ||
# - name: Verify Unbound is running | ||
# run: docker ps | ||
|
||
# - name: Wait for Unbound to become healthy | ||
# run: | | ||
# echo "Waiting for Unbound to be ready..." | ||
# for i in {1..30}; do | ||
# HEALTH=$(docker inspect --format='{{.State.Health.Status}}' unbound-${{ matrix.unbound-version }}) | ||
# if [ "$HEALTH" == "healthy" ]; then | ||
# echo "Unbound is healthy!" | ||
# break | ||
# fi | ||
# echo "Unbound is not ready yet. Waiting..." | ||
# sleep 2 | ||
# done | ||
# if [ "$HEALTH" != "healthy" ]; then | ||
# echo "Unbound did not become healthy in time." | ||
# exit 1 | ||
# fi | ||
|
||
# - name: Fix permissions inside container | ||
# run: | | ||
# docker exec unbound-${{ matrix.unbound-version }} chmod 777 /opt/unbound/etc/unbound/socket/unbound.ctl | ||
|
||
# - name: Set permissions for Unix socket | ||
# run: ls -Rl "$GITHUB_WORKSPACE/unbound-config" | ||
|
||
# - name: Test Unbound | ||
# run: | | ||
# dig @localhost -p ${{ matrix.unbound-port }} example.com | ||
|
||
# - name: Use Node.js 22.x | ||
# uses: actions/setup-node@v4 | ||
# with: | ||
# node-version: 22.x | ||
|
||
# - name: Install dependencies | ||
# run: npm ci | ||
# - run: npm run test:it | ||
|
||
# - name: Stop Unbound | ||
# run: | | ||
# docker compose stop unbound-${{ matrix.unbound-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
services: | ||
unbound-setup: | ||
image: mvance/unbound:latest | ||
volumes: | ||
- ${UNBOUND_CONF_PATH}:/opt/unbound/etc/unbound | ||
restart: "no" | ||
entrypoint: [] | ||
command: >- | ||
/bin/sh -c " | ||
if [ ! -f /opt/unbound/etc/unbound/key/unbound_server.key ]; then | ||
echo 'Setup start' && | ||
unbound-control-setup && | ||
mkdir /opt/unbound/etc/unbound/key && | ||
mv /opt/unbound/etc/unbound/unbound_* /opt/unbound/etc/unbound/key && | ||
echo 'Setup complete'; | ||
else | ||
echo 'Certificates already exist'; | ||
fi | ||
" | ||
unbound: | ||
image: mvance/unbound:latest | ||
container_name: unbound | ||
ports: | ||
- "53:53/tcp" | ||
- "53:53/udp" | ||
- "8953:8953" | ||
volumes: | ||
- ${UNBOUND_CONF_PATH}:/opt/unbound/etc/unbound | ||
restart: unless-stopped | ||
depends_on: | ||
- unbound-setup | ||
services: | ||
unbound-setup: | ||
image: mvance/unbound:${UNBOUND_VERSION:-latest} | ||
volumes: | ||
- ${UNBOUND_CONF_PATH:-./unbound-config/unix}:/opt/unbound/etc/unbound | ||
restart: "no" | ||
entrypoint: [] | ||
command: >- | ||
/bin/sh -c " | ||
if [ ! -f /opt/unbound/etc/unbound/key/unbound_server.key ]; then | ||
echo 'Setup start' && | ||
unbound-control-setup && | ||
mkdir /opt/unbound/etc/unbound/key /opt/unbound/etc/unbound/socket && | ||
mv /opt/unbound/etc/unbound/unbound_* /opt/unbound/etc/unbound/key && | ||
chown 1000 /opt/unbound/etc/unbound/key/* && | ||
echo 'Setup complete'; | ||
else | ||
echo 'Certificates already exist'; | ||
fi | ||
" | ||
unbound: | ||
image: mvance/unbound:${UNBOUND_VERSION:-latest} | ||
container_name: unbound-${UNBOUND_VERSION:-latest} | ||
ports: | ||
- "${UNBOUND_DNS_PORT:-53}:53/tcp" | ||
- "${UNBOUND_DNS_PORT:-53}:53/udp" | ||
- "${UNBOUND_CONTROL_PORT:-8953}:8953" | ||
volumes: | ||
- ${UNBOUND_CONF_PATH:-./unbound-config/unix}:/opt/unbound/etc/unbound | ||
restart: unless-stopped | ||
depends_on: | ||
- unbound-setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
const { hello } = require("../../dist/index.cjs"); | ||
const path = require("path"); | ||
const { UnboundControlClient, UnboundError } = require("../dist/index.cjs"); | ||
|
||
const result = hello(); | ||
console.log(`CJS Result: ${result}`); | ||
const baseDir = path.resolve(__dirname, ".."); | ||
|
||
const unixSocketName = path.join( | ||
baseDir, | ||
"unbound-config/unix/socket/unbound.ctl", | ||
); | ||
|
||
const client = new UnboundControlClient(unixSocketName); | ||
|
||
(async () => { | ||
try { | ||
const response = await client.status(); | ||
console.log(response.raw); | ||
console.log(response.json); | ||
} catch (error) { | ||
if (error instanceof UnboundError) { | ||
console.error(error.message); | ||
} else { | ||
console.error(error); | ||
} | ||
} | ||
})(); | ||
|
||
(async () => { | ||
try { | ||
const response = await client.status(); | ||
console.log(response.raw); | ||
console.log(response.json); | ||
} catch (error) { | ||
if (error instanceof UnboundError) { | ||
console.error(error.message); | ||
} else { | ||
console.error(error); | ||
} | ||
} | ||
})(); |
Oops, something went wrong.