Blob Blame History Raw
# Generated by go2rpm 1.9.0
%bcond_without check

# https://github.com/jedisct1/dnscrypt-proxy
%global goipath         github.com/jedisct1/dnscrypt-proxy
Version:                2.1.1
%global tag             2.1.1

%gometa

%global common_description %{expand:
A flexible DNS proxy, with support for modern encrypted DNS protocols such as
DNSCrypt v2 and DNS-over-HTTP/2.

Features:

 - DNS traffic encryption and authentication. Supports DNS-over-HTTPS (DoH)
 and DNSCrypt.
 - DNSSEC compatible
 - DNS query monitoring, with separate log files for regular and suspicious
 queries
 - Pattern-based local blocking of DNS names and IP addresses
 - Time-based filtering, with a flexible weekly schedule
 - Transparent redirection of specific domains to specific resolvers
 - DNS caching, to reduce latency and improve privacy
 - Local IPv6 blocking to reduce latency on IPv4-only networks
 - Load balancing: pick a set of resolvers, dnscrypt-proxy will automatically
 measure and keep track of their speed, and balance the traffic across the
 fastest available ones.
 - Cloaking: like a HOSTS file on steroids, that can return preconfigured
 addresses for specific names, or resolve and return the IP address of other
 names. This can be used for local development as well as to enforce safe
 search results on Google, Yahoo and Bing.
 - Automatic background updates of resolvers lists
 - Can force outgoing connections to use TCP; useful with tunnels such as Tor.}

Name:           dnscrypt-proxy
Release:        %autorelease
Summary:        Flexible DNS proxy, with support for encrypted DNS protocols

License:        ISC
URL:            %{gourl}
Source0:        %{gosource}
Source1:        dnscrypt-proxy.service

BuildRequires: systemd-rpm-macros

# Largely inspired by Arch packaging
# https://git.archlinux.org/svntogit/community.git/tree/trunk/configuration.diff?h=packages/dnscrypt-proxy
Patch0:         dnscrypt-proxy-2.1.1-custom_config.patch

%description %{common_description}

%prep
%goprep
%autopatch -p1
rm -rfv dnscrypt-proxy/sources_test.go

%generate_buildrequires
%go_generate_buildrequires

%build
for cmd in dnscrypt-proxy; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done

%install
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -Dpm 0644 dnscrypt-proxy/example-dnscrypt-proxy.toml %{buildroot}%{_sysconfdir}/%{name}/dnscrypt-proxy.toml
install -Dpm 0644 dnscrypt-proxy/example-allowed-ips.txt %{buildroot}%{_sysconfdir}/%{name}/allowed-ips.txt
install -Dpm 0644 dnscrypt-proxy/example-allowed-names.txt  %{buildroot}%{_sysconfdir}/%{name}/allowed-names.txt
install -Dpm 0644 dnscrypt-proxy/example-blocked-ips.txt  %{buildroot}%{_sysconfdir}/%{name}/blocked-ips.txt
install -Dpm 0644 dnscrypt-proxy/example-blocked-names.txt  %{buildroot}%{_sysconfdir}/%{name}/blocked-names.txt
install -Dpm 0644 dnscrypt-proxy/example-captive-portals.txt  %{buildroot}%{_sysconfdir}/%{name}/captive-portals.txt
install -Dpm 0644 dnscrypt-proxy/example-cloaking-rules.txt  %{buildroot}%{_sysconfdir}/%{name}/cloaking-rules.txt
install -Dpm 0644 dnscrypt-proxy/example-forwarding-rules.txt  %{buildroot}%{_sysconfdir}/%{name}/forwarding-rules.txt
install -Dpm 0644 %{S:1} %{buildroot}%{_unitdir}/dnscrypt-proxy.service
install -m 0755 -vd %{buildroot}%{_localstatedir}/cache/%{name}

%post
dnscrypt-proxy -service stop
rm -rfv /etc/systemd/system/dnscrypt-proxy.service
%systemd_post dnscrypt-proxy.service

%preun
dnscrypt-proxy -service stop
rm -rfv /etc/systemd/system/dnscrypt-proxy.service
%systemd_preun dnscrypt-proxy.service

%postun
dnscrypt-proxy -service stop
rm -rfv /etc/systemd/system/dnscrypt-proxy.service
%systemd_postun_with_restart dnscrypt-proxy.service

%posttrans
dnscrypt-proxy -service stop
rm -rfv /etc/systemd/system/dnscrypt-proxy.service

%files
%license LICENSE
%doc README.md ChangeLog
%doc utils/generate-domains-blocklist/
%{_bindir}/%{name}
%dir %{_sysconfdir}/%{name}/
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.toml
%config(noreplace) %{_sysconfdir}/%{name}/*.txt
%config(noreplace) %{_unitdir}/dnscrypt-proxy.service
%ghost %config(noreplace) %{_sysconfdir}/%{name}/blacklist.txt
%ghost %config(noreplace) %{_sysconfdir}/%{name}/whitelist.txt
%ghost %{_sysconfdir}/systemd/system/dnscrypt-proxy.service
%ghost %{_localstatedir}/cache/%{name}

%changelog
%autochangelog