# If any of the following macros should be set otherwise, # you can wrap any of them with the following conditions: # - %%if 0%%{centos} == 7 # - %%if 0%%{?rhel} == 7 # - %%if 0%%{?fedora} == 23 # Or just test for particular distribution: # - %%if 0%%{centos} # - %%if 0%%{?rhel} # - %%if 0%%{?fedora} # # Be aware, on centos, both %%rhel and %%centos are set. If you want to test # rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition. # (Don't forget to replace double percentage symbol with single one in order to apply a condition) # Generate devel rpm %global with_devel 0 # Build project from bundled dependencies %global with_bundled 0 # Build with debug info rpm %global with_debug 1 # Run tests in check section %global with_check 1 # Generate unit-test rpm %global with_unit_test 1 %if 0%{?with_debug} %global _dwz_low_mem_die_limit 0 %else %global debug_package %{nil} %endif %if ! 0%{?gobuild:1} %define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; %endif %global provider torproject %global provider_tld org %global project pluggable-transports %global repo obfs4.git # https://git.torproject.org/pluggable-transports/obfs4.git %global provider_prefix git.%{provider}.%{provider_tld}/%{project}/%{repo} %global import_path %{provider_prefix} #%%global commit #%%global shortcommit %(c=%%{commit}; echo ${c:0:7}) Name: obfs4 Version: 0.0.7 Release: 4%{?dist} Summary: The obfourscator, a pluggable transport for Tor # Detected licences # - BSD (3 clause) at 'LICENSE' License: BSD URL: https://gitweb.%{provider}.%{provider_tld}/%{project}/%{repo} # The source for this package was pulled from upstream's vcs. Clone the # repository and create archive using: # git archive --format=tar --prefix=obfs4-/ obfs4proxy- | xz > obfs4-.tar.gz Source0: %{name}-%{version}.tar.xz # Created by myself Source1: obfs4.torrc # e.g. el6 has ppc64 arch without gcc-go, so EA tag is required ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}} # If go_compiler is not set to 1, there is no virtual provide. Use golang instead. BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %if ! 0%{?with_bundled} # obfs4proxy/proxy_http.go BuildRequires: golang(golang.org/x/net/proxy) # obfs4proxy/obfs4proxy.go BuildRequires: golang(golang.org/x/net/proxy) # obfs4proxy/proxy_socks4.go BuildRequires: golang(golang.org/x/net/proxy) # Remaining dependencies not included in main packages BuildRequires: golang(github.com/dchest/siphash) BuildRequires: golang(golang.org/x/crypto/nacl/secretbox) BuildRequires: golang(github.com/agl/ed25519/extra25519) BuildRequires: golang(golang.org/x/crypto/hkdf) BuildRequires: golang(golang.org/x/crypto/curve25519) BuildRequires: golang(git.torproject.org/pluggable-transports/goptlib.git) %endif %description This is a look-like nothing obfuscation protocol that incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol. The obfs naming was chosen primarily because it was shorter, in terms of protocol ancestry obfs4 is much closer to ScrambleSuit than obfs2/obfs3. The notable differences between ScrambleSuit and obfs4: * The handshake always does a full key exchange (no such thing as a Session Ticket Handshake). * The handshake uses the Tor Project's ntor handshake with public keys obfuscated via the Elligator 2 mapping. * The link layer encryption uses NaCl secret boxes (Poly1305/XSalsa20). As an added bonus, obfs4proxy also supports acting as an obfs2/3 client and bridge to ease the transition to the new protocol. %if 0%{?with_devel} %package -n golang-%{provider}-%{project}-%{repo}-devel Summary: %{summary} BuildArch: noarch %if 0%{?with_check} && ! 0%{?with_bundled} BuildRequires: golang(github.com/agl/ed25519/extra25519) BuildRequires: golang(github.com/dchest/siphash) BuildRequires: golang(golang.org/x/crypto/curve25519) BuildRequires: golang(golang.org/x/crypto/hkdf) BuildRequires: golang(golang.org/x/crypto/nacl/secretbox) BuildRequires: golang(git.torproject.org/pluggable-transports/goptlib.git) %endif Requires: golang(github.com/agl/ed25519/extra25519) Requires: golang(github.com/dchest/siphash) Requires: golang(golang.org/x/crypto/curve25519) Requires: golang(golang.org/x/crypto/hkdf) Requires: golang(golang.org/x/crypto/nacl/secretbox) Requires: golang(git.torproject.org/pluggable-transports/goptlib.git) Provides: golang(%{import_path}/common/csrand) = %{version}-%{release} Provides: golang(%{import_path}/common/drbg) = %{version}-%{release} Provides: golang(%{import_path}/common/log) = %{version}-%{release} Provides: golang(%{import_path}/common/ntor) = %{version}-%{release} Provides: golang(%{import_path}/common/probdist) = %{version}-%{release} Provides: golang(%{import_path}/common/replayfilter) = %{version}-%{release} Provides: golang(%{import_path}/common/socks5) = %{version}-%{release} Provides: golang(%{import_path}/common/uniformdh) = %{version}-%{release} Provides: golang(%{import_path}/transports) = %{version}-%{release} Provides: golang(%{import_path}/transports/base) = %{version}-%{release} Provides: golang(%{import_path}/transports/meeklite) = %{version}-%{release} Provides: golang(%{import_path}/transports/obfs2) = %{version}-%{release} Provides: golang(%{import_path}/transports/obfs3) = %{version}-%{release} Provides: golang(%{import_path}/transports/obfs4) = %{version}-%{release} Provides: golang(%{import_path}/transports/obfs4/framing) = %{version}-%{release} Provides: golang(%{import_path}/transports/scramblesuit) = %{version}-%{release} %description -n golang-%{provider}-%{project}-%{repo}-devel %{summary} This package contains library source intended for building other packages which use import path with %{import_path} prefix. %endif %if 0%{?with_unit_test} && 0%{?with_devel} %package unit-test-devel Summary: Unit tests for %{name} package %if 0%{?with_check} #Here comes all BuildRequires: PACKAGE the unit tests #in %%check section need for running %endif # test subpackage tests code from devel subpackage Requires: %{name}-devel = %{version}-%{release} %if 0%{?with_check} && ! 0%{?with_bundled} %endif %description unit-test-devel %{summary} This package contains unit tests for project providing packages with %{import_path} prefix. %endif %prep %setup -q -n %{name}-%{version} %build mkdir -p src/git.%{provider}.%{provider_tld}/%{project} ln -s ../../../ src/%{import_path} %if ! 0%{?with_bundled} export GOPATH=$(pwd):%{gopath} %else # No dependency directories so far export GOPATH=$(pwd):%{gopath} %endif %gobuild -o bin/obfs4proxy %{import_path}/obfs4proxy %install install -d -p %{buildroot}%{_bindir} %{buildroot}%{_mandir}/man1 %{buildroot}%{_sysconfdir}/tor install -p -m 0755 bin/obfs4proxy %{buildroot}%{_bindir} install -p -m 0644 doc/obfs4proxy.1 %{buildroot}%{_mandir}/man1 install -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/tor # source codes for building projects %if 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list # find all *.go but no *_test.go files and generate devel.file-list for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go") ; do dirprefix=$(dirname $file) install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list while [ "$dirprefix" != "." ]; do echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list dirprefix=$(dirname $dirprefix) done done %endif # testing files for this project %if 0%{?with_unit_test} && 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ # find all *_test.go files and generate unit-test-devel.file-list for file in $(find . -iname "*_test.go") ; do dirprefix=$(dirname $file) install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list while [ "$dirprefix" != "." ]; do echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list dirprefix=$(dirname $dirprefix) done done %endif %if 0%{?with_devel} sort -u -o devel.file-list devel.file-list %endif %check %if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel} %if ! 0%{?with_bundled} export GOPATH=%{buildroot}/%{gopath}:%{gopath} %else # No dependency directories so far export GOPATH=%{buildroot}/%{gopath}:%{gopath} %endif %if ! 0%{?gotest:1} %global gotest go test %endif %gotest %{import_path}/common/ntor %gotest %{import_path}/common/probdist %gotest %{import_path}/common/replayfilter %gotest %{import_path}/common/socks5 %gotest %{import_path}/common/uniformdh %gotest %{import_path}/transports/obfs4 %gotest %{import_path}/transports/obfs4/framing %endif #define license tag if not already defined %{!?_licensedir:%global license %doc} %files %license LICENSE %doc README.md doc/obfs4-spec.txt %{_bindir}/obfs4proxy %{_mandir}/man1/obfs4proxy.1* %dir %{_sysconfdir}/tor %config(noreplace) %{_sysconfdir}/tor/obfs4.torrc %if 0%{?with_devel} %files -n golang-%{provider}-%{project}-%{repo}-devel -f devel.file-list %license LICENSE %dir %{gopath}/src/git.%{provider}.%{provider_tld}/%{project} %endif %if 0%{?with_unit_test} && 0%{?with_devel} %files unit-test-devel -f unit-test-devel.file-list %endif %changelog * Thu Feb 08 2018 Fedora Release Engineering - 0.0.7-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild * Sun Feb 04 2018 Hedayat Vatankhah - 0.0.7-3 - Mark obfs4.torrc as config file, so that local changes won't be overriden * Thu Jan 18 2018 Hedayat Vatankhah - 0.0.7-2 - Add a sample config file: obfs4.torrc in /etc/tor/ * Thu Sep 28 2017 Hedayat Vatankhah - 0.0.7-1 - First package for Fedora