# -*- 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           gitlab 1.0
PortGroup           legacysupport 1.1

# _strndup
legacysupport.newest_darwin_requires_legacy 10

gitlab.instance     https://gitlab.torproject.org/tpo
gitlab.setup        core torsocks 2.4.0 v
revision            0
checksums           rmd160  667813c86c1309281aae37a11e12101e760cbc12 \
                    sha256  f428cacf231ca9d11706ad2c701effc2b5fb71e9bdbdce1bbe294e0679a6fb17 \
                    size    96854

categories          net security
license             GPL-2+
maintainers         yopmail.com:sami.laine

description         A transparent socks proxy for use with tor

long_description    Torsocks is an application for Linux, BSD and \
                    macOS that allows you to use network applications \
                    such as ssh and irssi with Tor. Torsocks allows you \
                    to use most socks-friendly applications in a safe \
                    way with Tor. It ensures that DNS requests are \
                    handled safely and explicitly rejects UDP traffic \
                    from the application you are using.

# See https://trac.torproject.org/projects/tor/ticket/28538
# and https://gitlab.torproject.org/tpo/core/torsocks/-/issues/28538
# This same patch is being used by the Homebrew torsocks formula
patchfiles          0001-Fix-macros-for-accept4-2.patch
patchfiles-append   implicit.patch gethostbyaddr_r.patch version.patch

depends_build       path:libexec/coreutils/libstdbuf.so:coreutils

# No configure script in tarball.
use_autoreconf      yes
autoreconf.cmd      ./autogen.sh
autoreconf.args
depends_build-append \
                    port:autoconf \
                    port:automake \
                    port:libtool

configure.args      --disable-silent-rules

post-destroot {
    move ${destroot}${prefix}/etc/tor/torsocks.conf \
        ${destroot}${prefix}/etc/tor/torsocks.conf.default
}

post-activate {
    if {![file exists ${prefix}/etc/tor/torsocks.conf]} {
        file copy ${prefix}/etc/tor/torsocks.conf.default \
            ${prefix}/etc/tor/torsocks.conf
  }
}

test.run            yes
test.target         check
