diff options
author | DuckSoft | 2020-05-21 14:38:43 +0800 |
---|---|---|
committer | DuckSoft | 2020-05-21 14:38:43 +0800 |
commit | 75fd049f17e6c9db896a7f8d2e46b51fbf69256f (patch) | |
tree | 6492c6829a7899d3701b2d58794323e4117f5dd0 | |
parent | c2e4a1337e9a2b2d2b95d31a09fd60959dace5df (diff) | |
download | aur-75fd049f17e6c9db896a7f8d2e46b51fbf69256f.tar.gz |
rewrite
-rw-r--r-- | .SRCINFO | 26 | ||||
-rw-r--r-- | PKGBUILD | 67 | ||||
-rw-r--r-- | v2ray-cap.hook | 14 | ||||
-rwxr-xr-x | v2ray-cap.sh | 11 | ||||
-rw-r--r-- | v2ray.service | 13 |
5 files changed, 44 insertions, 87 deletions
@@ -1,24 +1,18 @@ pkgbase = v2ray-cap-git - pkgdesc = V2Ray core with capabilities. Special for Transparent Proxies. - pkgver = 4.20.0.r22.ge9f53059 + pkgdesc = V2Ray Core with Capabilities for Transparent Proxies + pkgver = 0.0.1 pkgrel = 1 url = https://github.com/v2ray/v2ray-core + install = v2ray-cap.sh arch = x86_64 license = MIT - makedepends = go-pie - makedepends = golang-golang-x-crypto - makedepends = golang-golang-x-net - makedepends = git - depends = glibc - depends = v2ray-domain-list-community - depends = v2ray-geoip - provides = v2ray - conflicts = v2ray - backup = etc/v2ray/config.json - source = v2ray-cap-git::git+https://github.com/v2ray/v2ray-core.git - source = v2ray.service - sha512sums = SKIP - sha512sums = 80ea8dde70e43133bbb2803496863e8001fff580281abdbb3be2406ab8789853d4ba7295fbce07058af980a4606eda89c9fc4a7c0f81ec078ae67c38abefbc0c + depends = v2ray + depends = libcap + provides = v2ray-cap + source = v2ray-cap.hook + source = v2ray-cap.sh + sha512sums = 90d16c05802b7b45742131fcb38fde26a343462a11452e0dbcfa9ef6dc39c27cff355bd8fadb654255dd9f09126835e26681940a3f9fb245b583dad4d06ca1ac + sha512sums = 75238188db3d49b36a9d3003d997af30c6a82edcaa5fc0a6657e2c5338d62d58bbed1fdf3c34ba361086032da8b3c2623842ae461cf2c3cbd8db12792c94d1a8 pkgname = v2ray-cap-git @@ -1,67 +1,18 @@ # Maintainer: DuckSoft <realducksoft at gmail dot com> pkgname=v2ray-cap-git -pkgver=4.20.0.r22.ge9f53059 +pkgver=0.0.1 pkgrel=1 -pkgdesc="V2Ray core with capabilities. Special for Transparent Proxies." +pkgdesc="V2Ray Core with Capabilities for Transparent Proxies" arch=(x86_64) url="https://github.com/v2ray/v2ray-core" license=(MIT) -depends=(glibc v2ray-domain-list-community v2ray-geoip) -makedepends=(go-pie golang-golang-x-crypto golang-golang-x-net git) -backup=(etc/v2ray/config.json) -provides=(v2ray) -conflicts=(v2ray) -source=("$pkgname::git+$url.git" - 'v2ray.service') -sha512sums=('SKIP' - '80ea8dde70e43133bbb2803496863e8001fff580281abdbb3be2406ab8789853d4ba7295fbce07058af980a4606eda89c9fc4a7c0f81ec078ae67c38abefbc0c') - -prepare() { - export GOPATH="$srcdir/build:/usr/share/gocode" - mkdir -p "$srcdir"/build/src/v2ray.com - - # mv *.com *.io *.org *.net "$srcdir"/build/src/ - mv $pkgname "$srcdir"/build/src/v2ray.com/core - - # Future makedepends - go get github.com/golang/protobuf/proto go.starlark.net/starlark go.starlark.net/syntax \ - google.golang.org/grpc - - # Future checkdepends - go get github.com/golang/mock/gomock github.com/google/go-cmp/cmp \ - golang.org/x/sync/errgroup github.com/miekg/dns h12.io/socks -} - - -pkgver() { - # $pkgname was moved in prepare(), so need to enter new directory - cd "$srcdir"/build/src/v2ray.com/core - - # cutting off 'v' prefix that presents in the git tag - git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' -} - -build() { - go build -o v2ray v2ray.com/core/main - go build -o v2ctl v2ray.com/core/infra/control/main -} - -check() { - cd "$srcdir"/build/src/v2ray.com/core - go test -p 1 -tags json -v -timeout 30m v2ray.com/core/... -} +depends=(v2ray libcap) +provides=(v2ray-cap) +source=(v2ray-cap.hook v2ray-cap.sh) +sha512sums=('90d16c05802b7b45742131fcb38fde26a343462a11452e0dbcfa9ef6dc39c27cff355bd8fadb654255dd9f09126835e26681940a3f9fb245b583dad4d06ca1ac' + '75238188db3d49b36a9d3003d997af30c6a82edcaa5fc0a6657e2c5338d62d58bbed1fdf3c34ba361086032da8b3c2623842ae461cf2c3cbd8db12792c94d1a8') +install='v2ray-cap.sh' package() { - cd "$srcdir"/build/src/v2ray.com/core - install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/v2ray/LICENSE - install -Dm644 release/config/systemd/v2ray.service "$pkgdir"/usr/lib/systemd/system/v2ray.service - sed -i -e '/ExecStart/i Environment=V2RAY_LOCATION_ASSET=/etc/v2ray' \ - -e 's|/usr/bin/v2ray/v2ray|/usr/bin/v2ray|' \ - "$pkgdir"/usr/lib/systemd/system/v2ray.service - install -Dm644 release/config/*.json -t "$pkgdir"/etc/v2ray/ - install -Dm755 "$srcdir"/v2ray -t "$pkgdir"/usr/bin/ - install -Dm755 "$srcdir"/v2ctl -t "$pkgdir"/usr/bin/ - setcap "cap_net_admin,cap_net_bind_service=ep" "$pkgdir"/usr/lib/v2ray/v2ray - - install -Dm644 "$srcdir"/v2ray.service "$pkgdir"/usr/lib/systemd/system/v2ray@.service + install -Dm644 "$srcdir"/v2ray-cap.hook -t "$pkgdir"/usr/share/libalpm/hooks/ } diff --git a/v2ray-cap.hook b/v2ray-cap.hook new file mode 100644 index 000000000000..8325e2340fad --- /dev/null +++ b/v2ray-cap.hook @@ -0,0 +1,14 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Path +Target = usr/lib/v2ray/v2ray + +[Action] +Description = setcap to v2ray +Depends = libcap +When = PostTransaction +Exec = /usr/bin/setcap "cap_net_bind_service=+ep cap_net_admin=+ep" /usr/lib/v2ray/v2ray +NeedsTargets + + diff --git a/v2ray-cap.sh b/v2ray-cap.sh new file mode 100755 index 000000000000..872d4a6b9bef --- /dev/null +++ b/v2ray-cap.sh @@ -0,0 +1,11 @@ +#/bin/sh + +post_install() { + echo 'Granting Capabilities to V2Ray Core...' + /usr/bin/setcap 'cap_net_bind_service=+ep cap_net_admin=+ep' /usr/lib/v2ray/v2ray +} + +post_remove() { + echo 'Revoking Capabilities from V2Ray Core...' + /usr/bin/setcap 'cap_net_bind_service=-ep cap_net_admin=-ep' /usr/lib/v2ray/v2ray +} diff --git a/v2ray.service b/v2ray.service deleted file mode 100644 index 0059aaec87e9..000000000000 --- a/v2ray.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=V2Ray Service -After=network.target -Wants=network.target - -[Service] -Type=simple -PIDFile=/var/run/v2ray-%i.pid -ExecStart=/usr/bin/env V2RAY_VMESS_PADDING=1 v2ray.location.asset=/etc/v2ray /usr/bin/v2ray -config /etc/v2ray/%i.json -Restart=on-failure - -[Install] -WantedBy=multi-user.target |