#
# spec file for package dnscrypt-proxy
#
# Copyright (c) 2015 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/
#


Name:           dnscrypt-proxy
Version:        1.6.1
Release:        alt1
Summary:        A tool for securing communications between a client and a DNS resolver
License:        BSD-3-Clause
Group:          Networking/DNS/Utilities
#Git-Url:       https://github.com/jedisct1/dnscrypt-proxy
Url:            http://dnscrypt.org
Source:         http://download.dnscrypt.org/dnscrypt-proxy/%{name}-%{version}.tar.bz2
Source1:        %name.service
Source2:        %name.sysconfig
Source3:		%name.init
Source4:        dnscrypt-resolvers.csv

# Automatically added by buildreq on Sat Mar 26 2016
# optimized out: gnu-config pkg-config
BuildRequires: libsodium-devel libssl-devel zlib-devel

BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libsodium-devel
BuildRequires:  libtool
Provides:       %{name} = %{version}-%{release}
Obsoletes:      %{name} < %{version}-%{release}

%description
dnscrypt-proxy provides local service which can be used directly as your local resolver or as a DNS forwarder,
encrypting and authenticating requests using the DNSCrypt protocol and passing them to an upstream server,
by default Cisco who run this on their resolvers. (It used to be OpenDNS.)

The DNSCrypt protocol uses high-speed high-security elliptic-curve cryptography and is very similar to
DNSCurve, but focuses on securing communications between a client and its first-level resolver.

While not providing end-to-end security, it protects the local network, which is often the weakest point
of the chain, against man-in-the-middle attacks. It also provides some confidentiality to DNS queries.

%package devel
Summary:        Header files for developent of DNSCrypt plugins
Group:          Development/Languages/C and C++
Requires:       %{name} = %{version}

%description devel
Header files for developent of DNSCrypt plugins.

%prep
%setup

%build
#%configure --enable-plugins
%configure
%make_build

%install
%make_install DESTDIR=%buildroot install

install -pD -m644 %{SOURCE1} %buildroot%systemd_unitdir/%name.service
install -pD -m755 %{SOURCE3} %buildroot%_initdir/%name

mkdir -p %buildroot/%_sysconfdir/sysconfig/
install -pD -m640 %{SOURCE2} %buildroot/%_sysconfdir/sysconfig/%{name}

mkdir -p %buildroot/%_logdir
touch %buildroot/%_logdir/%{name}.log

%pre
/usr/sbin/groupadd -r -f dnscrypt
/usr/sbin/useradd -r -g dnscrypt -d /var/empty -s /dev/null -c 'DNSCrypt user' dnscrypt >/dev/null 2>&1 ||:
if [ $1 -gt 1 ]; then
        /usr/sbin/usermod -d /var/empty dnscrypt
fi


%files
%doc AUTHORS ChangeLog README COPYING NEWS DNSCRYPT-V2-PROTOCOL.txt THANKS
%config(noreplace) %_sysconfdir/sysconfig/%name
%config %_initdir/%name
%systemd_unitdir/%name.service

%_sbindir/%name
%_bindir/hostip

%_man8dir/*

%dir %_datadir/%name
%_datadir/%name/*

%attr(664,root,dnscrypt) %_logdir/%name.log

#%files devel

%changelog
* Sat Mar 26 2016 hobbyte@neko.rocks
  * build for ALT
* Fri Feb 12 2016 dsterba@suse.cz
  * version 1.6.1:
  - Security: malformed packets could cause the OpenDNS deviceid,
  OpenDNS set-client-ip, blocking and AAAA blocking plugins to use
  uninitialized pointers, leading to a denial of service or possibly
  code execution. The vulnerable code is present since dnscrypt-proxy
  1.1.0. OpenDNS users and people using dnscrypt-proxy in order to block
  domain names and IP addresses should upgrade as soon as possible.
- add dnscrypt-resolvers.csv from git (41c6d8bb1f49a0216357)
* Fri Dec 18 2015 dsterba@suse.cz
- add dnscrypt-resolvers.csv from git (e6b4e93d07bdce39d4656c5a6)
- change default resolver to cisco (bnc#957003)
* Mon Aug 31 2015 dsterba@suse.cz
  * version 1.6.0:
  - New feature: public-key based client authentication (-K), for private and
  commercial DNS services to securely authenticate the sender of a query no
  matter what the source IP address is, without altering the DNS query.
  * version 1.5.0:
  - New option: -E, to use an ephemeral key pair for each query.
  - Logging to files is supported on Windows.
  - TCP FASTOPEN is now enabled on Linux.
  * version 1.4.4
  - edns used by default
  - server list updated
  - various build fixes
- spec file cleanup
* Fri Mar  6 2015 dsterba@suse.cz
- update to 1.4.3
  - libevent update, including a fix for CVE-2014-6272
  - Two new public dnscrypt resolvers were added: opennic-us-wa-ns1 and
    dnscrypt.org-fr
  - d0wn servers in France IP have changed.
  - Compilation fixes.
- version 1.4.2
  - New compilation switch: --with-systemd, to enable socket activation support
    when using systemd
  - The list of public DNSCrypt-enabled resolvers was updated
  - Libevent2 updates
- add sysconfig file for more flexible configuration
- build -devel package and enable plugins
- create user dnscrypt:dnscrypt during installation
* Wed Oct  1 2014 dsterba@suse.cz
- update to 1.4.1
* Fri May  2 2014 i@marguerite.su
- update version 1.4.0
  * see https://github.com/jedisct1/dnscrypt-proxy/commits/master
* Tue Oct 23 2012 i@marguerite.su
- fix a hang bug in dnscrypt.service
- upstream clarify license, it's BSD.
* Sun Oct 21 2012 i@marguerite.su
- add systemd service.
* Sun Oct 21 2012 i@marguerite.su
- Version 1.2.0:
  * A pre-filter can now totally bypass the resolver and directly send a
  reply to the client.
  * A new example plugin has been shipped: ldns-aaaa-blocking. It
  directly sends an empty response to AAAA queries in order to
  significantly speed up lookups on hosts without IPv6 connectivity
  (but with clients still asking for AAAA records anyway).
  * Example plugins requiring ldns can be compiled on Windows.
  * Paths with a drive name are now recognized as absolute paths on
  Windows.
