Skip to content

🚥 Port mapping library for Go supporting NAT-PMP and UPnP

Notifications You must be signed in to change notification settings

hlandau/portmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAT Port Mapping Library for Go

godocs.io Build status

Example:

import "github.com/hlandau/portmap"
import "fmt"

func Example() {
  m, err := portmap.New(portmap.Config{
    Protocol:     portmap.TCP,
    Name:         "http",
    InternalPort:  80,
    ExternalPort:  80,
  })
  if err != nil {
    // ...
  }

  for {
    // mapping may change over time
    <-m.NotifyChan()
    fmt.Printf("Current mapped address is: %s\n", m.ExternalAddr())
  }

  // mapping will be renewed automatically
  // call m.Delete() when mapping should be torn down
}

About

🚥 Port mapping library for Go supporting NAT-PMP and UPnP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages