Skip to content
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

If i change the time into the future,it will be fail #13

Open
LeoInLomrt opened this issue Nov 17, 2014 · 7 comments
Open

If i change the time into the future,it will be fail #13

LeoInLomrt opened this issue Nov 17, 2014 · 7 comments

Comments

@LeoInLomrt
Copy link

When i change the device time into the future,
the networkDate doing nothing.

@LeoInLomrt LeoInLomrt changed the title If i change the time to the feature,it will be fail If i change the time into the future,it will be fail Nov 17, 2014
@gavineadie
Copy link
Collaborator

I can verify that if the "device time" is set manually to a time in the future, the "network time" is incorrectly reported to be the same as the device time. I'll take a look at this, though the use case seems unlikely.

@jbenet
Copy link
Owner

jbenet commented Nov 17, 2014

though the use case seems unlikely.

Not so unlikely: the reason i first grabbed this lib was to prevent cheating from players in a game that required accurate time.

@gavineadie
Copy link
Collaborator

Good point! I'll raise my priority, and raise my suspicion levels !!

@gavineadie
Copy link
Collaborator

Found it.

One of the checks for whether a time server's time should be used or ignored is that the server's time should have been set during the previous hour. That hour is, incorrectly, measured from the client's time so if you advance the client's time by more than one hour, ALL the servers will treated as invalid because their last time setting cannot possible be less than one hour before the client's time.

This mistake has been in my code for ever. I will fix it in the next few days ..

@gavineadie
Copy link
Collaborator

This is fixed.

@gavineadie
Copy link
Collaborator

I want to restructure the way the library works. The "NetAssociation" class does too much work just now; not only does it bounce requests off a time server, it also manages the averaging of multiple time values that are returned. I would like to change this so that this class obtains one time value from one server, nothing more. This simple, function is not available in the present library which defeats a common use - quickly (~1 second) deriving a moderately accurate time.

The use of multiple time sources and multiple time samples from each source takes longer but provides more accurate time - it is commonly used in continuously running daemon or server implementations where the time required to select the most accurate servers from a pool and then consolidate their times is no hinderance. That sophisticated ability can be retained in the "NetworkClock" class where it would use the "NetAssociation" class to get the necessary samples.

Is this an improvement?

@warpling
Copy link

@gavineadie Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants