diff options
author | midnightix | 2021-12-19 23:31:06 +0800 |
---|---|---|
committer | midnightix | 2021-12-19 23:31:06 +0800 |
commit | 8ee90f2f1ba0205cca02d00962501e20502cc6b8 (patch) | |
tree | 4687267f9b5d5b1eaae8da685022f7e8fbf3bb3f | |
download | aur-8ee90f2f1ba0205cca02d00962501e20502cc6b8.tar.gz |
create package
-rw-r--r-- | .SRCINFO | 23 | ||||
-rw-r--r-- | PKGBUILD | 38 | ||||
-rw-r--r-- | arch.patch | 51 | ||||
-rw-r--r-- | clash-premium-script.install | 27 | ||||
-rw-r--r-- | config.yaml | 61 |
5 files changed, 200 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..f67669a26f60 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,23 @@ +pkgbase = clash-premium-script + pkgdesc = Simple clash premium core script for Linux. + pkgver = r11.e729951 + pkgrel = 1 + url = https://github.com/Kr328/clash-premium-installer + install = clash-premium-script.install + arch = any + license = unknown + makedepends = git + depends = clash-premium-bin + depends = systemd + depends = nftables + depends = iproute2 + backup = etc/clash/config.yaml + backup = etc/default/clash + source = git+https://github.com/Kr328/clash-premium-installer.git#commit=e729951 + source = arch.patch + source = config.yaml + sha256sums = SKIP + sha256sums = b12839b50154a1ff31fa6aa2e9de482ddd9a2bcd45a83bed0fae11549d479646 + sha256sums = 1938bc7544f8e33a6e41636f45e87a17de2eac0ca14f47c2f7a71c3c87341bf0 + +pkgname = clash-premium-script diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..e131f030fef5 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,38 @@ +# Maintainer: midnightix <midnightix@protonmail.com> + +pkgname=clash-premium-script +pkgver=r11.e729951 +pkgrel=1 +pkgdesc="Simple clash premium core script for Linux." +arch=('any') +url="https://github.com/Kr328/clash-premium-installer" +license=('unknown') +install=${pkgname}.install +depends=('clash-premium-bin' 'systemd' 'nftables' 'iproute2') +makedepends=('git') +backup=("etc/clash/config.yaml" "etc/default/clash") +source=("git+https://github.com/Kr328/clash-premium-installer.git#commit=e729951" + "arch.patch" + "config.yaml") +sha256sums=('SKIP' + 'b12839b50154a1ff31fa6aa2e9de482ddd9a2bcd45a83bed0fae11549d479646' + '1938bc7544f8e33a6e41636f45e87a17de2eac0ca14f47c2f7a71c3c87341bf0') + +prepare() { + cd "${srcdir}"/clash-premium-installer/ + git apply ../arch.patch +} + +package() { + cd "${srcdir}" + install -Dm 644 config.yaml "${pkgdir}"/etc/clash/config.yaml + cd "${srcdir}"/clash-premium-installer/scripts + install -Dm 644 clash-default "${pkgdir}"/etc/default/clash + install -Dm 755 bypass-proxy-pid "${pkgdir}"/usr/share/clash/bypass-proxy-pid + install -Dm 755 bypass-proxy "${pkgdir}"/usr/share/clash/bypass-proxy + install -Dm 700 clean-tun.sh "${pkgdir}"/usr/share/clash/clean-tun.sh + install -Dm 700 setup-tun.sh "${pkgdir}"/usr/share/clash/setup-tun.sh + install -Dm 700 setup-cgroup.sh "${pkgdir}"/usr/share/clash/setup-cgroup.sh + install -Dm 644 99-clash.rules "${pkgdir}"/usr/lib/udev/rules.d/99-clash.rules + install -Dm 644 clash.service "${pkgdir}"/usr/lib/systemd/system/clash.service +} diff --git a/arch.patch b/arch.patch new file mode 100644 index 000000000000..023d7514daed --- /dev/null +++ b/arch.patch @@ -0,0 +1,51 @@ +diff --git a/scripts/99-clash.rules b/scripts/99-clash.rules +index a73d507..9d77338 100644 +--- a/scripts/99-clash.rules ++++ b/scripts/99-clash.rules +@@ -1,2 +1,2 @@ +-SUBSYSTEM=="net",ENV{INTERFACE}=="utun",ACTION=="add",RUN+="/usr/lib/clash/setup-tun.sh" +-SUBSYSTEM=="net",ENV{INTERFACE}=="utun",ACTION=="remove",RUN+="/usr/lib/clash/clean-tun.sh" ++SUBSYSTEM=="net",ENV{INTERFACE}=="utun",ACTION=="add",RUN+="/usr/share/clash/setup-tun.sh" ++SUBSYSTEM=="net",ENV{INTERFACE}=="utun",ACTION=="remove",RUN+="/usr/share/clash/clean-tun.sh" +diff --git a/scripts/bypass-proxy b/scripts/bypass-proxy +index 606c4f1..cab10be 100755 +--- a/scripts/bypass-proxy ++++ b/scripts/bypass-proxy +@@ -1,5 +1,5 @@ + #!/bin/bash + +-bypass-proxy-pid $$ 2>&1 > /dev/null ++/usr/share/clash/bypass-proxy-pid $$ 2>&1 > /dev/null + + exec "$@" +diff --git a/scripts/clash-default b/scripts/clash-default +index eca38ad..82a78dc 100644 +--- a/scripts/clash-default ++++ b/scripts/clash-default +@@ -10,6 +10,6 @@ NETFILTER_MARK=114514 + IPROUTE2_TABLE_ID=114 + + # dns redirect +-FORWARD_DNS_REDIRECT=1.0.0.1:53 ++FORWARD_DNS_REDIRECT=198.18.0.2:53 + + +diff --git a/scripts/clash.service b/scripts/clash.service +index 552e56c..494069a 100644 +--- a/scripts/clash.service ++++ b/scripts/clash.service +@@ -1,11 +1,11 @@ + [Unit] + Description=A rule based proxy tunnel +-After=network-online.target nftables.service iptabels.service ++After=network-online.target nftables.service + + [Service] + Type=simple +-ExecStartPre=+/usr/lib/clash/setup-cgroup.sh +-ExecStart=/usr/bin/bypass-proxy /usr/bin/clash -d /srv/clash ++ExecStartPre=+/usr/share/clash/setup-cgroup.sh ++ExecStart=/usr/share/clash/bypass-proxy /usr/bin/clash -d /etc/clash + + [Install] + WantedBy=multi-user.target diff --git a/clash-premium-script.install b/clash-premium-script.install new file mode 100644 index 000000000000..e070bc31197b --- /dev/null +++ b/clash-premium-script.install @@ -0,0 +1,27 @@ +post_install() { + systemctl daemon-reload + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + echo "+ Install successfully +" + echo "+ +" + echo "+ Home directory at /etc/clash +" + echo "+ +" + echo "+ All dns traffic will be redirected to 198.18.0.2:53 +" + echo "+ Please use clash core's 'tun.dns-hijack' to handle it +" + echo "+ +" + echo "+ Use 'systemctl start clash' to start +" + echo "+ Use 'systemctl enable clash' to enable auto-restart on boot +" + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" +} + +post_upgrade() { + systemctl daemon-reload + systemctl restart clash +} + +pre_remove() { + systemctl disable --now clash +} + +post_remove() { + systemctl daemon-reload +} diff --git a/config.yaml b/config.yaml new file mode 100644 index 000000000000..ff049be01a16 --- /dev/null +++ b/config.yaml @@ -0,0 +1,61 @@ +dns: + enable: true + # listen: 0.0.0.0:53 + # ipv6: false # when the false, response to AAAA questions will be empty + + # These nameservers are used to resolve the DNS nameserver hostnames below. + # Specify IP addresses only + default-nameserver: + - 114.114.114.114 + - 8.8.8.8 + enhanced-mode: redir-host # or fake-ip + # fake-ip-range: 198.18.0.1/16 # Fake IP addresses pool CIDR + # use-hosts: true # lookup hosts and return IP record + + # Hostnames in this list will not be resolved with fake IPs + # i.e. questions to these domain names will always be answered with their + # real IP addresses + # fake-ip-filter: + # - '*.lan' + # - localhost.ptlogin2.qq.com + + # Supports UDP, TCP, DoT, DoH. You can specify the port to connect to. + # All DNS questions are sent directly to the nameserver, without proxies + # involved. Clash answers the DNS question with the first result gathered. + nameserver: + - 114.114.114.114 # default value + - 8.8.8.8 # default value + - tls://dns.rubyfish.cn:853 # DNS over TLS + - https://1.1.1.1/dns-query # DNS over HTTPS + + # When `fallback` is present, the DNS server will send concurrent requests + # to the servers in this section along with servers in `nameservers`. + # The answers from fallback servers are used when the GEOIP country + # is not `CN`. + # fallback: + # - tcp://1.1.1.1 + + # If IP addresses resolved with servers in `nameservers` are in the specified + # subnets below, they are considered invalid and results from `fallback` + # servers are used instead. + # + # IP address resolved with servers in `nameserver` is used when + # `fallback-filter.geoip` is true and when GEOIP of the IP address is `CN`. + # + # If `fallback-filter.geoip` is false, results from `nameserver` nameservers + # are always used if not match `fallback-filter.ipcidr`. + # + # This is a countermeasure against DNS pollution attacks. + fallback-filter: + geoip: true + ipcidr: + # - 240.0.0.0/4 + # domain: + # - '+.google.com' + # - '+.facebook.com' + # - '+.youtube.com' +tun: + enable: true + stack: system # or gvisor + dns-hijack: + - 198.18.0.2:53 # when `fake-ip-range` is 198.18.0.1/16, should hijack 198.18.0.2:53 |