MilhouseVH / texturecache.py

Utility script to manage the XBMC texture cache
http://forum.xbmc.org/showthread.php?tid=158373
GNU General Public License v2.0
181 stars 34 forks source link

IPv6 support #11

Closed ghost closed 10 years ago

ghost commented 10 years ago

JSON/RPC daemon of XBMC 13 in Openelec 3.95.1 (OE4 beta 1) listens only on IPv6 localhost address on port TCP/9090 (i.e. [::1]:9090).

texturecache.py should try to create TCP/IPv6 socket on line 1534 (https://github.com/MilhouseVH/texturecache.py/blob/master/texturecache.py#L1534):

self.mysocket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)

Maybe some fallback or configuration option would be nice.

In other words texturecache.py is currently unable to connect to any (even remote) XBMC via IPv6.

MilhouseVH commented 10 years ago

Would you prefer the option, something like rpc.ipv6=yes (default no), or simply try IPv4 then try IPv6 before giving up? Or maybe both... :)

As for OE Beta 1 only listening on IPv6, what platform is this? Presumably this isn't the case on all platforms (Pi with latest OE master is still IPv4, for instance).

ghost commented 10 years ago

@MilhouseVH, well, I'll leave the decision up to you; whatever would be nice. Thanks a lot for this neat utility.

ghost commented 10 years ago

Openelec 4 beta 1 has been released today. I'm using x86_64 platform. Well, if I enable XBMC to be controlled from any host on the network, texturecache.py works OK (because in this case XBMC binds IPv4 0.0.0.0:9090 instead of IPv6 [::1]:9090), nevertheless I do not like it this way and consider it as security risk. Connection via IPv6 would be clear and more secure solution. …and future-proof, of course.

MilhouseVH commented 10 years ago

I've put a version on pastebin that includes this change, can you test it? I've tested against an IPv4-only system and it works fine.

By default this test version will try connecting with IPv6 first, and if that fails then IPv4. However, if you assign a value to the property rpc.ipversion, either 4 or 6, then it will only use that version when connecting.

ghost commented 10 years ago
#texturecache.cfg 
xbmc.host = ::1
rpc.ipversion = 6

works like a charm!

If you want to omit xbmc.host parameter in cfg file, Openelec must be fixed — unfortunately it does not contain ::1 as an address for localhost in /etc/hosts, so I suggest to add it into /storage/.config/hosts.conf as quickfix

::1 localhost ip6-localhost ip6-loopback

After that works also texturecache.py's IPv4/6 autodetection. Nice.

You can also add other relevant items

fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Again, thank you for this patch.

(BTW: pastebin version contains CRLF line endings, I had to replace them to LF.)

ghost commented 10 years ago

BTW: I've created a ticket in OpenELEC's issues. (https://github.com/OpenELEC/OpenELEC.tv/issues/2974)

MilhouseVH commented 10 years ago

Many thanks for confirming and also pointing out the localhost issue - I do think that fixing in OpenELEC is the best solution so won't make any further changes where that is concerned otherwise it starts getting messy and very system specific.

I've pushed this update as v.1.5.4.

ghost commented 10 years ago

I absolutely agree, many thanks! You can close this issue. v1.5.4 works OK.