-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnameserver
More file actions
65 lines (61 loc) · 2.26 KB
/
nameserver
File metadata and controls
65 lines (61 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
REPOS="https://github.com/SETANTAZVPN/abc/raw/ipuk/"
ns_domain_cloudflare() {
DOMAIN="vpnshop.my.id"
DOMAIN_PATH=$(cat /etc/xray/domain)
SUB=$(tr </dev/urandom -dc a-z0-9 | head -c7)
SUB_DOMAIN=${SUB}."vpnshop.my.id"
NS_DOMAIN=ns.${SUB_DOMAIN}
CF_ID=bayuagungriadi000@gmail.com
CF_KEY=1fe3862ce9cdc01cfc82d1fb8556d64755842
set -euo pipefail
IP=$(wget -qO- ipinfo.io/ip)
echo "Updating DNS NS for ${NS_DOMAIN}..."
ZONE=$(
curl -sLX GET "https://api.cloudflare.com/client/v4/zones?name=${DOMAIN}&status=active" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" | jq -r .result[0].id
)
RECORD=$(
curl -sLX GET "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records?name=${NS_DOMAIN}" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" | jq -r .result[0].id
)
if [[ "${#RECORD}" -le 10 ]]; then
RECORD=$(
curl -sLX POST "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" \
--data '{"type":"NS","name":"'${NS_DOMAIN}'","content":"'${DOMAIN_PATH}'","proxied":false}' | jq -r .result.id
)
fi
RESULT=$(
curl -sLX PUT "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records/${RECORD}" \
-H "X-Auth-Email: ${CF_ID}" \
-H "X-Auth-Key: ${CF_KEY}" \
-H "Content-Type: application/json" \
--data '{"type":"NS","name":"'${NS_DOMAIN}'","content":"'${DOMAIN_PATH}'","proxied":false}'
)
echo $NS_DOMAIN >/etc/xray/dns
}
setup_dnstt() {
cd
rm -rf *
mkdir -p /etc/slowdns
wget -O dnstt-server "${REPOS}slowdns/dnstt-server" >/dev/null 2>&1
chmod +x dnstt-server >/dev/null 2>&1
wget -O dnstt-client "${REPOS}slowdns/dnstt-client" >/dev/null 2>&1
chmod +x dnstt-client >/dev/null 2>&1
./dnstt-server -gen-key -privkey-file server.key -pubkey-file server.pub
chmod +x *
mv * /etc/slowdns
wget -O /etc/systemd/system/client.service "${REPOS}slowdns/client" >/dev/null 2>&1
wget -O /etc/systemd/system/server.service "${REPOS}slowdns/server" >/dev/null 2>&1
sed -i "s/xxxx/$NS_DOMAIN/g" /etc/systemd/system/client.service
sed -i "s/xxxx/$NS_DOMAIN/g" /etc/systemd/system/server.service
}
ns_domain_cloudflare
setup_dnstt