-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add country data to display of service nodes. #9
base: master
Are you sure you want to change the base?
Conversation
d591ea7
to
7bc6123
Compare
To enable: ``` $ sudo apt install python3-geoip2 # or: 'pip install geoip2' for the latest $ sudo apt install geoipupdate ``` If necessary, sign up for an account with MaxMind: https://www.maxmind.com/en/geolite2/signup Edit `/etc/GeoIP.conf` with the details of your MaxMind account: ``` AccountID 123456 LicenseKey xxxxxxxxxxxxxxxx EditionIDs GeoLite2-City GeoLite2-ASN ``` Edit `/etc/cron.d/geoipupdate`: ``` # MaxMind database updates take place on Tuesdays and Fridays. # 00 12 * * 2,5 root test -x /usr/bin/geoipupdate && grep -q '^AccountID .*[^0]\+' /etc/GeoIP.conf && /usr/bin/geoipupdate ``` Edit `./local_config.py`: ``` config.geoip_dir = '/var/lib/GeoIP' ```
Flag images are sourced from here: https://flaglog.com/country-codes Placing the flags in a subdirectory of `./static` for good housekeeping requires a change to the location matching of the `nginx` configuration; otherwise they will not be found. Change: ``` location ~ /(?![^/]*\.(?:css|js|png|html)(?:$|\?)) { ``` to: ``` location ~ /(?!([^/]*|flags/[^/]*)\.(?:css|js|png|html)(?:$|\?)) { ```
suggestion, also provide systemd timer for updating geoip db. |
This would be a lot simpler if it used unicode flag sequences instead of needing to serve all the PNGs. These are pretty simple to construct -- you just write the two-letter country code using regional letter sequences instead of normal letters, and it gets rendered as a flag: regional_indicators = {'a': '🇦', 'b': '🇧', 'c': '🇨', 'd': '🇩', 'e': '🇪', 'f': '🇫', 'g': '🇬', 'h': '🇭', 'i': '🇮', 'j': '🇯', 'k': '🇰', 'l': '🇱', 'm': '🇲', 'n': '🇳', 'o': '🇴', 'p': '🇵', 'q': '🇶', 'r': '🇷', 's': '🇸', 't': '🇹', 'u': '🇺', 'v': '🇻', 'w': '🇼', 'x': '🇽', 'y': '🇾', 'z': '🇿'}
# Or if you prefer, something like:
regional_indicators = { chr(ord('a') + i): chr(ord('🇦') + i) for i in range(0, 26) }
def flag(cc):
return ''.join(regional_indicators[c] for c in cc) >>> flag('ca')
'🇨🇦' |
That would have been the obvious way to do it, were it not that Windows 10/11 won't render flag characters by design: |
A much better explanation of the problems with flag emoji can be found here: |
To enable:
If necessary, sign up for an account with MaxMind:
https://www.maxmind.com/en/geolite2/signup
Edit
/etc/GeoIP.conf
with the details of your MaxMind account:Edit
/etc/cron.d/geoipupdate
:Edit
./local_config.py
:Main page:
Service node detail page: