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
Don't hardcode localhost (maybe?) #394
Comments
This looks like a FreeBSD specific fix (as detailed in the very post that is linked) For example; on an install where there were no such issues; I'm now seeing: Rather than simply replacing the loopback address for localhost, it is best to test for it first.
|
As I pointed out, I didn't test that plex wasn't stupid. But as far as I can tell, it works well on my setup with localhost == 127.0.0.2 and I haven't authorized 127.0.0.0/8 in Allowed Networks. This is with 1.19.1.2645. And if localhost points to 127.0.0.1 in your setup, it should be a NO-OP, i.e. a transparent change, unless Plex does something even more stupid than I anticipated. What does Of course, if Plex had a proper bug tracker it would be easy to point out the problem there 😛 Regarding the RFC, the keyword is "ordinarily". Ordinarily loopback is 127.0.0.1, but not always. The whole block is available for loopback, as clearly stated in the first sentence:
|
For the record, I "reported" the issue here. Let's hope they will see the light. |
Not sure i understand fully your posts... |
My Plex install is under Docker for which ping isn't included; |
Yes, that's what it looks like, although the current scanner code works fine for me with PMS version 1.19.1.2645. I don't see the behavior @avluis reports. Maybe @avluis can tell us which version of PMS he's running? @avluis |
Version 1.19.3.2740 -- Plex Pass And as mentioned, localhost resolves; meaning it points to 127.0.0.1. |
sigh. The only way I can explain this is if Plex is actually parsing the http request and looks for "127.0.0.1" in the request host header, which would be really stupid, and doesn't match what I see on my setup. Then again, my PMS version is only slightly older than yours, I hope this is not a new behaviour. When I say I tested the current code, I started a brand new library from scratch with c.20k files in it and threw it at Hama/ASS: not a single glitch. Could it be docker doing something weird? |
@avluis localhost may resolve to something outside of 127.0.0.0/8. It could be incorrectly set to resolve to your LAN (non loopback) address, and that would be a plausible explanation for what you see. Hence my question. If you have confirmed this is not the case then there's some other problem. |
@avluis I don't know anything about docker, but a quick google search, first hit is https://pythonspeed.com/articles/docker-connection-refused/ Could this be related? |
No worries, there are no network misconfiguration issues on my end; The link provided goes into detail how a Docker container works; besides that, it doesn't pertain to our issue as The library I have here follows Hama/ASS without many issues (renaming is automated and backed by AniDB -- each file is matched by ed2k hash and then renamed with each folder containing the AnidDB ID); it still trips up Hama/ASS with certain edge cases. Anyways; if it works for you then I guess that's cool; hopefully the Plex team is not introducing additional issues with newer Plex versions (which I wouldn't discount honestly). |
@avluis thanks for taking the time to explain. I'm running out of ideas (and it's late for me :). Maybe you want to chime in on the Plex forum post I made here about this issue? I'll try to test a newer Plex version see if I trip on that bug, but I really hope we can get Plex to do the right thing. Hama/ASS is technically correct at the moment, I hope it can stay that way 😉 |
No worries; I'm gathering some additional details on my end and building a few containers with additional networking tools (alongside a Plex distribution) to add to your issue on their forums. -- |
Just a quick follow-up: I retested today with 1.19.1.2701 (last version currently available from FreshPorts). I removed my Anime Library and added it back (c20k files). The scan worked well: identification and matching works fine, metadata is correctly fetched. However I took a look at HTH |
If you put your token id in a file it won't show this error but not required. It helps finding root folders for libraries. |
9685e95#commitcomment-40265959 |
@ZeroQI if standards won’t convince you I don’t know what will. Plex code is garbage in that area (and others) and since they seem unwilling to fix it I don’t know what to say. If you revert it you will break the setup of some users (myself included, although I know what to patch now) and if you don’t it seems it breaks others. Caught between a rock and a hard place 😜 Maybe make this user configurable, if that’s not overly complicated? |
Just before setting "PLEX_LIBRARY_URL", simply test against "localhost:32400", and if fails use "127.0.0.1:32400". |
@EndOfLine369 that won't do. I see the same errors in my logs, but it doesn't affect my usage of Hama since I don't care about the behavior described here #394 (comment) (I haven't put the token in a file) |
It will do. And even then, would just be a socket/telnet test. Not if any data is available or not. |
The problem reported here 9685e95#commitcomment-40265959 is not a problem of name lookup for localhost (that would be a serious misconfiguration on the host system). If I read it right, it's a problem of Plex rejecting the HTTP content if the requested URI has 'localhost' instead of '127.0.0.1'. If that's the case, your proposed test won't do anything (unless you want to test for that, which will then break the setups like mine who don't care about token). |
This removes the need to ever have a "X-Plex-Token.id" file manually created. ZeroQI/Hama.bundle#394 / ZeroQI/Hama.bundle#406 / ZeroQI/Hama.bundle#407
Plex token is now pulled from the env in both HAMA & ASS. |
Closing as not hearing any more complaints post add of env pull of plex token. |
Hama.bundle/Contents/Code/common.py
Line 49 in 70f480b
On some setups (in particular FreeBSD jails without VNET), localhost may be any IP within the 127.0.0.0/8 range
Hardcoded 127.0.0.1 will either not work or be redirected to a different IP, at which point the agent won't work (as in https://forums.plex.tv/t/agents-not-working/156168 )
To be fair, I haven't tested that Plex does the right thing (for a change) and considers 127.0.0.0/8 as being localhost, vs only 127.0.0.1.
In any case, it's usually good practice not to assume localhost will always be 127.0.0.1 (see https://tools.ietf.org/html/rfc5735#section-3)
A correct approach should thus be
"http://localhost:32400/library/sections/"
A similar issue affects the Absolute Series Scanner.
HTH
The text was updated successfully, but these errors were encountered: