# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup github    1.0

github.setup        DNSCrypt dnscrypt-proxy 2.1.14
github.tarball_from archive
revision            0

checksums           rmd160  75e39e1643b2f45a6785326ea41a7dd842e734b6 \
                    sha256  495c4f494d40068e5e3ddcb8748d91b90e99f2516060e3b59520b9f3d6148a9e \
                    size    4190307

categories          net
license             ISC
maintainers         nomaintainer
description         A protocol for securing communications between a client and a DNS \
                    resolver.
long_description    {*}${description}

homepage            https://www.dnscrypt.info

depends_build       port:go

use_configure       no

worksrcdir          ${distname}/${name}
build.cmd           go build
build.args          -ldflags="-s -w"
build.target
build.env           GOPATH=${workpath}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/sbin
    xinstall -m 0755 -d ${destroot}${prefix}/share/${name}
    xinstall -m 0640 -W ${worksrcpath} example-allowed-ips.txt example-allowed-names.txt example-blocked-ips.txt example-blocked-names.txt example-captive-portals.txt example-cloaking-rules.txt example-dnscrypt-proxy.toml example-forwarding-rules.txt ${destroot}${prefix}/share/${name}
}

post-activate {
    if {![file exists ${prefix}/share/${name}/dnscrypt-proxy.toml]} {
        file copy ${prefix}/share/${name}/example-dnscrypt-proxy.toml ${prefix}/share/${name}/dnscrypt-proxy.toml
    }
}

startupitem.create      yes
startupitem.netchange   yes
startupitem.executable  ${prefix}/sbin/${name} -config ${prefix}/share/${name}/dnscrypt-proxy.toml

notes "
To use this port, update your DNS server settings to point to 127.0.0.1\
(in the Network Preference Pane -> Advanced... -> DNS tab)

If you are upgrading from dnscrypt-proxy 2.0.x, the configuration file\
has changed and you will need to modify your configuration file to \
match the 2.1.x configuration file requirements.
"
