Update comments to reference final rfc6886.
I read through rfc6886 and compared it to the implementation. The
implementation still seems good.
Jack Palevich
5 years ago
5 | 5 |
|
6 | 6 |
NAT-PMP is supported by Apple brand routers and open source routers like Tomato and DD-WRT.
|
7 | 7 |
|
8 | |
See http://tools.ietf.org/html/draft-cheshire-nat-pmp-03
|
|
8 |
See https://tools.ietf.org/rfc/rfc6886.txt
|
9 | 9 |
|
10 | 10 |
|
11 | 11 |
[![Build Status](https://travis-ci.org/jackpal/go-nat-pmp.svg)](https://travis-ci.org/jackpal/go-nat-pmp)
|
8 | 8 |
// Implement the NAT-PMP protocol, typically supported by Apple routers and open source
|
9 | 9 |
// routers such as DD-WRT and Tomato.
|
10 | 10 |
//
|
11 | |
// See http://tools.ietf.org/html/draft-cheshire-nat-pmp-03
|
|
11 |
// See https://tools.ietf.org/rfc/rfc6886.txt
|
12 | 12 |
//
|
13 | 13 |
// Usage:
|
14 | 14 |
//
|
15 | 15 |
// client := natpmp.NewClient(gatewayIP)
|
16 | 16 |
// response, err := client.GetExternalAddress()
|
17 | 17 |
|
18 | |
// The recommended mapping lifetime for AddPortMapping
|
|
18 |
// The recommended mapping lifetime for AddPortMapping.
|
19 | 19 |
const RECOMMENDED_MAPPING_LIFETIME_SECONDS = 3600
|
20 | 20 |
|
21 | 21 |
// Interface used to make remote procedure calls.
|
|
84 | 84 |
msg := make([]byte, 12)
|
85 | 85 |
msg[0] = 0 // Version 0
|
86 | 86 |
msg[1] = opcode
|
|
87 |
// [2:3] is reserved.
|
87 | 88 |
writeNetworkOrderUint16(msg[4:6], uint16(internalPort))
|
88 | 89 |
writeNetworkOrderUint16(msg[6:8], uint16(requestedExternalPort))
|
89 | 90 |
writeNetworkOrderUint32(msg[8:12], uint32(lifetime))
|