forked from mokeyish/smartdns-rs
-
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.
Added docker and pihole converter configuration. (mokeyish#144)
- Loading branch information
1 parent
4679faf
commit b3850c5
Showing
6 changed files
with
100 additions
and
0 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 |
---|---|---|
|
@@ -17,3 +17,5 @@ Cargo.lock | |
# web ui | ||
node_modules | ||
dist | ||
|
||
.idea/ |
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,3 @@ | ||
smartdns.conf | ||
pihole.txt | ||
smartdns-ads.txt |
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,44 @@ | ||
ARG VERSION=0.6.1 | ||
|
||
FROM debian:stable as downloader | ||
|
||
ARG VERSION | ||
|
||
RUN apt-get update && apt-get install -y curl | ||
RUN mkdir -p /app/x86 /app/arm64 /app/armv7 /app/extracted/x86 /app/extracted/arm64 /app/extracted/armv7 | ||
|
||
|
||
RUN curl -L https://github.com/mokeyish/smartdns-rs/releases/download/$VERSION/smartdns-x86_64-unknown-linux-musl.tar.gz -o /app/x86/smartdns.tar.gz | ||
RUN ls -lisa /app/x86 | ||
RUN tar -xvf /app/x86/smartdns.tar.gz -C /app/extracted/x86 | ||
|
||
RUN curl -L https://github.com/mokeyish/smartdns-rs/releases/download/$VERSION/smartdns-aarch64-unknown-linux-musl.tar.gz -o /app/arm64/smartdns.tar.gz | ||
|
||
RUN tar -xvf /app/arm64/smartdns.tar.gz -C /app/extracted/arm64 | ||
RUN curl -L https://github.com/mokeyish/smartdns-rs/releases/download/$VERSION/smartdns-arm-unknown-linux-musleabihf.tar.gz -o /app/armv7/smartdns.tar.gz | ||
|
||
RUN tar -xvf /app/armv7/smartdns.tar.gz -C /app/extracted/armv7 | ||
|
||
FROM alpine as base | ||
|
||
WORKDIR /app | ||
RUN apk add bash | ||
COPY docker-entrypoint.sh /app/entrypoint.sh | ||
FROM base as amd64 | ||
|
||
COPY --from=downloader /app/extracted/x86/* /app/ | ||
|
||
FROM base as armv7 | ||
|
||
COPY --from=downloader /app/extracted/armv7/* /app/ | ||
|
||
FROM base as arm64 | ||
|
||
COPY --from=downloader /app/extracted/arm64/* /app/ | ||
|
||
|
||
FROM ${TARGETARCH}${TARGETVARIANT} as final | ||
|
||
|
||
EXPOSE 8000 | ||
CMD ["bash", "/app/entrypoint.sh"] |
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,14 @@ | ||
version: "3" | ||
services: | ||
dns: | ||
image: smartdns-rs | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
ports: | ||
- "53:53" | ||
- "53:53/udp" | ||
volumes: | ||
- ./smartdns.conf:/app/smartdns.conf | ||
#environment: | ||
#- PARAMS= # Pass additional flags to the smartdns binary |
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,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ ! -f /app/smartdns.conf ]]; then | ||
echo "File /app/smartdns.conf is empty. It must be set in order to get started You can find additional information | ||
here:" | ||
echo "https://pymumu.github.io/smartdns/en/config/basic-config/" | ||
exit 1 | ||
fi | ||
|
||
# Init with default parameter | ||
if [[ -z "${PARAMS}" ]];then | ||
PARAMS="run -c /app/smartdns.conf" | ||
fi | ||
/app/smartdns $PARAMS |
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,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Converts a pihole adlist like https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts to | ||
# a smartdns compatible format. Download the respective adlist and save it as pihole.txt in the same folder as this script. | ||
# Run this script and copy the content of the generated smartdns-ads.txt to your smartdns.conf file. | ||
|
||
output='' | ||
block_prefix="address /" | ||
block_suffix="/0.0.0.0" | ||
|
||
while read p; do | ||
|
||
trimmed_output=$(echo $p| sed 's/^[ \t]*//;s/[ \t]*$//') | ||
# If line is not a comment and not empty | ||
if [[ $p != \#* && ! -z $trimmed_output ]] ; then | ||
output+=$block_prefix$(echo $trimmed_output | cut -d ' ' -f 2)$block_suffix | ||
else | ||
output+=$(echo $trimmed_output) | ||
fi | ||
output+='\n' | ||
done <pihole.txt | ||
|
||
echo -e $output > smartdns-ads.txt |