diff --git a/CMakeLists.txt b/CMakeLists.txt index fa7eb45..670a0b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,15 +28,10 @@ install(TARGETS cgproxyd DESTINATION /usr/bin PERMISSIONS ${basic_permission}) install(TARGETS cgproxy DESTINATION /usr/bin PERMISSIONS ${basic_permission}) install(TARGETS cgnoproxy DESTINATION /usr/bin PERMISSIONS ${basic_permission}) -install(FILES cgproxy.service - DESTINATION /usr/lib/systemd/system/) -install(FILES config.json - DESTINATION /etc/cgproxy/) -install(FILES cgroup-tproxy.sh - DESTINATION /usr/share/cgproxy/scripts/) - -install(FILES readme.md - DESTINATION /share/doc/cgproxy/) +install(FILES cgproxy.service DESTINATION /usr/lib/systemd/system/) +install(FILES config.json DESTINATION /etc/cgproxy/) +install(FILES cgroup-tproxy.sh DESTINATION /usr/share/cgproxy/scripts/) +install(FILES readme.md DESTINATION /share/doc/cgproxy/) ## package for deb and rpm @@ -47,7 +42,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "cgproxy will transparent proxy anything r ## deb pack set(CPACK_DEBIAN_PACKAGE_NAME "cgproxy") set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "x86_64") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "systemd") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "systemd" "nlohmann-json3-dev") set(CPACK_DEBIAN_PACKAGE_SECTION "network") set(CPACK_DEBIAN_PACKAGE_PRIORITY "Optional") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/springzfx/cgproxy") @@ -57,7 +52,7 @@ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CONTROL_DIR}/postinst;${CONTROL_DIR}/p ## rpm pack set(CPACK_RPM_PACKAGE_ARCHITECTURE, "x86_64") -set(CPACK_RPM_PACKAGE_REQUIRES "systemd") +set(CPACK_RPM_PACKAGE_REQUIRES "systemd" "json-devel") set(CPACK_RPM_PACKAGE_GROUP "network") set(CPACK_RPM_PACKAGE_URL "https://github.com/springzfx/cgproxy") set(CONTROL_DIR ${CMAKE_SOURCE_DIR}/control) diff --git a/cgnoproxy.sh b/cgnoproxy.sh deleted file mode 100644 index e66a182..0000000 --- a/cgnoproxy.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -config="/etc/cgproxy.conf" -source $config - -# test suid bit -if [ -u "$(which cgattach)" ]; then - cgattach $$ $cgroup_noproxy && attached=1 -else - sudo cgattach $$ $cgroup_noproxy && attached=1 -fi - -# test attach success or not -[[ -z "$attached" ]] && echo "attach error" && exit 1 - -exec "$@" \ No newline at end of file diff --git a/cgproxy.conf b/cgproxy.conf deleted file mode 100644 index c224b52..0000000 --- a/cgproxy.conf +++ /dev/null @@ -1,48 +0,0 @@ -## cgroup transparent proxy -## see how to configure, https://github.com/springzfx/cgproxy - -################################################################################### -## any process in cgroup_proxy will be proxied, and cgroup_noproxy the opposite -## note, cgroup must start with slash '/' -## the value can be string or bash array -## for array, only the first element will be created if not exist -## and the rest elements will not, so won't be applied if not exist - -### global proxy with v2ray service -# cgroup_proxy="/" -# cgroup_noproxy=("/noproxy.slice" "/system.slice/v2ray.service") - -### global proxy with manual `cgnoporxy qv2ray` -# cgroup_proxy="/" -# cgroup_noproxy="/noproxy.slice" - -### default -cgroup_proxy="/proxy.slice" -cgroup_noproxy="/noproxy.slice" - - -################################################################################### -## allow as gateway for local network -enable_gateway=false - - -################################################################################### -## listening port of another proxy process, for example v2ray -port=12345 - - -################################################################################### -## if you set to false, it's traffic won't go through proxy, -## but still can go direct to internet -enable_dns=true -enable_tcp=true -enable_udp=true -enable_ipv4=true -enable_ipv6=true - - -################################################################################### -## do not modify this if you don't known what you are doing -table=100 -fwmark=0x01 -mark_newin=0x02 diff --git a/cgproxy.sh b/cgproxy.sh deleted file mode 100644 index beeeb52..0000000 --- a/cgproxy.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -config="/etc/cgproxy.conf" -source $config - -# test suid bit -if [ -u "$(which cgattach)" ]; then - cgattach $$ $cgroup_proxy && attached=1 -else - sudo cgattach $$ $cgroup_proxy && attached=1 -fi - -# test attach success or not -[[ -z "$attached" ]] && echo "attach error" && exit 1 - -exec "$@" \ No newline at end of file diff --git a/run_in_cgroup.sh b/run_in_cgroup.sh deleted file mode 100644 index f15c900..0000000 --- a/run_in_cgroup.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -print_help(){ -cat << 'DOC' -usage: - run_in_cgroup --cgroup=CGROUP - run_in_cgroup --help -note: - CGROUP must start will slash '/' , and no special character -example: - run_in_cgroup --cggroup=/mycgroup.slice ping 127.0.0.1 -DOC -} - -## parse parameter -for i in "$@" -do -case $i in - --cgroup=*) - cgroup=${i#*=} - shift - ;; - --help) - print_help - exit 0 - shift - ;; - -*) - shift - ;; - *) - break - ;; -esac -done - -[[ -z "$cgroup" ]] && print_help && exit 1 -[[ -z "$@" ]] && print_help && exit 1 - -# test suid bit -if [ -u "$(which cgattach)" ]; then - cgattach $$ $cgroup && attached=1 -else - sudo cgattach $$ $cgroup && attached=1 -fi - -# test attach success or not -[[ -z "$attached" ]] && print_help && exit 1 - -exec "$@"