diff --git a/upnp.go b/upnp.go index 2ab13ea..443c1d1 100644 --- a/upnp.go +++ b/upnp.go @@ -63,17 +63,23 @@ func (d *IGD) Forward(port uint16, desc string) error { return err } + time.Sleep(time.Millisecond) err = d.client.AddPortMapping("", port, "TCP", port, ip, true, desc, 0) if err != nil { return err } + + time.Sleep(time.Millisecond) return d.client.AddPortMapping("", port, "UDP", port, ip, true, desc, 0) } // Clear un-forwards a port, removing it from the router's port mapping table. func (d *IGD) Clear(port uint16) error { + time.Sleep(time.Millisecond) tcpErr := d.client.DeletePortMapping("", port, "TCP") + time.Sleep(time.Millisecond) udpErr := d.client.DeletePortMapping("", port, "UDP") + // only return an error if both deletions failed if tcpErr != nil && udpErr != nil { return tcpErr diff --git a/upnp_test.go b/upnp_test.go index bd951ad..861612e 100644 --- a/upnp_test.go +++ b/upnp_test.go @@ -71,6 +71,7 @@ func TestIGD(t *testing.T) { if err != nil { t.Fatal(err) } + t.Log("Loc:", loc) // connect to router directly d, err = Load(loc)