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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| #!/bin/sh
AUTH='' DOMAIN='' RECORD_NAME=''
IP4P=${3}
ZONE=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=${DOMAIN}" \ -H "Authorization: Bearer ${AUTH}" \ -H "Content-Type: application/json" | jq -r '.result[0].id')
RECORD=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records?type=A&name=${RECORD_NAME}" \ -H "Authorization: Bearer ${AUTH}" \ -H "Content-Type: application/json" | jq -r .result[0].id)
while true; do curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records/${RECORD}" \ -H "Authorization: Bearer ${AUTH}" \ -H "Content-Type:application/json" \ --data "{\"type\":\"AAAA\",\"name\":\"${RECORD_NAME}\",\"content\":\"${IP4P}\",\"ttl\":60,\"proxied\":false}" > /dev/null 2> /dev/null if [ $? -eq 0 ]; then break fi done
rule_name="natmap" dest_port="${4}" if ! uci show firewall | grep -q "${rule_name}"; then uci add firewall rule uci set firewall.@rule[-1].name="${rule_name}" uci set firewall.@rule[-1].target='ACCEPT' uci set firewall.@rule[-1].src='wan' uci set firewall.@rule[-1].family='ipv4' uci set firewall.@rule[-1].dest_port="${dest_port}"
uci commit firewall /etc/init.d/firewall reload else rule_num=$(uci show firewall | grep ${rule_name} | awk -F'[][]' '{print $2}') uci set firewall.@rule[${rule_num}].dest_port="${dest_port}"
uci commit firewall /etc/init.d/firewall reload fi
curl --location --request PATCH 'http://192.168.1.100:3001/aaa/api/sub/natmap' \ --header 'Content-Type: application/json' \ --data '{ "name": "natmap", "displayName": "", "mergeSources": "", "ignoreFailedRemoteSub": false, "icon": "", "process": [ { "type": "Quick Setting Operator", "args": { "useless": "DISABLED", "udp": "DEFAULT", "scert": "DEFAULT", "tfo": "DEFAULT", "vmess aead": "DEFAULT" } } ], "source": "local", "url": "", "content": "home_ss_v4 = Shadowsocks,'"${1}"','"${2}"',aes-128-gcm,\"<uuid>\",fast-open=false,udp=true", "ua": "", "display-name": "" }'
curl --location --request PUT 'https://<domain>/?token=aaa&key=bbb' \ --header 'Content-Type: application/json' \ --data '{ "ip": "'"${1}"'", "port": "'"${2}"'" }'
curl https://api.day.app/<barkToken>/nat穿透信息已更改/${1}:${2}%0a${3}
|