Page 2 of 2

Re: SAB ignoreing host setting in conf

Posted: July 13th, 2012, 4:29 am
by sander
Weird ... in sequential order (and with :: set in sabnzbd.ini):

Code: Select all

sander@R540:~/SABnzbd-0.7.2RC1$ python SABnzbd.py 
Into get_webhost ...
('cherryhost 1 is %s', None)
('cherryhost 2 is %s', None)
('cherryhost 3 is %s', '::')
('cherryhost 5 is %s', '::')
('cherryhost 666 is %s', '::')
2012-07-13 11:25:15,112::INFO::[SABnzbd:1292] --------------------------------
So: first None (as input), then ::? I don't understand.

This is the code in SABnzbd.py:

Code: Select all

#------------------------------------------------------------------------------
def get_webhost(cherryhost, cherryport, https_port):
    """ Determine the webhost address and port,
        return (host, port, browserhost)
    """

    print('Into get_webhost ...') 		# SJ

    print("cherryhost 1 is %s", cherryhost) 	# SJ

    if cherryhost == '0.0.0.0' and not ipv_localhost('4'):
        cherryhost = ''
    elif cherryhost == '::' and not ipv_localhost('6'):
        cherryhost = ''

    print("cherryhost 2 is %s", cherryhost) 	# SJ


    if cherryhost is None:
        cherryhost = sabnzbd.cfg.cherryhost()
    else:
        sabnzbd.cfg.cherryhost.set(cherryhost)

    print("cherryhost 3 is %s", cherryhost) 	# SJ
So in my config cherrypost gets filled from sabnzbd.cfg.cherryhost ?

Re: SAB ignoreing host setting in conf

Posted: July 13th, 2012, 1:18 pm
by shypike
Makes sense, doesn't it?
When you do not specify a hostname on the command line, it's read from the INI file.
None means that you didn't give a command line value.

Re: SAB ignoreing host setting in conf

Posted: July 13th, 2012, 1:31 pm
by sander
shypike wrote:Makes sense, doesn't it?
When you do not specify a hostname on the command line, it's read from the INI file.
None means that you didn't a command line value.
Ahhhhh! OK. Clear. Thanks.

Re: SAB ignoreing host setting in conf

Posted: July 13th, 2012, 2:02 pm
by shypike
I don't blame you for not following it easily.
I get a headache each time I have to do something in that code :(

Re: SAB ignoreing host setting in conf

Posted: July 13th, 2012, 3:08 pm
by whytewolf
Eureka!!!
once i saw this line i knew exactly what was wrong.

info = socket.getaddrinfo(socket.gethostname(), None)

since it was a private server. it's internal hostname for the entire system was set to a nonsensical word not the actual hostname. and since i was lazy that was not put into the host file. once i put both into the hosts file it works.

I'm not sure about this logic. just because hostname on a system isn't setup right doesn't mean that ip based configs should be ignored.

Re: SAB ignoreing host setting in conf

Posted: July 13th, 2012, 4:01 pm
by sander
@shypike:

I think it would useful if sabnzbd would log strange things it discovers in get_webhost(). That way it would be easier to analyze and solve problems. See the last post of whytewolf.

Re: SAB ignoreing host setting in conf [solved]

Posted: July 13th, 2012, 4:35 pm
by shypike
Hmmm, you're right about the logging, only logging isn't active.
I'll see what I can do.

What I find hard to understand the cavalier approach that Linux distros
have towards setting up a proper node name.
"uname -n" should give a name that resolves to the IP address of the system.
On many it's just 127.0.0.1 and on some systems it's complete nonsense.
Out of the box, that is.
Many services depend on a proper hostname/IP combo.

Re: SAB ignoreing host setting in conf [solved]

Posted: July 13th, 2012, 4:43 pm
by sander
shypike wrote:Hmmm, you're right about the logging, only logging isn't active.
I'll see what I can do.

What I find hard to understand the cavalier approach that Linux distros
have towards setting up a proper node name.
"uname -n" should give a name that resolves to the IP address of the system.
On many it's just 127.0.0.1 and on some systems it's complete nonsense.
Out of the box, that is.
Many services depend on a proper hostname/IP combo.

Is the command: host `uname -n` ?

Here's the result of a few of my systems:


Back to the logging thing:

We should SABnzbd not to solve everything. If a config is bad, SAB can't solve it, I think it's OK if SAB logs it and defaults to something safe (if possible).


Ubuntu laptop:

Code: Select all

sander@R540:~$ host `uname -n`
R540.home has address 192.168.1.53
sander@R540:~$
Raspi:

Code: Select all

pi@raspberrypi ~ $ host `uname -n`
raspberrypi.home has address 192.168.1.50
pi@raspberrypi ~ $ 
Ubuntu Server:

Code: Select all

sander@toverdoos:~$ host `uname -n`
Host toverdoos not found: 3(NXDOMAIN)
sander@toverdoos:~$ 
So my Ubuntu Server is bad?

Re: SAB ignoreing host setting in conf [solved]

Posted: July 13th, 2012, 5:01 pm
by shypike
sander wrote: Ubuntu Server:

Code: Select all

sander@toverdoos:~$ host `uname -n`
Host toverdoos not found: 3(NXDOMAIN)
sander@toverdoos:~$ 
So my Ubuntu Server is bad?
I think so. This is from the manpage of uname:

Code: Select all

 -n, --nodename
              print the network node hostname
AFAIK, a network node name is just that: the name of the network node.
Is it odd that I expect that name to resolve to an IP?

Re: SAB ignoreing host setting in conf [solved]

Posted: July 13th, 2012, 5:13 pm
by sander
The ping does know how to handle the `uname -n`:

Code: Select all

sander@toverdoos:~$ ping `uname -n`
PING toverdoos (176.31.156.230) 56(84) bytes of data.
64 bytes from toverdoos (176.31.156.230): icmp_req=1 ttl=64 time=0.041 ms
... so ping does resolve the `uname -n` name.

Luckily python knows it too:

Code: Select all

sander@toverdoos:~$ python
Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print socket.gethostname()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'socket' is not defined
>>> import socket
>>> socket.gethostname()
'toverdoos'
>>> socket.getaddrinfo(socket.gethostname(), None)
[(2, 1, 6, '', ('176.31.156.230', 0)), (2, 2, 17, '', ('176.31.156.230', 0)), (2, 3, 0, '', ('176.31.156.230', 0))]
>>> 
sander@toverdoos:~$ 

So that works for me, but not for the OP as he had a fancy name which was not in /etc/hosts?

Stupid question: why does SABnzbd want the *name*? Why not just binding to 127.0.0.1, or ::, or ... ?

Re: SAB ignoreing host setting in conf [solved]

Posted: July 13th, 2012, 5:48 pm
by whytewolf
shypike wrote:Hmmm, you're right about the logging, only logging isn't active.
I'll see what I can do.

What I find hard to understand the cavalier approach that Linux distros
have towards setting up a proper node name.
"uname -n" should give a name that resolves to the IP address of the system.
On many it's just 127.0.0.1 and on some systems it's complete nonsense.
Out of the box, that is.
Many services depend on a proper hostname/IP combo.
like i said, this is a private server and i was lazy with the hosts file. most services that most people deal with on a day to day basis are happy with an IP address only solution. it is perfectly possible that the address i want to bind to is not the same ip that my hostname qualifies as. in which case why does it matter at all what my system hostname is.

Re: SAB ignoreing host setting in conf [solved]

Posted: July 13th, 2012, 5:51 pm
by whytewolf
shypike wrote:
sander wrote: Ubuntu Server:

Code: Select all

sander@toverdoos:~$ host `uname -n`
Host toverdoos not found: 3(NXDOMAIN)
sander@toverdoos:~$ 
So my Ubuntu Server is bad?
I think so. This is from the manpage of uname:

Code: Select all

 -n, --nodename
              print the network node hostname
AFAIK, a network node name is just that: the name of the network node.
Is it odd that I expect that name to resolve to an IP?
it isn't odd that you expect that name is resolved to an IP, it is odd that you ignore a functioning config, because it doesn't.

edit: just thought of something, other network protocols besides IP. such as appletalk, IPX, token-ring. remember these systems were written LONG before IP based networks were the norm. in these cases while it is rare. it could be possible that you do not get an IP address [of coarse. you most likely would not be setting up a ip only based system]

Re: SAB ignoreing host setting in conf [solved]

Posted: July 14th, 2012, 7:28 am
by shypike
I think I have it fixed now, will be in 0.7.2