• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Go
  • License
    Other
  • Created about 10 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Go language client for the NAT-PMP internet protocol for port mapping and discovering the external IP address of a firewall.

go-nat-pmp

A Go language client for the NAT-PMP internet protocol for port mapping and discovering the external IP address of a firewall.

NAT-PMP is supported by Apple brand routers and open source routers like Tomato and DD-WRT.

See https://tools.ietf.org/rfc/rfc6886.txt

Build Status

Get the package

# Get the go-nat-pmp package.
go get -u github.com/jackpal/go-nat-pmp

Usage

Get one more package, used by the example code:

go get -u github.com/jackpal/gateway

Create a directory:

cd ~/go
mkdir -p src/hello
cd src/hello

Create a file hello.go with these contents:

package main

import (
    "fmt"

    "github.com/jackpal/gateway"
    natpmp "github.com/jackpal/go-nat-pmp"
)

func main() {
    gatewayIP, err := gateway.DiscoverGateway()
    if err != nil {
        return
    }

    client := natpmp.NewClient(gatewayIP)
    response, err := client.GetExternalAddress()
    if err != nil {
        return
    }
    fmt.Printf("External IP address: %v\n", response.ExternalIPAddress)
}

Build the example

go build
./hello

External IP address: [www xxx yyy zzz]

Clients

This library is used in the Taipei Torrent BitTorrent client http://github.com/jackpal/Taipei-Torrent

Complete documentation

http://godoc.org/github.com/jackpal/go-nat-pmp

License

This project is licensed under the Apache License 2.0.

More Repositories

1

Android-Terminal-Emulator

A VT-100 terminal emulator for the Android OS
Java
3,011
star
2

Taipei-Torrent

A(nother) Bittorrent client written in the go programming language
Go
844
star
3

bencode-go

A Go language binding for encodeing and decoding data in the bencode format that is used by the BitTorrent peer-to-peer file sharing protocol.
Go
251
star
4

gateway

A golang library for discovering the address of a LAN gateway.
Go
225
star
5

Dandy-Dungeon

A collection of implementations of a simple 2D dungeon crawling game
C#
76
star
6

picasawebuploader

A python-based file uploader for PicasaWeb
Python
40
star
7

android-command-line-ssh

A command line ssh for unrooted Android devices
C
39
star
8

lisp5000

A small dialect of Common Lisp based upon lisp500
Common Lisp
38
star
9

droid-examiner

An Android utility for examining Linux system internals of an Android device.
Java
35
star
10

glesquake

GL ES Quake: A port of Quake to OpenGL ES and the Android platform
C++
27
star
11

smallpt-swift

Smallpt: Global Illumination in Swift
Swift
20
star
12

webgltrace

A debugging utility for WebGL that records a trace of the WebGL calls made by an application
JavaScript
15
star
13

SeattleSnowman

Enhances an EdgeRouter Lite router to provide time-based internet access on a per-device basis.
Go
11
star
14

D3DQuake

D3DQuake is id Software's Quake modified to use Direct3D 7.0.
C
8
star
15

HD

A High Definition 4Chan browser
Swift
6
star
16

SpyPuzzleGameState

A Swift Package implementing the game state for a spy puzzle game.
Swift
5
star
17

SQLiteDataFrame

A Swift Package Manager Package for reading SQLite3 data into Tablular Data Framework DataFrames
Swift
5
star
18

jackpal.github.io

Source code for the blog https://jackpal.github.io/
SCSS
4
star
19

crt-terminal-emulator

Partial source code to a version of my Atari 400/800 Chameleon CRT Terminal Emulator
Roff
4
star
20

jackshacks

Browser-based casual games
JavaScript
4
star
21

gi-hacks

Global illumination experiments
C++
4
star
22

arkit-app-and-playgroundbook

A demonstration of how to have an iOS ARKit app that is also a playgroundbook
Swift
4
star
23

colabraytracing

A port of the Ray Tracing in One Weekend code to Swift in Google Colab
Jupyter Notebook
4
star
24

swiftgen4cgsql

Generates Swift wrappers for CG-SQL code.
Python
3
star
25

FourChanAPI

Swift code for accessing the FourChan image board API
Swift
3
star
26

planetwars-javascript-kit

Sample source code for the Google AI Challenge PlanetWars
JavaScript
3
star
27

HTMLString

A Codable class representing an HTML string.
Swift
2
star
28

SamsaraRoomPuzzle

A Swift command line app for solving the Samsara Room Bookshelf Puzzle
Swift
2
star
29

cutecamera

A simple image filtering app for iOS.
Swift
2
star
30

ToyPathTracerSwift

Swift
2
star
31

RemoteImage

A SwiftUI RemoteImage package. This one is especially good with large files.
Swift
2
star
32

SpyPuzzleCLI

A command line interface for a spy puzzle game.
Swift
2
star
33

AmahTV

A YouTube player for watching Taiwanese TV
Swift
1
star
34

reyes-dart

A simple REYES renderer in the Dart programming language
Dart
1
star
35

ants-dart-starter-package

A Dart language starter package for the Fall 2011 AI Challenge
Dart
1
star
36

icfp2017

ICFP 2017 Contest
Go
1
star
37

Ripples

Swift
1
star
38

ToyPathTracerSwiftCLI

A macOS command line interface to a toy path tracer.
Swift
1
star
39

arkitplaygroundbook

A bare bones implementation of a Swift ARKit plagroundbook
Swift
1
star