-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
DnsTube is not able to get the current IPv6. #63
Comments
Had to delete the .db file and reinstall |
@sushantshah-dev I don't use IPv6 so have never been able to actually test it. What API endpoint are you using to get your address and what does it return? |
It's the default. When hitting the endpoint manually, I do actually see my IPv6... I am behind a CGNAT, so the IPv4 is shared by a huge number of networks, but IPv6 is provided to individual networks (still shared by the devices). That's why I am forced to use IPv6. However, deleting the db file fixed it for me. |
I ran into this issue as well, i am in the same situation as sushantshah-dev as far as needing ipv6 because of CGNAT. When i first installed the service it worked perfectly. Then after some time of running the service stopped and when i restarted it, it could no longer detect i had an ipv6 address. I had to delete the db file as sushantshah described (thank you) to get it back up and running, however this did mean i needed to re enter all of my credentials. I am currently using the default https://api64.ipify.org/ as an IPv6 API I will move over to http://checkip6.spdyn.de and see if the issue re appears |
Beware! I ran into this once again... You should probably set up another service or something like that to first backup the db file right after creation, and restore it every 12 hours. |
Thanks for the updates. I have not experienced anything like this with IPv4 and unfortunately am unable to test IPv6. The best way to resolve this would be to compare the difference in the db when it's non-functional vs. functional. If you are comfortable with it, please do the following the next time you experience this issue before deleting the db file:
|
Here are the log outputs if it is helpful. at 2023-11-15 10:56:57 i switched to the default ipv6 api to see if that makes a difference and it gave a different error. EDIT: I forgot to delete and restart, sorry. Soit doesnt look like the DnsTube.db updates when you update the webui instead i see an updated "date modified" on a file called DnsTube.db-wal . the service works after restarting but the DnsTube.db is empty even after clicking save in the settings page. |
I have an idea what is going on here and I expect it is just an intermittent external API issue. I'm going to try to make things more robust and will have a new release for this soon. |
@jamesxsc I don't think so. I'm guessing you're on an older version of Windows? The fix for this is usually to choose a different endpoint to get your public IP address. It's just a matter of finding one that will work with your version of Windows. |
Yeah this is on server 2012... will try and find another endpoint. |
@jamesxsc A quick workaround is to not use SSL, e.g., change the API end point to |
You should add a options that collect real ipv6 |
It seems to be stable if i never change settings after first putting them in. I think one time i just selected a network interface or checked a box next to which hostname to update and it broke the config after some time. Just wanted to offer another data point. |
I've narrowed down the error of being some sort of cache of the httpclient see: https://stackoverflow.com/questions/53408781/system-net-http-httpclient-disable-caching-net-standart-project it is returning the ipv4 address when I select IPV6 only. I've did what the post suggested and the problem was solved, i.e. replaced line 34 with var httpClient = new HttpClient(); Now everything seems to work fine. |
Tryed to solve in a more elegant way, please take a look into it if you will. |
Closed by #66. Thanks @fbordignon. |
@drittich thanks for the review but unfortunately the issue returned. I believe that it was because I was messing with my router's ipv6 config, the dnstube process lost ipv6 connectivity and defaulted to ipv4. When you access the default api64.ipfy.org without ipv6 connectivity, it returns your ipv4 and it messes with the config and/or the state of the http client. if (protocol == IpSupport.IPv4){
httpClient = _httpClientFactory.CreateClient(HttpClientName.IpAddress.ToString());
}
else
{
httpClient = new HttpClient(new SocketsHttpHandler()
{
ConnectCallback = async (context, cancellationToken) =>
{
// Use DNS to look up the IP addresses of the target host:
// - IP v4: AddressFamily.InterNetwork
// - IP v6: AddressFamily.InterNetworkV6
// - IP v4 or IP v6: AddressFamily.Unspecified
// note: this method throws a SocketException when there is no IP address for the host
var entry = await Dns.GetHostEntryAsync(context.DnsEndPoint.Host, AddressFamily.InterNetworkV6, cancellationToken);
// Open the connection to the target host/port
var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
// Turn off Nagle's algorithm since it degrades performance in most HttpClient scenarios.
socket.NoDelay = true;
try
{
await socket.ConnectAsync(entry.AddressList, context.DnsEndPoint.Port, cancellationToken);
// If you want to choose a specific IP address to connect to the server
// await socket.ConnectAsync(
// entry.AddressList[Random.Shared.Next(0, entry.AddressList.Length)],
// context.DnsEndPoint.Port, cancellationToken);
// Return the NetworkStream to the caller
return new NetworkStream(socket, ownsSocket: true);
}
catch
{
socket.Dispose();
throw;
}
}
});
} |
Sorry, initially pushed a commit with HttpClientName.IpAddress instead of HttpClientName.IpAddressV4. Fixed it, compiled and it should be fine. I guess the elegant solution would implement IHttpClientFactory with this method for ipv6, but no time or patience for that 😅 sorry. |
Another attempted fix released as beta here: https://github.com/drittich/DnsTube/releases/tag/v2.6.0-beta |
2023-11-14 05:00:46 | Cloudflare API error: Content for AAAA record must be a valid IPv6 address. | Error
2023-11-14 05:00:41 | Current public IPv6 address: | Information
DnsTube is not able to get the current IPv6.
The text was updated successfully, but these errors were encountered: