# $Id: Portfile 60534 2009-11-14 23:10:00Z ryandesign@macports.org $

PortSystem 1.0

name                    dsocks
version                 1.6
categories              net
maintainers             boeyms openmaintainer
description             SOCKS client wrapper for *BSD / Mac OS X
long_description        dsocks supports just enough of SOCKS 4 and 5 to allow \
                        non-SOCKS-aware applications to connect through either \
                        a local OpenSSH or a local Tor SOCKS proxy.
platforms               darwin freebsd

homepage                http://monkey.org/~dugsong/dsocks/
master_sites            ${homepage}
checksums               md5    3879ecbdccedbee8fcb0713492274c02 \
                        sha1   d2f917b831786cdf0b80f662f6e8b9e283929c92 \
                        rmd160 7a36c11e80a099bd595dfa9ed2cde654ef22aefe

depends_run             bin:ssh:openssh

patchfiles		patch-dsocks.sh.diff patch-dsocks-torify.sh.diff

post-patch  {
    reinplace "s|/usr/local|${prefix}|g" \
        ${worksrcpath}/dsocks.sh \
        ${worksrcpath}/dsocks-torify.sh
}

use_configure           no
build.type              bsd
destroot.post_args      DESTDIR=${destroot} LIBDIR=${prefix}/lib

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/bin
    xinstall -m 755 ${worksrcpath}/dsocks.sh ${destroot}${prefix}/bin
}

variant tor description {Add support for using the TOR anonymising network} {
    depends_run-append  bin:tor:tor port:py-dpkt
    post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/bin
        xinstall -m 755 ${worksrcpath}/dsocks.sh \
            ${destroot}${prefix}/bin
        xinstall -m 755 ${worksrcpath}/dsocks-torify.sh \
            ${destroot}${prefix}/bin
        xinstall -m 755 ${worksrcpath}/tor-dns-proxy.py \
            ${destroot}${prefix}/bin
    }
}
