Skip to content
skubotaPublic

About

extip returns the public facing IPv4 or IPv6 address of the requesting client by querying servers at STUN

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Package extip is external IPv4 or IPv6 address check

GoDev Go

DESCRIPTION

extip returns the public facing IPv4 or IPv6 address of the requesting client by querying servers at STUN

usage

$ go get github.com/skubota/extip

package extip

https://pkg.go.dev/github.com/skubota/extip

package main

import (
	"fmt"
	"github.com/skubota/extip"
)

func main() {
	// Any
	addr,err := extip.GetIP()
	if err != nil {
		fmt.Errorf("Address cannot get : %s\n", err)
	}else{
		fmt.Printf("Adress : %s\n",addr) 
	}


	// IPv4
	ipv4,err := extip.GetIP4()
	if err != nil {
		fmt.Errorf("IPv4 address cannot get : %s\n", err)
	}else{
		fmt.Printf("IPv4 address : %s\n", ipv4)
	}

	// IPv6
	ipv6,err := extip.GetIP6()
	if err != nil {
		fmt.Errorf("IPv6 address cannot get : %s\n", err)
	}else{
		fmt.Printf("IPv6 address : %s\n", ipv6)
	}
}

About

extip returns the public facing IPv4 or IPv6 address of the requesting client by querying servers at STUN

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages