net-proxy/hysteria: new package

This commit is contained in:
oatiz 2023-10-13 01:42:59 +08:00 committed by 梁永祥
parent f0aad1844f
commit 58c41b6214
12 changed files with 240 additions and 0 deletions

View File

@ -957,6 +957,13 @@ use_latest_release = true
prefix = "v"
github_account = "st0nie"
["net-proxy/hysteria"]
source = "github"
github = "apernet/hysteria"
use_latest_release = true
prefix = "app/v"
github_account = "oatiz"
["net-proxy/make-proxy"]
source = "github"
github = "yueyoum/make-proxy"

View File

@ -0,0 +1,8 @@
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit acct-group
ACCT_GROUP_ID=-1

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<name>lyraile</name>
<email>iamoatiz@gmail.com</email>
</maintainer>
</pkgmetadata>

View File

@ -0,0 +1,13 @@
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit acct-user
ACCT_USER_ID=-1
ACCT_USER_GROUPS=( hysteria )
ACCT_USER_HOME="/etc/hysteria"
ACCT_USER_HOME_OWNER="hysteria:hysteria"
acct-user_add_deps

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<name>lyraile</name>
<email>iamoatiz@gmail.com</email>
</maintainer>
</pkgmetadata>

View File

@ -0,0 +1,2 @@
DIST hysteria-2.1.0-deps.tar.xz 42357544 BLAKE2B 15d146c29666c736c14ca82ca8b30a62155afad9adbf1c8eeb69e0043b4d333af081c7ec3b756163b4d520a2b01e2d761f998db6da2f3de44c10bd3d43f69922 SHA512 b40cb4b5bf35a3d1a4de3d4f057ae4dcbc42bbb33b20584a483ff2144e54e7ce5dbb09a964063c06d8040cc8d213bc895bb4710dbae03b67b1f3818a0d0cd52f
DIST hysteria-2.1.0.tar.gz 3776335 BLAKE2B 4ec3aa0f162fb4653b256f6dc1886072cc88888ce09ddecbfa002833fd0555a52e31c122013fa1d3081f876306eab5e244902ba9019d9d31ff97f8ff0b32330d SHA512 9435ef173adb90ec1d31fa956fac48a81bafb9d8151e73a6bb13b4224fecd63941480542ea523e3334b5a19cd71016f0d79db245466d54b5b8ab493a42f3c651

View File

@ -0,0 +1,23 @@
#!/sbin/openrc-run
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
pidfile="/run/hysteria/hysteria-client.pid"
command="/usr/bin/hysteria"
command_args="client --config /etc/hysteria/client.yaml --disable-update-check"
command_background="yes"
command_user="hysteria:hysteria"
capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"
output_log="/var/log/hysteria-client.log"
error_log="/var/log/hysteria-client.log"
depend() {
need net
after local
}
start_pre() {
checkpath -d -m 0755 -o "$command_user" /run/hysteria
checkpath -f -m 0644 -o "$command_user" "$output_log"
}

View File

@ -0,0 +1,18 @@
[Unit]
Description=Hysteria Client Service
Documentation=https://hysteria.network/
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/hysteria client --config /etc/hysteria/client.yaml --disable-update-check
WorkingDirectory=~
User=hysteria
Group=hysteria
Environment=HYSTERIA_LOG_LEVEL=info
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,23 @@
#!/sbin/openrc-run
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
pidfile="/run/hysteria/hysteria-server.pid"
command="/usr/bin/hysteria"
command_args="server --config /etc/hysteria/server.yaml --disable-update-check"
command_background="yes"
command_user="hysteria:hysteria"
capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"
output_log="/var/log/hysteria-server.log"
error_log="/var/log/hysteria-server.log"
depend() {
need net
after local
}
start_pre() {
checkpath -d -m 0755 -o "$command_user" /run/hysteria
checkpath -f -m 0644 -o "$command_user" "$output_log"
}

View File

@ -0,0 +1,19 @@
[Unit]
Description=Hysteria Server Service
Documentation=https://hysteria.network/
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/hysteria server --config /etc/hysteria/server.yaml --disable-update-check
WorkingDirectory=~
User=hysteria
Group=hysteria
Environment=HYSTERIA_LOG_LEVEL=info
Environment=HYSTERIA_ACME_DIR=/var/lib/hysteria/acme
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,96 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit go-module systemd
DESCRIPTION="A powerful, lightning fast and censorship resistant proxy."
HOMEPAGE="https://github.com/apernet/hysteria"
SRC_URI="
https://github.com/apernet/${PN}/archive/refs/tags/app/v${PV}.tar.gz -> ${P}.tar.gz
https://github.com/oatiz/gentoo-go-deps/releases/download/${P}/${P}-deps.tar.xz
"
RESTRICT="mirror"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
GO_CPU_FLAGS_X86="
cpu_flags_x86_avx2
cpu_flags_x86_fma4
cpu_flags_x86_fma3
cpu_flags_x86_f16c
cpu_flags_x86_avx
cpu_flags_x86_sse4_2
cpu_flags_x86_sse4_1
cpu_flags_x86_ssse3
cpu_flags_x86_sse3
"
IUSE="+goamd64 ${GO_CPU_FLAGS_X86[@]}"
DEPEND="
acct-user/hysteria
acct-group/hysteria
>=dev-lang/go-1.21.1
"
RDEPEND="${DEPEND}"
S="${WORKDIR}/${PN}-app-v${PV}"
ego() {
set -- go "$@"
echo "$@" >&2
"$@" || die -n "${*} failed"
}
pkg_setup() {
if use goamd64; then
GOAMD64_V="v1"
if use cpu_flags_x86_sse3 && use cpu_flags_x86_sse4_1 && use cpu_flags_x86_sse4_2 && use cpu_flags_x86_ssse3
then
GOAMD64_V="v2"
if use cpu_flags_x86_avx && use cpu_flags_x86_avx2 && use cpu_flags_x86_f16c && \
(use cpu_flags_x86_fma4 || use cpu_flags_x86_fma3)
then
GOAMD64_V="v3"
fi
fi
export GOAMD64="${GOAMD64_V}"
einfo "building with GOAMD64=${GOAMD64_V}"
fi
}
src_compile() {
local APP_SRC_CMD_PKG="github.com/apernet/hysteria/app/cmd"
local APP_DATE
APP_DATE=$(LC_ALL=C date -u +'%Y-%m-%dT%H:%M:%SZ' || die)
local APP_ARCH="Unknown"
if use goamd64; then
APP_ARCH="amd64-${GOAMD64}"
fi
CGO_ENABLED=1 ego build \
-trimpath \
-ldflags "-s -w -extldflags \"${LDFLAGS}\" \
-X \"${APP_SRC_CMD_PKG}.appVersion=${PV}\" \
-X \"${APP_SRC_CMD_PKG}.appDate=${APP_DATE}\" \
-X \"${APP_SRC_CMD_PKG}.appType=release\" \
-X \"${APP_SRC_CMD_PKG}.appPlatform=linux\" \
-X \"${APP_SRC_CMD_PKG}.appArch=${APP_ARCH}\" \
" \
-o "${PN}" "./app"
}
src_install() {
insinto "/etc/${PN}"
dobin "${PN}"
systemd_dounit "${FILESDIR}/${PN}-server.service"
systemd_dounit "${FILESDIR}/${PN}-client.service"
newinitd "${FILESDIR}/${PN}-server.initd" "${PN}-server"
newinitd "${FILESDIR}/${PN}-client.initd" "${PN}-client"
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE
pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<name>lyraile</name>
<email>iamoatiz@gmail.com</email>
</maintainer>
<use>
<flag name="goamd64">detect golang arch level on amd64 cpus by CPU_FLAGS_X86</flag>
</use>
<upstream>
<remote-id type="github">apernet/hysteria</remote-id>
</upstream>
</pkgmetadata>