block_analytics.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. analytics_servers=$(cat <<EOF
  3. # Honkai Impact 3rd analytics servers (glb/sea/tw/kr/jp):
  4. 0.0.0.0 log-upload-os.hoyoverse.com
  5. 0.0.0.0 sg-public-data-api.hoyoverse.com
  6. 0.0.0.0 dump.gamesafe.qq.com
  7. # Honkai Impact 3rd analytics servers (cn):
  8. 0.0.0.0 log-upload.mihoyo.com
  9. 0.0.0.0 public-data-api.mihoyo.com
  10. 0.0.0.0 dump.gamesafe.qq.com
  11. # Honkai Star Rail analytics servers (os)
  12. 0.0.0.0 log-upload-os.hoyoverse.com
  13. 0.0.0.0 sg-public-data-api.hoyoverse.com
  14. # Honkai Star Rail analytics servers (cn)
  15. 0.0.0.0 log-upload.mihoyo.com
  16. 0.0.0.0 public-data-api.mihoyo.com
  17. EOF
  18. )
  19. if [[ ! `cat /etc/hosts` == *"$analytics_servers"* ]]; then
  20. echo "Blocking analytics servers. This will require superuser privileges"
  21. echo "$analytics_servers" | pkexec tee -a /etc/hosts 2>&1 >> /dev/null
  22. if test $? -ne 0; then
  23. echo "Could not block analytics servers. Please add the following lines to your /etc/hosts manually:"
  24. echo "$analytics_servers"
  25. fi
  26. else
  27. echo "Analytics servers are already blocked"
  28. fi