inetaf / nat

A collection of Go networking packages for dealing with NATs and NAT traversal.
BSD 3-Clause "New" or "Revised" License
16 stars 0 forks source link

nat/natpmp: initial commit #1

Closed mdlayher closed 4 years ago

mdlayher commented 4 years ago

This is very much a WIP and all feedback is welcome. I read a bit of the RFC and implemented request/response serialization and backoff/retry as recommended, but there's probably more intelligent things we can do as well. I've left TODO comments for things I am either unsure of or intend to do.

For now I've only implemented the "get external IP" method, but will take a look at the actual mapping calls once the overall structure is solid.

/cc @danderson @bradfitz @crawshaw

mdlayher commented 4 years ago

I forgot that t.Cleanup was added in 1.14:

[error]natpmp/client_test.go:219:3: t.Cleanup undefined (type *testing.T has no field or method Cleanup)

I'll change the signature to my older pattern:

c, done := testServer(t)
defer done()
mdlayher commented 4 years ago

Looks like this is probably a reasonable place to checkpoint the work. I took a look at netcheck and am mulling over some API ideas, but I think I'll open an issue before writing more code to ensure it ends up being something workable. Will squash and merge!