From 6c0846bb642d25aa81b22fc959a35ba787b3e9de Mon Sep 17 00:00:00 2001 From: Owen-sz Date: Sat, 25 Oct 2025 00:57:13 -0500 Subject: [PATCH] add (backport): graftcp Signed-off-by: Owen-sz --- anda/tools/graftcp/nightly/anda.hcl | 8 +++ .../graftcp/nightly/graftcp-nightly.spec | 56 +++++++++++++++++++ anda/tools/graftcp/nightly/update.rhai | 5 ++ anda/tools/graftcp/stable/anda.hcl | 5 ++ anda/tools/graftcp/stable/graftcp.spec | 52 +++++++++++++++++ anda/tools/graftcp/stable/update.rhai | 1 + 6 files changed, 127 insertions(+) create mode 100644 anda/tools/graftcp/nightly/anda.hcl create mode 100644 anda/tools/graftcp/nightly/graftcp-nightly.spec create mode 100644 anda/tools/graftcp/nightly/update.rhai create mode 100644 anda/tools/graftcp/stable/anda.hcl create mode 100644 anda/tools/graftcp/stable/graftcp.spec create mode 100644 anda/tools/graftcp/stable/update.rhai diff --git a/anda/tools/graftcp/nightly/anda.hcl b/anda/tools/graftcp/nightly/anda.hcl new file mode 100644 index 0000000000..ec2b93230a --- /dev/null +++ b/anda/tools/graftcp/nightly/anda.hcl @@ -0,0 +1,8 @@ +project pkg { + rpm { + spec = "graftcp-nightly.spec" + } + labels { + nightly = 1 + } +} diff --git a/anda/tools/graftcp/nightly/graftcp-nightly.spec b/anda/tools/graftcp/nightly/graftcp-nightly.spec new file mode 100644 index 0000000000..1d62737758 --- /dev/null +++ b/anda/tools/graftcp/nightly/graftcp-nightly.spec @@ -0,0 +1,56 @@ +%global commit ebb5ad865f673ecbde1a628b75c5505bbd2bfd04 +%global commit_date 20250817 +%global shortcommit %(c=%{commit}; echo ${c:0:7}) + +Name: graftcp-nightly +Version: 0~%{commit_date}git.%{shortcommit} +Release: 1%?dist +Summary: A flexible tool for redirecting a given program's TCP traffic to SOCKS5 or HTTP proxy +URL: https://github.com/hmgle/graftcp +License: GPL-3.0 +Source0: %url/archive/%commit/graftcp-%commit.tar.gz +BuildRequires: gcc mold make golang systemd-rpm-macros +Packager: Owen Zimmerman +Conflicts: graftcp + +%description +graftcp can redirect the TCP connection made by the given program [application, script, shell, etc.] to SOCKS5 or HTTP proxy. + +Compared with tsocks, proxychains or proxychains-ng, graftcp is not using the LD_PRELOAD trick which only work for dynamically +linked programs, e.g., applications built by Go can not be hook by proxychains-ng. graftcp can trace or modify any given program's +connect by ptrace(2), so it is workable for any program. The principle will be explained in this paragraph of how does it work. + +%prep +%autosetup -n graftcp-%{commit} + +%build +%make_build + +%install +install -Dm755 graftcp %{buildroot}%{_bindir}/graftcp +install -Dm755 local/graftcp-local %{buildroot}%{_bindir}/graftcp-local +install -Dm755 local/mgraftcp %{buildroot}%{_bindir}/mgraftcp +install -Dm644 local/contrib/systemd/graftcp-local.service %{buildroot}%{_unitdir}/graftcp-local.service +install -Dm644 local/example-graftcp-local.conf %{buildroot}%{_sysconfdir}/graftcp-local/example-graftcp-local.conf + +%post +%systemd_post graftcp-local.service + +%preun +%systemd_preun graftcp-local.service + +%postun +%systemd_postun_with_restart graftcp-local.service + +%files +%doc README.md README.zh-CN.md +%license COPYING +%{_bindir}/graftcp +%{_bindir}/graftcp-local +%{_bindir}/mgraftcp +%{_unitdir}/graftcp-local.service +%{_sysconfdir}/graftcp-local/example-graftcp-local.conf + +%changelog +* Fri Oct 24 2025 Owen Zimmerman +- initial commit diff --git a/anda/tools/graftcp/nightly/update.rhai b/anda/tools/graftcp/nightly/update.rhai new file mode 100644 index 0000000000..00cb6078b9 --- /dev/null +++ b/anda/tools/graftcp/nightly/update.rhai @@ -0,0 +1,5 @@ +rpm.global("commit", gh_commit("hmgle/graftcp")); +if rpm.changed() { + rpm.release(); + rpm.global("commit_date", date()); +} diff --git a/anda/tools/graftcp/stable/anda.hcl b/anda/tools/graftcp/stable/anda.hcl new file mode 100644 index 0000000000..8a082224fb --- /dev/null +++ b/anda/tools/graftcp/stable/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "graftcp.spec" + } +} diff --git a/anda/tools/graftcp/stable/graftcp.spec b/anda/tools/graftcp/stable/graftcp.spec new file mode 100644 index 0000000000..a3201229ef --- /dev/null +++ b/anda/tools/graftcp/stable/graftcp.spec @@ -0,0 +1,52 @@ +Name: graftcp +Version: 0.7.1 +Release: 1%?dist +Summary: A flexible tool for redirecting a given program's TCP traffic to SOCKS5 or HTTP proxy +URL: https://github.com/hmgle/graftcp +License: GPL-3.0 +Source0: %url/archive/refs/tags/v%version.tar.gz +BuildRequires: gcc mold make golang systemd-rpm-macros +Packager: Owen Zimmerman +Conflicts: graftcp-nightly + +%description +graftcp can redirect the TCP connection made by the given program [application, script, shell, etc.] to SOCKS5 or HTTP proxy. + +Compared with tsocks, proxychains or proxychains-ng, graftcp is not using the LD_PRELOAD trick which only work for dynamically +linked programs, e.g., applications built by Go can not be hook by proxychains-ng. graftcp can trace or modify any given program's +connect by ptrace(2), so it is workable for any program. The principle will be explained in this paragraph of how does it work. + +%prep +%autosetup -n graftcp-%{version} + +%build +%make_build + +%install +install -Dm755 graftcp %{buildroot}%{_bindir}/graftcp +install -Dm755 local/graftcp-local %{buildroot}%{_bindir}/graftcp-local +install -Dm755 local/mgraftcp %{buildroot}%{_bindir}/mgraftcp +install -Dm644 local/contrib/systemd/graftcp-local.service %{buildroot}%{_unitdir}/graftcp-local.service +install -Dm644 local/example-graftcp-local.conf %{buildroot}%{_sysconfdir}/graftcp-local/example-graftcp-local.conf + +%post +%systemd_post graftcp-local.service + +%preun +%systemd_preun graftcp-local.service + +%postun +%systemd_postun_with_restart graftcp-local.service + +%files +%doc README.md README.zh-CN.md +%license COPYING +%{_bindir}/graftcp +%{_bindir}/graftcp-local +%{_bindir}/mgraftcp +%{_unitdir}/graftcp-local.service +%{_sysconfdir}/graftcp-local/example-graftcp-local.conf + +%changelog +* Fri Oct 24 2025 Owen Zimmerman +- initial commit diff --git a/anda/tools/graftcp/stable/update.rhai b/anda/tools/graftcp/stable/update.rhai new file mode 100644 index 0000000000..ebe7a2790c --- /dev/null +++ b/anda/tools/graftcp/stable/update.rhai @@ -0,0 +1 @@ +rpm.version(gh("hmgle/graftcp"));