Browse Source

Merge pull request #10624 from G-M0N3Y-2503/feature_cache_domains_order_fix

cache-domains: Changed to hotplug script
lilik-openwrt-22.03
Dirk Brenken 5 years ago
committed by GitHub
parent
commit
63c000a31a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 15 deletions
  1. +7
    -4
      utils/cache-domains/Makefile
  2. +3
    -3
      utils/cache-domains/README.md
  3. +8
    -0
      utils/cache-domains/files/30-cache-domains
  4. +18
    -8
      utils/cache-domains/files/cache-domains

+ 7
- 4
utils/cache-domains/Makefile View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=cache-domains
PKG_VERSION:=1.0.0
PKG_VERSION:=2.0.0
PKG_RELEASE:=1
PKG_MAINTAINER:=Gerard Ryan <G.M0N3Y.2503@gmail.com>
@ -17,13 +17,16 @@ define Package/cache-domains/default
endef
define Package/cache-domains/description/default
Service to dynamically configure the local DNS (dnsmasq) to redirect game content servers to a LAN cache.
hotplug script to dynamically configure the local DNS (dnsmasq) to redirect game content servers to a LAN cache.
Definitive list dynamically obtained from https://github.com/uklans/cache-domains.
endef
define Package/cache-domains/install/default
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/cache-domains.init $(1)/etc/init.d/cache-domains
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./files/cache-domains $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface/
$(INSTALL_BIN) ./files/30-cache-domains $(1)/etc/hotplug.d/iface/
endef
Build/Compile=# Nothing to compile, just install the scripts


+ 3
- 3
utils/cache-domains/README.md View File

@ -1,6 +1,6 @@
# cache-domains
Service to dynamically configure the local DNS (dnsmasq) to redirect game content servers to a LAN cache. Definitive list dynamically obtained from https://github.com/uklans/cache-domains.
hotplug script to dynamically configure the local DNS (dnsmasq) to redirect game content servers to a LAN cache. Definitive list dynamically obtained from https://github.com/uklans/cache-domains.
## Configuration
Configuration file follows the same [syntax as the upsteam file](https://github.com/uklans/cache-domains/blob/master/scripts/config.example.json). The key for each `cache_domain` member matches the name of one of the `.txt` files in the [upstream root directory](https://github.com/uklans/cache-domains/blob/master/), except for the `default` key which matches the all the unreferenced `.txt` files. The value of each `cache_domain` member maps to one of the keys of the `ips` members, Thus mapping a cached domain to a list of IP addresses/LAN cache server.
@ -23,8 +23,8 @@ Configuration file follows the same [syntax as the upsteam file](https://github.
}
```
## Startup/Shutdown
On start the local DNS (dnsmasq) will be configured to redirect the configured cache domains and on stop the redirection will be removed.
## Configure/Cleanup
`/usr/bin/cache-domains configure` will configure the local DNS (dnsmasq) to redirect the configured cache domains. `/usr/bin/cache-domains cleanup` will cleanup redirection. The hotplug script calls `/usr/bin/cache-domains configure` when the WAN interface is brought up.
## Testing
With the above configuration set and the service running `nslookup swcdn.apple.com` would return `10.10.3.12`

+ 8
- 0
utils/cache-domains/files/30-cache-domains View File

@ -0,0 +1,8 @@
#!/bin/sh
source /lib/functions/network.sh
network_find_wan WAN_IFACE
if [ "${ACTION}" == "ifup" ] && [ "${INTERFACE}" == "${WAN_IFACE}" ] && [ ! -d /var/cache-domains ]; then
/usr/bin/cache-domains configure
fi

utils/cache-domains/files/cache-domains.init → utils/cache-domains/files/cache-domains View File


Loading…
Cancel
Save