benoitc / erlang-nat

implements NAT handling facilities for Erlang applications
Other
57 stars 10 forks source link

Trying to get a UPNP lease with an infinite timeout triggers a delete instead. #5

Closed Vagabond closed 6 years ago

Vagabond commented 6 years ago

My home router, a linksys nighthawk R700P only supports permanent leases:

UPNP SOAP error: {ok,{{"HTTP/1.1",500,"Internal Server Error"},[{"server","Linux/2.6.12 UPnP/1.0 NETGEAR-UPNP/1.0"},{"content-length","438"},{"content-type","text/xml"},{"ext",[]}],"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n<s:Body>\r\n<s:Fault>\r\n<faultcode>s:Client</faultcode>\r\n<faultstring>UPnPError</faultstring>\r\n<detail>\r\n<UPnPError xmlns=\"urn:schemas-upnp-org:control-1-0\">\r\n<errorCode>725</errorCode>\r\n<errorDescription>OnlyPermanentLeasesSupported</errorDescription></UPnPError>\r\n</detail>\r\n</s:Fault>\r\n</s:Body>\r\n</s:Envelope>\r\n"}}

However, when I try to get an infinite lease using a timeout of 0, the nat code tries to do a delete instead:

https://github.com/benoitc/erlang-nat/blob/master/src/natupnp_v1.erl#L129

Is this intentional? How can I obtain an infinite lease?

benoitc commented 6 years ago

That was a convenient wrapper. Rereading the spec I think we should rather default to 0 when no duration is given instead of deleting it. Same for upnv v2 . Thoughts?

Vagabond commented 6 years ago

I'm torn, I hate things littering up my router with infinite leases, but infinite timeouts seem to work more consistently.

Certainly we need a way to be able to request infinite timeouts, at least. Maybe add a new clause where you can pass infinity as a timeout value?

macpie commented 6 years ago

I have created a PR #8 for this.

benoitc commented 6 years ago

8 have been merged :) thanks!