diff --git a/.github/workflows/overlay.toml b/.github/workflows/overlay.toml index ce3e32c70b..890d2cba01 100644 --- a/.github/workflows/overlay.toml +++ b/.github/workflows/overlay.toml @@ -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" diff --git a/acct-group/hysteria/hysteria-0.ebuild b/acct-group/hysteria/hysteria-0.ebuild new file mode 100644 index 0000000000..c62d194eed --- /dev/null +++ b/acct-group/hysteria/hysteria-0.ebuild @@ -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 diff --git a/acct-group/hysteria/metadata.xml b/acct-group/hysteria/metadata.xml new file mode 100644 index 0000000000..3b3c7e4eff --- /dev/null +++ b/acct-group/hysteria/metadata.xml @@ -0,0 +1,8 @@ + + + + + lyraile + iamoatiz@gmail.com + + diff --git a/acct-user/hysteria/hysteria-0.ebuild b/acct-user/hysteria/hysteria-0.ebuild new file mode 100644 index 0000000000..40c6a8c5f5 --- /dev/null +++ b/acct-user/hysteria/hysteria-0.ebuild @@ -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 diff --git a/acct-user/hysteria/metadata.xml b/acct-user/hysteria/metadata.xml new file mode 100644 index 0000000000..3b3c7e4eff --- /dev/null +++ b/acct-user/hysteria/metadata.xml @@ -0,0 +1,8 @@ + + + + + lyraile + iamoatiz@gmail.com + + diff --git a/net-proxy/hysteria/Manifest b/net-proxy/hysteria/Manifest new file mode 100644 index 0000000000..bff72ae86d --- /dev/null +++ b/net-proxy/hysteria/Manifest @@ -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 diff --git a/net-proxy/hysteria/files/hysteria-client.initd b/net-proxy/hysteria/files/hysteria-client.initd new file mode 100644 index 0000000000..a814ca9f83 --- /dev/null +++ b/net-proxy/hysteria/files/hysteria-client.initd @@ -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" +} diff --git a/net-proxy/hysteria/files/hysteria-client.service b/net-proxy/hysteria/files/hysteria-client.service new file mode 100644 index 0000000000..39a614c0c4 --- /dev/null +++ b/net-proxy/hysteria/files/hysteria-client.service @@ -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 diff --git a/net-proxy/hysteria/files/hysteria-server.initd b/net-proxy/hysteria/files/hysteria-server.initd new file mode 100644 index 0000000000..21e2d1581b --- /dev/null +++ b/net-proxy/hysteria/files/hysteria-server.initd @@ -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" +} diff --git a/net-proxy/hysteria/files/hysteria-server.service b/net-proxy/hysteria/files/hysteria-server.service new file mode 100644 index 0000000000..85c0eacf1e --- /dev/null +++ b/net-proxy/hysteria/files/hysteria-server.service @@ -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 diff --git a/net-proxy/hysteria/hysteria-2.1.0.ebuild b/net-proxy/hysteria/hysteria-2.1.0.ebuild new file mode 100644 index 0000000000..05f285cccc --- /dev/null +++ b/net-proxy/hysteria/hysteria-2.1.0.ebuild @@ -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" +} diff --git a/net-proxy/hysteria/metadata.xml b/net-proxy/hysteria/metadata.xml new file mode 100644 index 0000000000..ad7695c8a9 --- /dev/null +++ b/net-proxy/hysteria/metadata.xml @@ -0,0 +1,15 @@ + + + + + lyraile + iamoatiz@gmail.com + + + detect golang arch level on amd64 cpus by CPU_FLAGS_X86 + + + apernet/hysteria + +