# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
	addr2line@0.21.0
	adler@1.0.2
	aho-corasick@1.1.1
	anstream@0.5.0
	anstyle@1.0.3
	anstyle-parse@0.2.1
	anstyle-query@1.0.0
	anstyle-wincon@2.1.0
	atty@0.2.14
	autocfg@1.1.0
	backtrace@0.3.69
	bitflags@1.3.2
	bumpalo@3.14.0
	byteorder@1.4.3
	bytes@1.5.0
	cc@1.0.83
	cfg-if@1.0.0
	clap@4.4.4
	clap_builder@4.4.4
	clap_lex@0.5.1
	colorchoice@1.0.0
	either@1.9.0
	env_logger@0.7.1
	flume@0.10.14
	futures-core@0.3.28
	futures-sink@0.3.28
	getrandom@0.2.10
	gimli@0.28.0
	glob@0.3.1
	hermit-abi@0.1.19
	hermit-abi@0.3.3
	humantime@1.3.0
	internet-checksum@0.2.1
	ipnetwork@0.19.0
	js-sys@0.3.64
	libc@0.2.148
	lock_api@0.4.10
	log@0.4.20
	memchr@2.6.3
	memoffset@0.6.5
	miniz_oxide@0.7.1
	mio@0.8.8
	nanorand@0.7.0
	neli@0.6.4
	neli-proc-macros@0.1.3
	nix@0.25.1
	no-std-net@0.6.0
	num_cpus@1.16.0
	object@0.32.1
	once_cell@1.18.0
	parking_lot@0.12.1
	parking_lot_core@0.9.8
	pin-project@1.1.3
	pin-project-internal@1.1.3
	pin-project-lite@0.2.13
	pin-utils@0.1.0
	pnet@0.31.0
	pnet_base@0.31.0
	pnet_datalink@0.31.0
	pnet_macros@0.31.0
	pnet_macros_support@0.31.0
	pnet_packet@0.31.0
	pnet_sys@0.31.0
	pnet_transport@0.31.0
	ppv-lite86@0.2.17
	pretty_env_logger@0.4.0
	proc-macro2@1.0.67
	quick-error@1.2.3
	quote@1.0.33
	rand@0.8.5
	rand_chacha@0.3.1
	rand_core@0.6.4
	redox_syscall@0.3.5
	regex@1.9.5
	regex-automata@0.3.8
	regex-syntax@0.7.5
	rustc-demangle@0.1.23
	scopeguard@1.2.0
	serde@1.0.188
	serde_derive@1.0.188
	signal-hook-registry@1.4.1
	smallvec@1.11.1
	socket2@0.4.9
	socket2@0.5.4
	spin@0.9.8
	strsim@0.10.0
	syn@1.0.109
	syn@2.0.37
	termcolor@1.3.0
	tokio@1.32.0
	tokio-macros@2.1.0
	tokio-tun@0.7.0
	tokio-util@0.7.9
	unicode-ident@1.0.12
	utf8parse@0.2.1
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen@0.2.87
	wasm-bindgen-backend@0.2.87
	wasm-bindgen-macro@0.2.87
	wasm-bindgen-macro-support@0.2.87
	wasm-bindgen-shared@0.2.87
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.6
	winapi-x86_64-pc-windows-gnu@0.4.0
	windows-sys@0.48.0
	windows-targets@0.48.5
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_msvc@0.48.5
	windows_i686_gnu@0.48.5
	windows_i686_msvc@0.48.5
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_msvc@0.48.5
"

inherit cargo fcaps

DESCRIPTION="A lightweight and fast UDP to TCP obfuscator."
HOMEPAGE="https://github.com/dndx/phantun"
SRC_URI="
	https://github.com/dndx/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"

# License set may be more restrictive as OR is not respected
# use cargo-license for a more accurate license picture
LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD MIT Unicode-DFS-2016 Unlicense ZLIB"
SLOT="0"
KEYWORDS="~amd64"

FILECAPS=(
	cap_net_admin=+pe "usr/bin/${PN}_client" --
	cap_net_admin=+pe "usr/bin/${PN}_server"
)

QA_FLAGS_IGNORED="
	usr/bin/${PN}_client
	usr/bin/${PN}_server
"

src_install() {
	cargo_src_install --path "${PN}"

	mv "${ED}/usr/bin/client" "${ED}/usr/bin/${PN}_client" || die
	mv "${ED}/usr/bin/server" "${ED}/usr/bin/${PN}_server" || die

	einstalldocs
}