File dnscrypt-proxy.spec of Package dnscrypt-proxy

#
# spec file for package dnscrypt-proxy
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%define user_group  _dnscrypt_proxy
%define config_dir  %{_sysconfdir}/%{name}
%define home_dir    /var/lib/%{name}
%define log_dir     /var/log/%{name}
%define services    dnscrypt-proxy.socket dnscrypt-proxy.service dnscrypt-proxy-resolvconf.service

Name:           dnscrypt-proxy
Version:        2.1.14
Release:        0
%define pkg_version %{version}
Summary:        A flexible DNS proxy, with support for modern encrypted DNS protocols
License:        ISC
Group:          Productivity/Networking/DNS/Utilities
Url:            https://github.com/DNSCrypt/dnscrypt-proxy
Source:         %{name}-%{pkg_version}.tar.gz
Source1:        dnscrypt-proxy-resolvconf.service
Source2:        dnscrypt-proxy.service
Source3:        dnscrypt-proxy.socket
Source4:        dnscrypt-proxy.sysusers
Source98:       series
Source99:       systemd.md
Patch:          config.patch
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.21
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
%{?go_nostrip}
%{?sysusers_requires}

%description
- DNS traffic encryption and authentication. Supports DNS-over-HTTPS (DoH)
  using TLS 1.3, DNSCrypt and Anonymized DNS
- Client IP addresses can be hidden using Tor, SOCKS proxies or Anonymized DNS
  relays
- DNS query monitoring, with separate log files for regular and suspicious
  queries
- Filtering: block ads, malware, and other unwanted content. Compatible with
  all DNS services
- 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, DuckDuckGo and Bing
- Automatic background updates of resolvers lists
- Can force outgoing connections to use TCP
- Compatible with DNSSEC

%prep
%autosetup -p1 -n %{name}-%{pkg_version}

%build
pushd dnscrypt-proxy
go build -mod=vendor -buildmode=pie
popd

perl -p -i -e 's|/usr/bin/env\s+python\d?|/usr/bin/python3|g' utils/generate-domains-blocklist/*.py
%sysusers_generate_pre %{SOURCE4} %{name} %{name}.conf

%install
install -D -d -m 0750               \
  %{buildroot}%{log_dir}            \
  %{buildroot}%{home_dir}           \
  %{buildroot}%{config_dir}

install -D -d -m 0755               \
  %{buildroot}%{_datadir}/%{name}/

install -D -m 0755 dnscrypt-proxy/dnscrypt-proxy %{buildroot}%{_sbindir}/dnscrypt-proxy

cp -a utils/generate-domains-blocklist/ %{buildroot}%{_datadir}/%{name}/

pushd dnscrypt-proxy
  for i in example* ; do
    install -m 0640 $i %{buildroot}%{config_dir}/${i//example-/}
  done
popd
pushd $RPM_SOURCE_DIR
  for i in *.service *.socket ; do
    install -D -m 0644 $i %{buildroot}%{_unitdir}/$i
  done
  for i in *.service ; do
    ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc${i%%.service}
  done
popd
install -Dpm0644 %{SOURCE4} %{buildroot}%{_sysusersdir}/%{name}.conf

%pre -f %{name}.pre
%service_add_pre %{services}

%post
%service_add_post %{services}

%preun
%service_del_preun %{services}

%postun
%service_del_postun %{services}


%files
%config(noreplace) %attr(-,root,%{user_group}) %{config_dir}/
%{_sbindir}/rcdnscrypt-proxy*
%{_sbindir}/dnscrypt-proxy
%{_unitdir}/dnscrypt-proxy.service
%{_sysusersdir}/%{name}.conf
%{_datadir}/%{name}/
%dir %attr(0750,%{user_group},%{user_group}) %{home_dir}
%dir %attr(0750,%{user_group},%{user_group}) %{log_dir}
%doc ChangeLog README.md
%license LICENSE
%{_unitdir}/dnscrypt*

%changelog
openSUSE Build Service is sponsored by