paullouisageneau / libplum

Multi-protocol Port Mapping client library
Mozilla Public License 2.0
40 stars 5 forks source link

Issues with Draytek routers #21

Closed oviano closed 3 weeks ago

oviano commented 1 month ago

Hey there

  1. WANIPConnection is not found in the response from three different Draytek routers (2866, 2862, 2927):

10 urn:schemas-upnp-org:device:InternetGatewayDevice:1 Vigor2866 Draytek http://www.draytek.com.tw Residential Gateway Internet Connection Sharing 1.0 http://www.draytek.com/ uuid:226bffca-bc03-47dc-9aa4-1449bc36d4e8 00000-00001 urn:schemas-microsoft-com:service:OSInfo:1 urn:microsoft-com:serviceId:OSInfo1/OSInfo1 /OSInfoEvent1 /upnp/OSInfo.xml urn:schemas-upnp-org:device:WANDevice:1 WANDeviceDraytek http://www.draytek.com/ Residential Gateway Internet Connection Sharing 1 http://www.draytek.com/ 0000001 uuid:8c9db0f1-db2e-4c2a-b4af-89b06f67c4f300000-00001 urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 urn:upnp-org:serviceId:WANCommonIFC1/upnp?control=WANCommonIFC1 /upnp?event=WANCommonIFC1/upnp/WComIFC1.xml urn:schemas-upnp-org:device:WANConnectionDevice:1 WANConnectionDeviceDraytek http://www.draytek.com/Residential Gateway Internet Connection Sharing1http://www.draytek.com/ 0000001uuid:f3eab9db-ad42-4dc3-bc75-8c41679f65eb00000-00001 urn:schemas-upnp-org:service: WANDSLLinkConfig:1 urn:upnp-org:serviceId:WANDSLLinkC1/upnp?control=WANDSLLinkC1 /upnp?event=WANDSLLinkC1/upnp/WANDSL.xml urn:schemas-upnp-org:service:WANPPPConnection:1urn:upnp-org:serviceId:WANPPPConn1 /upnp?control=WANPPPConn1/upnp?event=WANPPPConn1 /upnp/WPPPCon1.xml http://192.168.2.1/

  1. Ok, so if I hack the code everywhere it says WANIPConnection to use WANPPPConnection then it starts to work. But then fails trying to extract ExternalIPAddress from the following response:

<?xml version="1.0" ?> XX.XX.XXX.XXX</m:GetExternalIPAddressResponse></s:Body></s:Envelope>

This is caused by the presence of the datatype information immediately after NewExternalIPAddress. If I add further hacks to the code to take into account this string then it works and maps the port correctly.

paullouisageneau commented 1 month ago

It looks like the routers implement the WANPPPConnection service instead of WANIPConnection. The UPnP standard is such a mess...

I think the library be adapted to support both. If you already have working code, a PR would be welcome.

oviano commented 1 month ago

Great, I'll sort out a PR for this.

oviano commented 1 month ago

https://github.com/paullouisageneau/libplum/pull/26 https://github.com/paullouisageneau/libplum/pull/27