Skip to content
/ extip Public

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

License

Notifications You must be signed in to change notification settings

skubota/extip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

License

Stars

Watchers

Forks

Packages

No packages published

Languages