Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kodi doesn't honor <hosts> in advancedsettings.xml #15469

Closed
1 of 7 tasks
andbo467 opened this issue Feb 8, 2019 · 33 comments · Fixed by #19040
Closed
1 of 7 tasks

Kodi doesn't honor <hosts> in advancedsettings.xml #15469

andbo467 opened this issue Feb 8, 2019 · 33 comments · Fixed by #19040

Comments

@andbo467
Copy link
Contributor

andbo467 commented Feb 8, 2019

Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

<videodatabase> and <musicdatabase> doesn't care about what is defined in previous <hosts> in advancedsettings.xml.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

If a host is defined in advancedsettings it should use it.

Actual Behavior

It doesn't matter what is defined in <hosts>. Kodi doesn't use it anyway.

To Reproduce

Steps to reproduce the behavior:

In advancedsettings.xml:
A1. Define a host with the actual/right hostname (in my case "SC-NAS") but wrong IP.
A2. Use the hostname above when defining a mysql database.
A3. Start Kodi.
A4. Kodi should not find the database because of the hostname points to the wrong IP, but it does.

B1. Define a host with the wrong hostname (lets say "TEST") but with the right IP.
B2. Use the hostname above when defining a mysql database.
B3. Start Kodi.
B4. Kodi should now find the database because of the hostname points to the right IP, but it doesn't.

Debuglog

The debuglog can be found here:
Debug with right hostname and wrong IP: https://paste.kodi.tv/erusocarat.kodi
Debug with wrong hostname and right IP: https://paste.kodi.tv/quqokufupu.kodi

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

Also when referring to a smb://hostname in sources.xml doesn't care about what is defined under <hosts>.

The problem was discovered when Windows 10 removed SMB1 by default and the hostname wasn't autodiscovered in Windows under a period, before it was fixed.

The same problem is in Kodi 17.x

Your Environment

Used Operating system:

  • Android

  • iOS

  • Linux

  • OSX

  • Raspberry-Pi

  • Windows

  • Windows UWP

  • Operating system version/name: 10 Education edition (10.0.17763.253)

  • Kodi version: 18.0

note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

@andbo467
Copy link
Contributor Author

noone?

@WulfmanGer
Copy link

Same @ LibreElec 9.2 (Kodi 18.3) @ Raspberry Pi4

KODI has a very aggressive handling of DNS.

(LibreElec, Pi4)
~ / .config / hosts.conf -> is completely ignored by Kodi. Only console works.

Workaround: delete resolv.conf, create new resolv.conf (at startup) with OWN DNS server wants to be rejected after some seconds (time enough to open to Netshare and cache this DNS).

DNS-push via VPN (openvpn via autostart.sh) is completely ignored. Routing into my LAN behind VPN works.

Apparently, it is fixed here defines how DNS resolution is allowed to work and with which server is spoken. Only resolv.conf -> nameserver x.y.z.a. If this fix were removed, then or at least hosts.conf would work immediately.

@JoshDi
Copy link

JoshDi commented Oct 3, 2019

Im having the same issue

@mytril
Copy link

mytril commented Oct 14, 2020

The issue is also in version 18,8 and 19, On Windows 10, Kubuntu 20.04, Fire TV Stick and Android TV

@vagkap
Copy link

vagkap commented Jan 8, 2021

Same here. Tested Kodi 18.9 on SONY Android TV, Android TV Box, and Windows 7.
In the case of Android TVs there is no chance of editing hosts file so there is no other way to solve this problem.
With Android TV sales on the rise lots of people are going to face the same problem. Please fix it.

@arnova
Copy link
Member

arnova commented Jan 8, 2021

as.xml was never implemented for stuff like this. It simply adds host->ip entries inside Kodi's internal DNS-cache but the DNS cache is actually only used by the NFS client (and LAN-check). So it means it also doesn't work for other network filesystems: smb, http, webdav etc.

I also don't get why you need this? You might as well stick the IP directly in the database-sections. Or perhaps you could use Kodi's path substitution? This doesn't mean that should be fixed or its comment should be improved, but perhaps it can offer a workaround for now?

@wsnipex wsnipex linked a pull request Jan 8, 2021 that will close this issue
13 tasks
@wsnipex
Copy link
Member

wsnipex commented Jan 8, 2021

I suspect when you want to use SSL, you're better off with a hostname or you might have cert validation issues.
I've quickly looked into a fix, see PR linked above

@vagkap
Copy link

vagkap commented Jan 8, 2021

Just to make my case clear:
I use kodi with MariaDB(mysql) as the audio/video database which is running on a NAS.
I have multiple clients running kodi on different platforms.
In each client machine change only the (system) hosts file to point to my NAS IP (eg. HOME_NAS 192.168.1.101).

The audio/video files are stored in the same NAS.

my settings for the DB in advancedsettings.xml are
<videodatabase> <type>mysql</type> <host>HOME_NAS</host> <port>3306</port> <user>username</user> <pass>password</pass> </videodatabase>

The sources.xml file has entries like this:
<source> <name>documentaries</name> <path pathversion="1">smb://HOME_NAS/video/documentaries/</path> <allowsharing>true</allowsharing> </source>

The "problem" is that on a machine that you cannot edit the system hosts file
you cannot use the (shared) sql database because the file paths are stored as smb://HOME_NAS/.....

@arnova
Copy link
Member

arnova commented Jan 8, 2021

Just to make my case clear:
I use kodi with MariaDB(mysql) as the audio/video database which is running on a NAS.
I have multiple clients running kodi on different platforms.
In each client machine change only the (system) hosts file to point to my NAS IP (eg. HOME_NAS 192.168.1.101).

The audio/video files are stored in the same NAS.

my settings for the DB in advancedsettings.xml are
<videodatabase> <type>mysql</type> <host>HOME_NAS</host> <port>3306</port> <user>username</user> <pass>password</pass> </videodatabase>

The sources.xml file has entries like this:
<source> <name>documentaries</name> <path pathversion="1">smb://HOME_NAS/video/documentaries/</path> <allowsharing>true</allowsharing> </source>

The "problem" is that on a machine that you cannot edit the system hosts file
you cannot use the (shared) sql database because the file paths are stored as smb://HOME_NAS/.....

To be honest: I don't really see the problem. It's only for convenience that you can configure the hostname->IP mapping in a single place, right? But then the question comes to mind: How often do you change the host's IP? I suspect it's a one time thing, so that means setting an IP in 2 config files: advancedsettings.xml and sources.xml, no biggy imo.

@vagkap
Copy link

vagkap commented Jan 8, 2021

You're correct but it's a little bit more complicated.
I sync the databases (and the files) between two different NASes in different locations with different ip addresses [192.168.1.* and 192.168.0.* ]

@wsnipex
Copy link
Member

wsnipex commented Jan 8, 2021

are you able to test my proposed fix?

@mytril
Copy link

mytril commented Jan 8, 2021

I have a bit other setting, but the same problem. I have two nas systems on two locations with the same files. But to keep track of the view status of every file. I have created only one database on one of the nas systems. So the trick is to tell kodi that both systems are the same. Because if both nas systems have not the same name, they will be treated in the database as different file locations.

So i use the tag for the file server and the fixed ip for the db server. But because that don't function i have used my fritzbox to do the same...

@vagkap
Copy link

vagkap commented Jan 8, 2021

are you able to test my proposed fix?

@wsnipex Sorry but i cannot test it.

@wsnipex
Copy link
Member

wsnipex commented Jan 8, 2021

why is that?

@vagkap
Copy link

vagkap commented Jan 8, 2021

why is that?

Because i don't know what i have to do. How can i test it ? I suppose i need a new executable ?

@wsnipex
Copy link
Member

wsnipex commented Jan 8, 2021

which OS and hardware do you use? We can provide test builds for most platforms, but linux

@mytril
Copy link

mytril commented Jan 8, 2021

I could test it on linux or windows. I have tried to compile it on kubuntu. After fetching your patch, kodi dont start anymore, only matrix screen...

@wsnipex
Copy link
Member

wsnipex commented Jan 8, 2021

did you build this branch? https://github.com/wsnipex/xbmc/tree/hosts
please provide a debug log, by running kodi --debug from console

@mytril
Copy link

mytril commented Jan 8, 2021

Ok i have found the error. The fault win an extra entry in advacedsettings.xml not related to this topic. Now it works witch your patch

@vagkap
Copy link

vagkap commented Jan 8, 2021

which OS and hardware do you use? We can provide test builds for most platforms, but linux

@wsnipex
I use windows 7 64bit and android TV version 9. Windows is much easier/faster to test.

@mytril
Copy link

mytril commented Jan 8, 2021

Thats strange if i add the msql database entrys from the older config. Kodi dont start anymore.

advancedsettings.xml
kodi.log

@howie-f
Copy link
Contributor

howie-f commented Jan 8, 2021

@mytril you‘re testing with an old commit, as your log reveals. the pr has been updated meanwhile and i can confirm it‘s working for mysql in its current state.
try again with https://github.com/wsnipex/xbmc/tree/hosts please

@mytril
Copy link

mytril commented Jan 8, 2021

@howie-f Ok will try it.

@mytril
Copy link

mytril commented Jan 8, 2021

@howie-f Yes now it works

@vagkap
Copy link

vagkap commented Jan 9, 2021

Tested win64 version.
Entry for HOME_NAS deleted from windows hosts file and added to advancedsettings.xml
<hosts>
<entry name="HOME_NAS">192.168.1.201</entry>
</hosts>
RESULTS:
On first run DB migrated to new version. Seems that HOME_NAS was correctly resolved to 192.168.1.201.
But none of the files in the database could be played.

In the log file there are entries for for every file/directory in the DB like the following:
"2021-01-09 18:07:20.690 T:2836 WARNING : VIDEO::CVideoInfoScanner::Process directory 'smb://HOME_NAS/video/movies/' does not exist - skipping scan."

This message appeared on screen: "This file is no longer available. Would you like to remove from the library ?".
It seems that smb protocol cannot resolve the host.
Hope that helps.

@wsnipex
Copy link
Member

wsnipex commented Jan 9, 2021

I kinda expected this. Contrary to curl (for http/ftp), there is no way to fake a DNS server for SMB and MySQL. Kodi is not a DNS server, the best we can do is replace the name with the IP. The resulting URL is smb://192.168.1.201/videos/movies
You might be able to combine this with path substitution to get it working.
It works for HTTP, because curl provides a method to fake DNS entries.

@mytril
Copy link

mytril commented Jan 9, 2021

On my setup with smb and mysql it works. All Videos play and i can resume them on other devices too. Maybe there are other problems with your setup like permission problems? Or have you a problem with lowercase or uppercase letters in your path?

@vagkap
Copy link

vagkap commented Jan 9, 2021

@mytril I don't think it's an uppercase/lowercase issue because when the O/S does the resolving everything works fine.
Did you reboot your system (or flushed the dns cache) ( ipconfig /flushdns on windows) after removing the entry from your hosts file?
I can't think of anything else why it is working in your case and not mine. I use win7 x64.

Are the file paths in your DB referenced as "smb://ip.address/path" or by "smb://hostname/path" ?

@mytril
Copy link

mytril commented Jan 9, 2021

I am on Linux and didn't need to reboot. But i can try it on windows 10.
Here are my entries:

<advancedsettings> <hosts> <entry name="test">192.168.42.42</entry> </hosts> <videodatabase> <type>mysql</type> <host>test</host> <port>3306</port> <user>kodi</user> <pass>kodi</pass> </videodatabase>

@vagkap
Copy link

vagkap commented Jan 9, 2021

Maybe i wasn't clear enough. The DB works fine. The problem is that kodi cannot find the video files when i press play.

@mytril
Copy link

mytril commented Jan 9, 2021

Yes i can confirm it. On Linux it works but on Windows 10 i get an error if i want to add the source. He cant find the Host.
mysql hostname works by me too.

@wsnipex
Copy link
Member

wsnipex commented Jan 10, 2021

windows doesn't use samba, but windows native SMB. If it works in linux, it should work on all other platform but windows as well.
For windows: just use a hosts file entry and be done with it.

DaveTBlake added a commit that referenced this issue Jan 12, 2021
use DNS cache for samba and mysql. (fixes  #15469)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants