-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ZoneTables feature to auto-distribute load over different servers…
… and ports (#73) * auto dns/port selection based on zone * add zone map * Update README.md * make use of zonetable persistent across all functions * make logging more consistent * cleanup * cleanup * made ImAlive more robust * add EU zones * improve zonetable to auto-extract zone names; add EU zones * Update README.md
- Loading branch information
Showing
6 changed files
with
300 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
#shellcheck shell=bash disable=SC2154 | ||
|
||
# associative array with the DNS, port, and boundary data for each zone. | ||
|
||
declare -A ZoneTable=( | ||
[EU001:name]="West-Portugal West-Spain" | ||
[EU001:dns]="mg22.adsbnetwork.com" | ||
[EU001:port]="50050" | ||
[EU001:max_lat]="43.5" | ||
[EU001:max_lon]="-7.5" | ||
[EU001:min_lat]="34.0" | ||
[EU001:min_lon]="-25.0" | ||
[EU002:name]="East-Portugal Spain South-France" | ||
[EU002:dns]="mg22.adsbnetwork.com" | ||
[EU002:port]="50050" | ||
[EU002:max_lat]="43.5" | ||
[EU002:max_lon]="10.0" | ||
[EU002:min_lat]="34.0" | ||
[EU002:min_lon]="-7.5" | ||
[EU003:name]="East-Mediterranean" | ||
[EU003:dns]="mg22.adsbnetwork.com" | ||
[EU003:port]="50050" | ||
[EU003:max_lat]="43.5" | ||
[EU003:max_lon]="27.5" | ||
[EU003:min_lat]="34.0" | ||
[EU003:min_lon]="10.0" | ||
[EU004:name]="Turkey Middle-East" | ||
[EU004:dns]="mg22.adsbnetwork.com" | ||
[EU004:port]="50050" | ||
[EU004:max_lat]="43.5" | ||
[EU004:max_lon]="45.0" | ||
[EU004:min_lat]="34.0" | ||
[EU004:min_lon]="27.5" | ||
[EU005:name]="Southwest-Ireland" | ||
[EU005:dns]="mg22.adsbnetwork.com" | ||
[EU005:port]="50050" | ||
[EU005:max_lat]="53.0" | ||
[EU005:max_lon]="-7.5" | ||
[EU005:min_lat]="43.5" | ||
[EU005:min_lon]="-25.0" | ||
[EU006:name]="Southwest Ireland France Benelux Western-Germany" | ||
[EU006:dns]="mg22.adsbnetwork.com" | ||
[EU006:port]="50050" | ||
[EU006:max_lat]="53.0" | ||
[EU006:max_lon]="10.0" | ||
[EU006:min_lat]="43.5" | ||
[EU006:min_lon]="-7.5" | ||
[EU007:name]="Eastern-Germany Mid-Eastern-Europe" | ||
[EU007:dns]="mg22.adsbnetwork.com" | ||
[EU007:port]="50050" | ||
[EU007:max_lat]="53.0" | ||
[EU007:max_lon]="27.5" | ||
[EU007:min_lat]="43.5" | ||
[EU007:min_lon]="10.0" | ||
[EU008:name]="Southeastern-Europe" | ||
[EU008:dns]="mg22.adsbnetwork.com" | ||
[EU008:port]="50050" | ||
[EU008:max_lat]="53.0" | ||
[EU008:max_lon]="45.0" | ||
[EU008:min_lat]="43.5" | ||
[EU008:min_lon]="27.5" | ||
[EU009:name]="Northwestern-Ireland" | ||
[EU009:dns]="mg22.adsbnetwork.com" | ||
[EU009:port]="50050" | ||
[EU009:max_lat]="62.5" | ||
[EU009:max_lon]="-7.5" | ||
[EU009:min_lat]="53.0" | ||
[EU009:min_lon]="-25.0" | ||
[EU010:name]="Great-Britain Northeastern-Ireland NorthSea-Countries" | ||
[EU010:dns]="mg22.adsbnetwork.com" | ||
[EU010:port]="50050" | ||
[EU010:max_lat]="62.5" | ||
[EU010:max_lon]="10.0" | ||
[EU010:min_lat]="53.0" | ||
[EU010:min_lon]="-7.5" | ||
[EU011:name]="BalticSea-Countries" | ||
[EU011:dns]="mg22.adsbnetwork.com" | ||
[EU011:port]="50050" | ||
[EU011:max_lat]="62.5" | ||
[EU011:max_lon]="27.5" | ||
[EU011:min_lat]="53.0" | ||
[EU011:min_lon]="10.0" | ||
[EU012:name]="Belarus Russia Eastern-Finland Eastern-Latvia" | ||
[EU012:dns]="mg22.adsbnetwork.com" | ||
[EU012:port]="50050" | ||
[EU012:max_lat]="62.5" | ||
[EU012:max_lon]="45.0" | ||
[EU012:min_lat]="53.0" | ||
[EU012:min_lon]="27.5" | ||
[EU013:name]="Iceland" | ||
[EU013:dns]="mg22.adsbnetwork.com" | ||
[EU013:port]="50050" | ||
[EU013:max_lat]="72.0" | ||
[EU013:max_lon]="-7.5" | ||
[EU013:min_lat]="62.5" | ||
[EU013:min_lon]="-25.0" | ||
[EU014:name]="Mid-Western-Norway" | ||
[EU014:dns]="mg22.adsbnetwork.com" | ||
[EU014:port]="50050" | ||
[EU014:max_lat]="72.0" | ||
[EU014:max_lon]="10.0" | ||
[EU014:min_lat]="62.5" | ||
[EU014:min_lon]="-7.5" | ||
[EU015:name]="Northern-Scandinavia Northern-Finland" | ||
[EU015:dns]="mg22.adsbnetwork.com" | ||
[EU015:port]="50050" | ||
[EU015:max_lat]="72.0" | ||
[EU015:max_lon]="27.5" | ||
[EU015:min_lat]="62.5" | ||
[EU015:min_lon]="10.0" | ||
[EU016:name]="Eastern-Finland Northwestern-Russia" | ||
[EU016:dns]="mg22.adsbnetwork.com" | ||
[EU016:port]="50050" | ||
[EU016:max_lat]="72.0" | ||
[EU016:max_lon]="45.0" | ||
[EU016:min_lat]="62.5" | ||
[EU016:min_lon]="27.5" | ||
[NA001:name]="SoCal" | ||
[NA001:dns]="mg21.adsbnetwork.com" | ||
[NA001:port]="50021" | ||
[NA001:max_lat]="34.3534155" | ||
[NA001:max_lon]="-117.1984944" | ||
[NA001:min_lat]="25.34440649" | ||
[NA001:min_lon]="-128.7677266" | ||
[NA002:dns]="mg21.adsbnetwork.com" | ||
[NA002:name]="AZ NM Baja nw-Mex" | ||
[NA002:port]="50031" | ||
[NA002:max_lat]="34.3534155" | ||
[NA002:max_lon]="-105.6292621" | ||
[NA002:min_lat]="25.34440649" | ||
[NA002:min_lon]="-117.1984944" | ||
[NA003:name]="se-NM TX se-OK sw-AR" | ||
[NA003:dns]="mg21.adsbnetwork.com" | ||
[NA003:port]="50033" | ||
[NA003:max_lat]="34.3534155" | ||
[NA003:max_lon]="-94.06002987" | ||
[NA003:min_lat]="25.34440649" | ||
[NA003:min_lon]="-105.6292621" | ||
[NA004:name]="so-AR LA MS AL FL GA" | ||
[NA004:dns]="mg21.adsbnetwork.com" | ||
[NA004:port]="50037" | ||
[NA004:max_lat]="34.3534155" | ||
[NA004:max_lon]="-85.13" | ||
[NA004:min_lat]="25.34440649" | ||
[NA004:min_lon]="-94.06002987" | ||
[NA005:name]="GA FL" | ||
[NA005:dns]="mg21.adsbnetwork.com" | ||
[NA005:port]="50039" | ||
[NA005:max_lat]="34.3534155" | ||
[NA005:max_lon]="-70.92156537" | ||
[NA005:min_lat]="24.5" | ||
[NA005:min_lon]="-85.13" | ||
[NA006:name]="CA NV OR" | ||
[NA006:dns]="mg21.adsbnetwork.com" | ||
[NA006:port]="50040" | ||
[NA006:max_lat]="43.3624245" | ||
[NA006:max_lon]="-117.1984944" | ||
[NA006:min_lat]="34.3534155" | ||
[NA006:min_lon]="-128.7677266" | ||
[NA007:name]="NV sw-CA UT CO AZ NM ID WY" | ||
[NA007:dns]="mg21.adsbnetwork.com" | ||
[NA007:port]="50041" | ||
[NA007:max_lat]="43.3624245" | ||
[NA007:max_lon]="-105.6292621" | ||
[NA007:min_lat]="34.3534155" | ||
[NA007:min_lon]="-117.1984944" | ||
[NA008:name]="WY SD IA CO KS MS NM no_TX OK we-AR" | ||
[NA008:dns]="mg21.adsbnetwork.com" | ||
[NA008:port]="50042" | ||
[NA008:max_lat]="43.3624245" | ||
[NA008:max_lon]="-94.06002987" | ||
[NA008:min_lat]="34.3534155" | ||
[NA008:min_lon]="-105.6292621" | ||
[NA009:name]="IA WI MI IL IN OH MS KY AR TN no-MS no-AL no-GA" | ||
[NA009:dns]="mg21.adsbnetwork.com" | ||
[NA009:port]="50043" | ||
[NA009:max_lat]="43.3624245" | ||
[NA009:max_lon]="-82.49079762" | ||
[NA009:min_lat]="34.3534155" | ||
[NA009:min_lon]="-94.06002987" | ||
[NA010:name]="mid-Atlantic south-NewEngland" | ||
[NA010:dns]="mg21.adsbnetwork.com" | ||
[NA010:port]="50044" | ||
[NA010:max_lat]="43.3624245" | ||
[NA010:max_lon]="-69.9" | ||
[NA010:min_lat]="34.3534155" | ||
[NA010:min_lon]="-82.49079762" | ||
[NA011:name]="Pac NW" | ||
[NA011:dns]="mg21.adsbnetwork.com" | ||
[NA011:port]="50045" | ||
[NA011:max_lat]="52.37143351" | ||
[NA011:max_lon]="-117.1984944" | ||
[NA011:min_lat]="43.3624245" | ||
[NA011:min_lon]="-128.7677266" | ||
[NA012:name]="ID MT WY east-BC AB SK" | ||
[NA012:dns]="mg21.adsbnetwork.com" | ||
[NA012:port]="50046" | ||
[NA012:max_lat]="52.37143351" | ||
[NA012:max_lon]="-105.6292621" | ||
[NA012:min_lat]="43.3624245" | ||
[NA012:min_lon]="-117.1984944" | ||
[NA013:name]="WY MT ND SD MN SK MB ON" | ||
[NA013:dns]="mg21.adsbnetwork.com" | ||
[NA013:port]="50048" | ||
[NA013:max_lat]="52.37143351" | ||
[NA013:max_lon]="-94.06002987" | ||
[NA013:min_lat]="43.3624245" | ||
[NA013:min_lon]="-105.6292621" | ||
[NA014:name]="MN WI MI ON" | ||
[NA014:dns]="mg21.adsbnetwork.com" | ||
[NA014:port]="50049" | ||
[NA014:max_lat]="52.37143351" | ||
[NA014:max_lon]="-82.49079762" | ||
[NA014:min_lat]="43.3624245" | ||
[NA014:min_lon]="-94.06002987" | ||
[NA015:name]="No-NewEngland East-Canada StPierreMiquelon" | ||
[NA015:dns]="mg21.adsbnetwork.com" | ||
[NA015:port]="50051" | ||
[NA015:max_lat]="52.37143351" | ||
[NA015:max_lon]="-52.432265" | ||
[NA015:min_lat]="43.3624245" | ||
[NA015:min_lon]="-82.49079762" | ||
[NA016:name]="Hawaii" | ||
[NA016:dns]="mg21.adsbnetwork.com" | ||
[NA016:port]="50039" | ||
[NA016:max_lat]="22.356682" | ||
[NA016:max_lon]="-154.539553" | ||
[NA016:min_lat]="18.809780" | ||
[NA016:min_lon]="-160.453822" | ||
[NA017:name]="Alaska" | ||
[NA017:dns]="mg21.adsbnetwork.com" | ||
[NA017:port]="50039" | ||
[NA017:max_lat]="71.5388" | ||
[NA017:max_lon]="-130" | ||
[NA017:min_lat]="51.2097" | ||
[NA017:min_lon]="-172" | ||
) | ||
|
||
declare -a ZoneNames=() | ||
for name in "${!ZoneTable[@]}"; do | ||
if [[ ! " ${ZoneNames[*]} " =~ " ${name:0:5} " ]]; then | ||
ZoneNames+=("${name:0:5}") | ||
fi | ||
done | ||
|
||
if [[ -n "$LON" ]] && [[ -n "$LAT" ]]; then | ||
for zone in "${ZoneNames[@]}"; do | ||
math_string="$LAT > ${ZoneTable[$zone:min_lat]} && " | ||
math_string+="$LAT <= ${ZoneTable[$zone:max_lat]} && " | ||
math_string+="$LON > ${ZoneTable[$zone:min_lon]} && " | ||
math_string+="$LON <= ${ZoneTable[$zone:max_lon]}" | ||
if [[ "$(bc -l <<< "$math_string")" == "1" ]]; then | ||
zone_name="${ZoneTable[$zone:name]}" | ||
zone_id="$zone" | ||
zone_dns="${ZoneTable[$zone:dns]}" | ||
zone_port="${ZoneTable[$zone:port]}" | ||
break | ||
fi | ||
done | ||
fi |