Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pymumu/smartdns
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: Release40
Choose a base ref
...
head repository: pymumu/smartdns
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing 397 changed files with 68,941 additions and 20,007 deletions.
45 changes: 45 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Checks: >
-*,
modernize-*,
bugprone-*,
concurrency-*,
misc-*,
readability-*,
performance-*,
portability-*,
google-*,
linuxkernel-*,
-bugprone-narrowing-conversions,
-bugprone-branch-clone,
-bugprone-reserved-identifier,
-bugprone-easily-swappable-parameters,
-bugprone-sizeof-expression,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-suspicious-memory-comparison,
-bugprone-not-null-terminated-result,
-bugprone-signal-handler,
-bugprone-assignment-in-if-condition,
-concurrency-mt-unsafe,
-modernize-macro-to-enum,
-misc-unused-parameters,
-misc-misplaced-widening-cast,
-misc-no-recursion,
-readability-magic-numbers,
-readability-use-anyofallof,
-readability-identifier-length,
-readability-function-cognitive-complexity,
-readability-named-parameter,
-readability-isolate-declaration,
-readability-else-after-return,
-readability-redundant-control-flow,
-readability-suspicious-call-argument,
-google-readability-casting,
-google-readability-todo,
-performance-no-int-to-ptr,
# clang-analyzer-*,
# clang-analyzer-deadcode.DeadStores,
# clang-analyzer-optin.performance.Padding,
# -clang-analyzer-security.insecureAPI.*

# Turn all the warnings from the checks above into errors.
FormatStyle: file
11 changes: 10 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -13,5 +13,14 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: prepare
run: |
sudo apt update
sudo apt install libgtest-dev dnsperf
- name: make
run: make
run: |
make all -j4
make clean
- name: test
run: |
make -C test test -j8
35 changes: 35 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Docker Image

on:
workflow_dispatch:
inputs:
version:
description: 'new image tag(e.g. v1.1.0)'
required: true
default: 'latest'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{vars.DOCKERHUB_REPO}}:${{ github.event.inputs.version }}
22 changes: 22 additions & 0 deletions .github/workflows/webui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: WebUI CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: stable
- name: test
run: |
EXTRA_CFLAGS=-fPIC make -C plugin/smartdns-ui test -j8
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.vscode
*.o
*.a
*.pem
.DS_Store
*.swp.
*.a
systemd/smartdns.service
test.bin
27 changes: 17 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
FROM ubuntu:latest as smartdns-builder
FROM ubuntu:latest AS smartdns-builder
LABEL previous-stage=smartdns-builder

# prepare builder
ARG OPENSSL_VER=1.1.1f
ARG OPENSSL_VER=3.4.1
RUN apt update && \
apt install -y perl curl make musl-tools musl-dev && \
apt install -y binutils perl curl make musl-tools musl-dev && \
ln -s /usr/include/linux /usr/include/$(uname -m)-linux-musl && \
ln -s /usr/include/asm-generic /usr/include/$(uname -m)-linux-musl && \
ln -s /usr/include/$(uname -m)-linux-gnu/asm /usr/include/$(uname -m)-linux-musl && \
\
mkdir -p /build/openssl && \
cd /build/openssl && \
curl -sSL http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_${OPENSSL_VER}.orig.tar.gz | tar --strip-components=1 -zxv && \
curl -sSL https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VER}/openssl-${OPENSSL_VER}.tar.gz | tar --strip-components=1 -zxv && \
\
OPENSSL_OPTIONS="no-argon2 no-aria no-async no-bf no-blake2 no-camellia no-cmp no-cms " \
OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-comp no-des no-dh no-dsa no-ec2m no-engine no-gost "\
OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-http no-idea no-legacy no-md4 no-mdc2 no-multiblock "\
OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-nextprotoneg no-ocb no-ocsp no-rc2 no-rc4 no-rmd160 "\
OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-scrypt no-seed no-siphash no-siv no-sm2 no-sm3 no-sm4 "\
OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-srp no-srtp no-ts no-whirlpool no-apps no-ssl-trace "\
OPENSSL_OPTIONS="$OPENSSL_OPTIONS no-ssl no-ssl3 no-tests -Os" \
export CC=musl-gcc && \
if [ "$(uname -m)" = "aarch64" ]; then \
./config --prefix=/opt/build no-tests -mno-outline-atomics ; \
./config --prefix=/opt/build $OPENSSL_OPTIONS -mno-outline-atomics ; \
else \
./config --prefix=/opt/build no-tests ; \
./config --prefix=/opt/build $OPENSSL_OPTIONS ; \
fi && \
make all -j8 && make install_sw && \
cd / && rm -rf /build
@@ -27,19 +34,19 @@ COPY . /build/smartdns/
RUN cd /build/smartdns && \
export CC=musl-gcc && \
export CFLAGS="-I /opt/build/include" && \
export LDFLAGS="-L /opt/build/lib" && \
export LDFLAGS="-L /opt/build/lib -L /opt/build/lib64" && \
sh ./package/build-pkg.sh --platform linux --arch `dpkg --print-architecture` --static && \
\
( cd package && tar -xvf *.tar.gz && chmod a+x smartdns/etc/init.d/smartdns ) && \
\
mkdir -p /release/var/log /release/var/run && \
mkdir -p /release/var/log /release/run && \
cp package/smartdns/etc /release/ -a && \
cp package/smartdns/usr /release/ -a && \
cd / && rm -rf /build

FROM busybox:latest
FROM busybox:stable-musl
COPY --from=smartdns-builder /release/ /
EXPOSE 53/udp
VOLUME "/etc/smartdns/"
VOLUME ["/etc/smartdns/"]

CMD ["/usr/sbin/smartdns", "-f", "-x"]
32 changes: 28 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2018-2020 Ruilin Peng (Nick) <pymumu@gmail.com>.
# Copyright (C) 2018-2025 Ruilin Peng (Nick) <pymumu@gmail.com>.
#
# smartdns is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,31 +17,55 @@ PKG_CONFIG := pkg-config
DESTDIR :=
PREFIX := /usr
SBINDIR := $(PREFIX)/sbin
SLIBDIR := $(PREFIX)/lib
SYSCONFDIR := /etc
RUNSTATEDIR := /var/run
RUNSTATEDIR := /run
SYSTEMDSYSTEMUNITDIR := $(shell ${PKG_CONFIG} --variable=systemdsystemunitdir systemd)
SMARTDNS_SYSTEMD = systemd/smartdns.service

.PHONY: all clean install SMARTDNS_BIN
ifneq ($(strip $(DESTDIR)),)
$(shell mkdir -p $(DESTDIR) -m 0755)
override DESTDIR := $(realpath $(DESTDIR))
endif

PLUGINS :=
WITH_UI ?= 0

ifeq ($(WITH_UI), 1)
PLUGINS += plugin/smartdns-ui
endif

define PLUGINS_TARGETS
$(foreach plugin,$(PLUGINS),$(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) -C $(plugin) $(1);)
endef

.PHONY: all clean install help SMARTDNS_BIN
all: SMARTDNS_BIN

SMARTDNS_BIN: $(SMARTDNS_SYSTEMD)
$(MAKE) $(MFLAGS) -C src all
$(MAKE) $(MFLAGS) -C src all
$(call PLUGINS_TARGETS, all)

$(SMARTDNS_SYSTEMD): systemd/smartdns.service.in
cp $< $@
sed -i 's|@SBINDIR@|$(SBINDIR)|' $@
sed -i 's|@SYSCONFDIR@|$(SYSCONFDIR)|' $@
sed -i 's|@RUNSTATEDIR@|$(RUNSTATEDIR)|' $@

help:
@echo "Options:"
@echo " WITH_UI=1: Build with smartdns-ui plugin"

clean:
$(MAKE) $(MFLAGS) -C src clean
$(RM) $(SMARTDNS_SYSTEMD)
$(call PLUGINS_TARGETS, clean)

install: SMARTDNS_BIN
install -v -m 0640 -D -t $(DESTDIR)$(SYSCONFDIR)/default etc/default/smartdns
install -v -m 0755 -D -t $(DESTDIR)$(SYSCONFDIR)/init.d etc/init.d/smartdns
install -v -m 0640 -D -t $(DESTDIR)$(SYSCONFDIR)/smartdns etc/smartdns/smartdns.conf
install -v -m 0755 -D -t $(DESTDIR)$(SBINDIR) src/smartdns
install -v -m 0644 -D -t $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) systemd/smartdns.service
$(call PLUGINS_TARGETS, install)

Loading