# -*- 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.5
revision            0

checksums           rmd160  6a98fdd7321bd227f108df793e1d5bab5cb4565b \
                    sha256  10be32bb6c34f2203c3a30b92ae444e261601a75bff18d0a646c421a24bb6622 \
                    size    4066256

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.
"
