🚥 Port mapping library for Go supporting NAT-PMP and UPnP
Clone or download
hlandau Fix logging to be quiet by default
©! I, Hugo Landau <hlandau@devever.net>, hereby licence these changes under the
©! licence with SHA256 hash
©! fd80a26fbb3f644af1fa994134446702932968519797227e07a1368dea80f0bc.
Latest commit c22def2 Jun 27, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gateway
natpmp
ssdp
upnp
.travis.yml
README.md
extaddr.go
maploop.go Fix logging to be quiet by default Jun 27, 2017
portmap.go

README.md

NAT Port Mapping Library for Go

GoDoc 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
}