robertvazan / guerrillantp Goto Github PK
View Code? Open in Web Editor NEWSimple NTP (SNTP) client library providing .NET applications with accurate network time.
Home Page: https://guerrillantp.machinezoo.com/
License: Apache License 2.0
Simple NTP (SNTP) client library providing .NET applications with accurate network time.
Home Page: https://guerrillantp.machinezoo.com/
License: Apache License 2.0
I have a UWP application (a minimum target to uap10.0.19041
) that uses the 2.0.1 version targeted to netstandard2.0 but updating to the latest version 3.0.0
makes it incompatible with UWP apps
Passing in a time >= year 2037 to function:
void SetDateTime64(int offset, DateTime? value) { SetUInt64BE(offset, value == null ? 0 : Convert.ToUInt64((value.Value.Ticks - epoch.Ticks) * (0.0000001 * (1L << 32)))); }
causes the conversion to UInt64 to overflow.
Test Program:
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
DateTime EpochFuture = new DateTime(2037, 1, 1);
DateTime EpochPast = new DateTime(1900, 1, 1);
try
{
UInt64 Result = Convert.ToUInt64((EpochFuture.Ticks - EpochPast.Ticks) * (0.0000001 * (1L << 32)));
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
Output:
System.OverflowException: Arithmetic operation resulted in an overflow.
at System.Convert.ToUInt64(Double value)
at ConsoleApp1.Program.Main(String[] args) in MyProgram
Is there a timeframe you will be releasing async changes you have made?
Tested with GuerillaNtp v3.0.0 & .NET for macOS
Code:
var ntpClient = new NtpClient(NtpClient.DefaultEndpoint, TimeSpan.FromSeconds(0.001));
var clock = await ntpClient.QueryAsync().ConfigureAwait(false);
Expected behaviour:
OperationCanceledException
or similar Exception
Actual behaviour:
Timeout is ignored. QueryAsync
can be awaited for much longer, potentially indefinitely, without any exception being thrown.
The docs only mention that the synchronous Receive method might use this timeout.
https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.receivetimeout?view=net-7.0
There's also another Timeout, for synchronous Send methods, currently it doesn't seem to be used anywhere in this library: https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.sendtimeout?view=net-7.0
If this is expected behaviour, it should be explained in detail in the docs. It currently only says "Query timeout" which is pretty vague. I expected this to be a timeout for any method (async or synchronous) that I call on the NtpClient method (and not on the underlying socket). I think the timeout should be implemented differently, perhaps using a CancellationTokenSource
and CancelAfter
Is it possible to make secure/authenticated queries to an NTP server? I've read that SNTPv4 service is vulnerable.
This is not an issue but rather a feature request.
Tried in Unity 2021.3 and above that the version 3 didn't work. Downgraded to version 2 worked perfectly.
Just hope that this wonderful library can be used inside Unity editor.
Dear authors of GuerrillaNtp,
Are there any plans to support Network Time Security (NTS), as specified on RFC 8915 ?
I'm getting this error:
Error: System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (10014): The system detected an invalid pointer address in attempting to use a pointer argument in a call. [::ffff:194.117.47.42]:123
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at GuerrillaNtp.NtpClient.Connect()
at GuerrillaNtp.NtpClient.Query()
When using in a Azure App, running local don't throw error.
Code used
//NtpClient client = new NtpClient("ntp02.oal.ul.pt");
NtpClient client = new NtpClient(IPAddress.Parse("194.117.47.42"));
NtpClock clock = client.Query();
Any idea how to solve this?
Cheers
Jorge
Would you accept a PR that adds:
Thanks!
It would nice if you provide a version with a strong name.
Is there burst or iburst support as of now or in the development pipeline? I love this project thus far. Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.