Commit 49eb98a2 authored by nanahira's avatar nanahira

Merge branch 'master' of git.mycard.moe:mycard/utility

parents d8e31187 56b745dc
/dnsmasq-china-list /dnsmasq-china-list
/templates/smartdns/smartdns.conf.j2 /files/smartdns/china-list.conf
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
utility_root: ~/utility utility_root: ~/utility
apt_cacher_path: ./apt-cacher-ng/cache apt_cacher_path: ./apt-cacher-ng/cache
apt_mirror: mirrors.tuna.tsinghua.edu.cn apt_mirror: mirrors.tuna.tsinghua.edu.cn
smartdns_image: yousiki/smartdns:x86_64 smartdns_image: git-registry.mycard.moe/nanahira/docker-smartdns:latest
web_port_occupied: false web_port_occupied: false
# array of addresses # array of addresses
smartdns_address: null smartdns_address: null
...@@ -12,10 +12,12 @@ smartdns_ports: ...@@ -12,10 +12,12 @@ smartdns_ports:
- 54 - 54
- 55 - 55
smartdns_disable_ipv6: false smartdns_disable_ipv6: false
smartdns_cache_path: ./smartdns-cache
kms_address: null kms_address: null
squid_address: null squid_address: null
apt_cacher_address: null apt_cacher_address: null
sniproxy_address: null sniproxy_address: null
ntp_address: null
smartdns_china_dns: smartdns_china_dns:
- 114.114.114.114 - 114.114.114.114
- 223.5.5.5 - 223.5.5.5
......
...@@ -4,6 +4,8 @@ git fetch origin master ...@@ -4,6 +4,8 @@ git fetch origin master
git reset --hard FETCH_HEAD git reset --hard FETCH_HEAD
make smartdns make smartdns
cd .. cd ..
cp -rf ./templates/smartdns/header.conf.j2 ./templates/smartdns/smartdns.conf.j2 rm -rf ./files/smartdns/china-list.conf
sed 's/114.114.114.114/china/g' ./dnsmasq-china-list/*.smartdns.conf >> ./templates/smartdns/smartdns.conf.j2 sed 's/114.114.114.114/china/g' ./dnsmasq-china-list/*.smartdns.conf >> ./files/smartdns/china-list.conf
grep -P '^bogus-nxdomain=.+$' dnsmasq-china-list/bogus-nxdomain.china.conf | sed 's/=/ /g' >> ./templates/smartdns/smartdns.conf.j2 grep -P '^bogus-nxdomain=.+$' dnsmasq-china-list/bogus-nxdomain.china.conf | sed 's/=/ /g' >> ./files/smartdns/china-list.conf
# wget -O ./files/smartdns/anti-ad.conf https://anti-ad.net/anti-ad-for-smartdns.conf
echo '' > ./files/smartdns/anti-ad.conf
...@@ -18,13 +18,20 @@ ...@@ -18,13 +18,20 @@
state: directory state: directory
with_items: with_items:
- smartdns - smartdns
- apt-cacher-ng-docker
- sni - sni
- name: smartdns - name: smartdns
template: template:
src: smartdns/smartdns.conf.j2 src: smartdns/smartdns.conf.j2
dest: '{{utility_root}}/smartdns/smartdns.conf' dest: '{{utility_root}}/smartdns/smartdns.conf'
notify: restart_smartdns notify: restart_smartdns
- name: smartdns related files
copy:
src: smartdns/{{item}}.conf
dest: '{{utility_root}}/smartdns/{{item}}.conf'
notify: restart_smartdns
with_items:
- china-list
- anti-ad
- name: sni - name: sni
synchronize: synchronize:
src: ./sni/ src: ./sni/
...@@ -35,14 +42,12 @@ ...@@ -35,14 +42,12 @@
checksum: yes checksum: yes
archive: no archive: no
notify: restart_sni notify: restart_sni
- name: apt cacher Dockerfile - name: apt cacher Dockerfile clean
template: file:
src: ./apt-cacher-ng-docker/Dockerfile.j2 path: '{{utility_root}}/apt-cacher-ng-docker'
dest: '{{utility_root}}/apt-cacher-ng-docker/Dockerfile' state: absent
register: dockerfile_res
- name: docker-compose up -d - name: docker-compose up -d
docker_compose: docker_compose:
project_src: '{{utility_root}}' project_src: '{{utility_root}}'
remove_orphans: true remove_orphans: true
pull: false pull: true
build: '{{dockerfile_res.changed}}'
FROM debian:buster-slim
{% if apt_mirror != 'deb.debian.org' %}
RUN sed -i 's/deb.debian.org/{{apt_mirror}}/g;s/security.debian.org/{{apt_mirror}}/g' /etc/apt/sources.list
{% endif %}
RUN apt update && apt install -y apt-cacher-ng && rm -rf /var/lib/apt/lists/*
RUN sed -i 's/# ForeGround: 0/ForeGround: 1/' /etc/apt-cacher-ng/acng.conf && \
sed -i 's/Remap-debrep: .*/Remap-debrep: \/debian ; http:\/\/{{apt_mirror}}\/debian/' /etc/apt-cacher-ng/acng.conf && \
sed -i 's/Remap-uburep: .*/Remap-uburep: \/ubuntu ; http:\/\/{{apt_mirror}}\/ubuntu/' /etc/apt-cacher-ng/acng.conf && \
sed -i 's/Remap-secdeb: .*/Remap-debdeb: \/debian-security ; http:\/\/{{apt_mirror}}\/debian-security/' /etc/apt-cacher-ng/acng.conf
RUN ln -s /dev/stdout /var/log/apt-cacher-ng/apt-cacher.log && ln -s /dev/stderr /var/log/apt-cacher-ng.err
EXPOSE 3142/tcp
CMD [ "/usr/sbin/apt-cacher-ng", "-c", "/etc/apt-cacher-ng" ]
...@@ -19,7 +19,8 @@ services: ...@@ -19,7 +19,8 @@ services:
{% endif %} {% endif %}
command: -f -x -c /etc/smartdns/smartdns.conf command: -f -x -c /etc/smartdns/smartdns.conf
volumes: volumes:
- ./smartdns/smartdns.conf:/etc/smartdns/smartdns.conf:ro - ./smartdns:/etc/smartdns:ro
- {{smartdns_cache_path}}:/tmp/smartdns-cache
kms: kms:
restart: always restart: always
...@@ -51,18 +52,20 @@ services: ...@@ -51,18 +52,20 @@ services:
apt-cacher-ng: apt-cacher-ng:
restart: always restart: always
build: apt-cacher-ng-docker image: git-registry.mycard.moe/nanahira/apt-cacher-ng-docker:latest
dns: {{ smartdns_china_dns[0] }} dns: {{ smartdns_china_dns[0] }}
ports: ports:
{% if apt_cacher_address %} {% if apt_cacher_address %}
{% for address in apt_cacher_address %} {% for address in apt_cacher_address %}
- '{{address}}:80:3142' - '{{address}}:80:80'
{% endfor %} {% endfor %}
{% else %} {% else %}
- '80:3142' - '80:80'
{% endif %} {% endif %}
volumes: volumes:
- {{apt_cacher_path}}:/var/cache/apt-cacher-ng - {{apt_cacher_path}}:/var/cache/apt-cacher-ng
environment:
UPSTREAM_MIRROR: {{apt_mirror}}
sni: sni:
restart: always restart: always
...@@ -78,3 +81,20 @@ services: ...@@ -78,3 +81,20 @@ services:
volumes: volumes:
- ./sni/nginx.conf:/etc/nginx/nginx.conf - ./sni/nginx.conf:/etc/nginx/nginx.conf
{% endif %} {% endif %}
ntp:
restart: always
image: cturra/ntp
environment:
NTP_SERVERS: ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com
cap_add:
- SYS_TIME
ports:
{% if ntp_address %}
{% for address in ntp_address %}
- '{{address}}:123:123/udp'
{% endfor %}
{% else %}
- '123:123/udp'
{% endif %}
server-name mycard-smartdns
bind-tcp [::]:53 bind-tcp [::]:53
bind [::]:53 bind [::]:53
tcp-idle-time 3 tcp-idle-time 3
cache-size 4096 cache-size 4096
cache-persist yes
cache-file /tmp/smartdns-cache/cache
prefetch-domain yes prefetch-domain yes
dualstack-ip-selection yes
serve-expired yes serve-expired yes
serve-expired-ttl 0 serve-expired-ttl 0
...@@ -38,4 +41,7 @@ server {{dns}} -group china -exclude-default-group ...@@ -38,4 +41,7 @@ server {{dns}} -group china -exclude-default-group
nameserver /{{domain}}/china nameserver /{{domain}}/china
{% endfor %} {% endfor %}
# dnsmasq-china-list below # anti ad
conf-file /etc/smartdns/anti-ad.conf
# china list
conf-file /etc/smartdns/china-list.conf
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment