Feature request: determine if ipv4 and/or ipv6 should be updated #107

Open
opened 2025-11-20 04:20:22 -05:00 by saavagebueno · 3 comments
Owner

Originally created by @qdm12 on GitHub (Mar 21, 2021).

Originally assigned to: @qdm12 on GitHub.

  • Automatically detect if the machine supports ipv4 and/or ipv6 and depending on that gets its public IP address.
  • Update records with ipv4 and/or ipv6 depending on the result above
  • Remove the ip_version parameter

The following can be used to detect ip version stacks supported:

func ipVersionsSupported(ctx context.Context) (ipv4, ipv6 bool) {
	dialer := &net.Dialer{}
	_, err := dialer.DialContext(ctx, "tcp4", "127.0.0.1:0")
	ipv4 = err.Error() == "dial tcp4 127.0.0.1:0: connect: connection refused"
	_, err = dialer.DialContext(ctx, "tcp6", "[::1]:0")
	ipv6 = err.Error() == "dial tcp6 [::1]:0: connect: connection refused"
	return ipv4, ipv6
}
Originally created by @qdm12 on GitHub (Mar 21, 2021). Originally assigned to: @qdm12 on GitHub. - Automatically detect if the machine supports ipv4 and/or ipv6 and depending on that gets its public IP address. - Update records with ipv4 and/or ipv6 depending on the result above - Remove the `ip_version` parameter The following can be used to detect ip version stacks supported: ```go func ipVersionsSupported(ctx context.Context) (ipv4, ipv6 bool) { dialer := &net.Dialer{} _, err := dialer.DialContext(ctx, "tcp4", "127.0.0.1:0") ipv4 = err.Error() == "dial tcp4 127.0.0.1:0: connect: connection refused" _, err = dialer.DialContext(ctx, "tcp6", "[::1]:0") ipv6 = err.Error() == "dial tcp6 [::1]:0: connect: connection refused" return ipv4, ipv6 } ```
Author
Owner

@fredericrous commented on GitHub (May 18, 2021):

Maybe let the ip_version optional in case the docker container is listening on a IPv4 interface but the machine also has an IPv6? But maybe this case would be too rare? What do you think?

@fredericrous commented on GitHub (May 18, 2021): Maybe let the ip_version optional in case the docker container is listening on a IPv4 interface but the machine also has an IPv6? But maybe this case would be too rare? What do you think?
Author
Owner

@qdm12 commented on GitHub (May 18, 2021):

I.... need to test things more 😄 I don't have IPv6 enabled on my network... yet, although my ISP supports it so that's that I have to do.

If you have IPv6 (check for example here), can you try save the following as main.go

package main

import (
	"context"
	"fmt"
	"net"
)

func main() {
	ctx := context.Background()
	dialer := &net.Dialer{}
	_, err := dialer.DialContext(ctx, "tcp4", "127.0.0.1:0")
	ipv4 := err.Error() == "dial tcp4 127.0.0.1:0: connect: connection refused"
	fmt.Println("IPV4: ", ipv4)

	_, err = dialer.DialContext(ctx, "tcp6", "[::1]:0")
	ipv6 := err.Error() == "dial tcp6 [::1]:0: connect: connection refused"
	fmt.Println("IPV6: ", ipv6)
}

And run it with go run main.go on your host first? If you don't have IPv6, well we're both stuck for now 😄

@qdm12 commented on GitHub (May 18, 2021): I.... need to test things more 😄 I don't have IPv6 enabled on my network... yet, although my ISP supports it so that's that I have to do. If you have IPv6 (check for example [here](https://test-ipv6.com/)), can you try save the following as `main.go` ```go package main import ( "context" "fmt" "net" ) func main() { ctx := context.Background() dialer := &net.Dialer{} _, err := dialer.DialContext(ctx, "tcp4", "127.0.0.1:0") ipv4 := err.Error() == "dial tcp4 127.0.0.1:0: connect: connection refused" fmt.Println("IPV4: ", ipv4) _, err = dialer.DialContext(ctx, "tcp6", "[::1]:0") ipv6 := err.Error() == "dial tcp6 [::1]:0: connect: connection refused" fmt.Println("IPV6: ", ipv6) } ``` And run it with `go run main.go` on your host first? If you don't have IPv6, well we're both stuck for now 😄
Author
Owner

@tcurdt commented on GitHub (Sep 4, 2023):

These issues seem to overlap https://github.com/qdm12/ddns-updater/issues/507

@tcurdt commented on GitHub (Sep 4, 2023): These issues seem to overlap https://github.com/qdm12/ddns-updater/issues/507
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ddns-updater#107