WiiLink24 / room-server

A backend for Wii no Ma.
MIT License
28 stars 13 forks source link

Handle user time #30

Closed spotlightishere closed 3 years ago

spotlightishere commented 3 years ago

It's been discussed to use the user's time within Wii no Ma. For reference, currently we obtain the current time in UTC:

<RegionInfo>
  <ver>399</ver>
  <sdt>2021-01-23T16:35:21</sdt>
  <cdt>2021-01-23T16:35:21</cdt>
  <limited>0</limited>
</RegionInfo>

sdt is server time, and cdt is the time parsed to present to the user on startup and for environmental usage. (Presumably server time would be UTC and cdt would permanently be JST.)

Theoretically, we could obtain the user's time somehow and present this back to them. This may involve modding our next distribution to send the console's current time, or doing GeoIP wizardry.

This leaves a few questions:

and lastly, stemming from the above:

spotlightishere commented 3 years ago

Ah, thanks for the suggestion! It looks like this uses the MaxMind databases internally - we'd probably want to explicitly state a version somehow and figure out a way to keep this up to date (perhaps Dependabot could assist?) Additionally, we'll have to provide X-Forwarded-For or similar within the nginx containers which is completely doable - will have to tinker with the default configuration there so we aren't logging IPs.

zurgeg commented 3 years ago

@spotlightishere For the question of what CDT is used for: SDT is used internally in XML files, e.x., to say "Hey, x movie expires at this time" to prevent region mixing mess ups with end dates. This, along with the fact that is even will check and try to load HCCE (SPD for U version consoles) hints at a possible international release.

CDT is used to display to the user localized time, so it can be offset. E.x., if CDT is offset from SDT by 2 hours. then the displayed end time for a movie rental will be enddt offset by 2 hours

Hope this cleared things up ^^)

EDIT: Additionally, while browsing through SO, I found a simple way to get GeoIP stuff that prevents logging locations:

import urllib

response = urllib.urlopen('http://api.hostip.info/get_html.php?ip=<ip>').read()

print(response)
zurgeg commented 3 years ago

Just found this, which should work for our purposes as it gets the timezone, one trick to enhance user privacy is to do something like (psuedo-code):

timezone = get_timezone()['timezone']

which, while we are still getting user location info, makes it inaccessible by us unless we explicitly try to.

spotlightishere commented 3 years ago

Definitely would be preferable! That's quite an old DB however - we should have users optionally provide their own DB from MaxMind, and return UTC if the database isn't present to be queried.

zurgeg commented 3 years ago

Check the timezone branch, I've tried an approach to doing user time, also forgot to update config defaults, whoops.