Codebase list golang-github-jackpal-go-nat-pmp / 766af2b
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
2 changed file(s) with 4 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
55
66 NAT-PMP is supported by Apple brand routers and open source routers like Tomato and DD-WRT.
77
8 See http://tools.ietf.org/html/draft-cheshire-nat-pmp-03
8 See https://tools.ietf.org/rfc/rfc6886.txt
99
1010
1111 [![Build Status](https://travis-ci.org/jackpal/go-nat-pmp.svg)](https://travis-ci.org/jackpal/go-nat-pmp)
88 // Implement the NAT-PMP protocol, typically supported by Apple routers and open source
99 // routers such as DD-WRT and Tomato.
1010 //
11 // See http://tools.ietf.org/html/draft-cheshire-nat-pmp-03
11 // See https://tools.ietf.org/rfc/rfc6886.txt
1212 //
1313 // Usage:
1414 //
1515 // client := natpmp.NewClient(gatewayIP)
1616 // response, err := client.GetExternalAddress()
1717
18 // The recommended mapping lifetime for AddPortMapping
18 // The recommended mapping lifetime for AddPortMapping.
1919 const RECOMMENDED_MAPPING_LIFETIME_SECONDS = 3600
2020
2121 // Interface used to make remote procedure calls.
8484 msg := make([]byte, 12)
8585 msg[0] = 0 // Version 0
8686 msg[1] = opcode
87 // [2:3] is reserved.
8788 writeNetworkOrderUint16(msg[4:6], uint16(internalPort))
8889 writeNetworkOrderUint16(msg[6:8], uint16(requestedExternalPort))
8990 writeNetworkOrderUint32(msg[8:12], uint32(lifetime))