# -*- 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           golang 1.0

go.setup            github.com/DNSCrypt/dnscrypt-proxy 2.1.15
revision            0
categories          net
license             ISC
maintainers         {i0ntempest @i0ntempest} openmaintainer
description         A flexible DNS proxy, with support for encrypted DNS protocols
long_description    A flexible DNS proxy, with support for modern encrypted DNS protocols such as DNSCrypt v2,\
                    DNS-over-HTTPS, Anonymized DNSCrypt and ODoH (Oblivious DoH).

homepage            https://dnscrypt.info

checksums           rmd160  d50158276ed8b2fac83d76bcc0e1bd9573a7fb27 \
                    sha256  57da91dd2a3992a1528e764bcfe9b48088c63c933c0c571a2cac3d27ac8c7546 \
                    size    4058547

go.offline_build    no

build.dir           ${worksrcpath}/${name}
build.post_args     -ldflags="-s -w"

destroot {
    xinstall -m 0755 ${build.dir}/${name} ${destroot}${prefix}/sbin
    xinstall -m 0755 -d ${destroot}${prefix}/share/${name} ${destroot}${prefix}/etc/${name}
    xinstall -m 0640 {*}[glob ${build.dir}/example-*.txt] ${destroot}${prefix}/share/${name}
    xinstall -m 0640 {*}[glob ${build.dir}/example-*.toml] ${destroot}${prefix}/etc/${name}
}

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

startupitem.create      yes
startupitem.netchange   yes
startupitem.executable  ${prefix}/sbin/${name} -config ${prefix}/etc/${name}/${name}.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)

The default configuration file is copied to ${prefix}/etc/${name}/${name}.toml.\
It is used by the startup item (service). You should edit or replace it.

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. Also note that the path for\
the configuration file has changed in 2.1.15.
"
