genotrance / px

An HTTP proxy server to automatically authenticate through an NTLM proxy
MIT License
952 stars 98 forks source link

Startup error in parse_noproxy() #139

Closed DK100 closed 2 years ago

DK100 commented 2 years ago

Hi! I just upgraded from version 0.4 to the current one and I get the following error on startup (using the same px.ini file as before):

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "...\px.py", line 1652, in <module>
    main()
    ^^^^^^
  File "...\px.py", line 1647, in main
    parse_config()
    ^^^^^^^^^^^^^^
  File "...\px.py", line 1450, in parse_config
    State.wproxy = wproxy.Wproxy(wproxy.MODE_CONFIG_PAC, [pac], debug_print = dprint)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\wproxy.py", line 323, in __init__
    super().__init__(mode, servers, noproxy, debug_print)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\wproxy.py", line 132, in __init__
    noproxy, self.noproxy_hosts = parse_noproxy(noproxy)
                                  ^^^^^^^^^^^^^^^^^^^^^^
  File "...\wproxy.py", line 78, in parse_noproxy
    bypasses = [h for h in noproxystr.lower().replace(' ', ',').replace(';', ',').split(',')]
                           ^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'

My ini-file looks like this:

[proxy]
server = 
pac = http://localhost:4444/proxy.pac
port = 3128
listen = 127.0.0.1
allow = *.*.*.*
gateway = 0
hostonly = 0
noproxy = 
useragent = 
username = 
auth = 

[settings]
workers = 2
threads = 5
idle = 30
socktimeout = 20.0
proxyreload = 60
foreground = 0
log = 1

I downloaded the code and I was able to run a debug session (I'm no python coder yet ;). If I understand it correctly the error occurs when the wproxy-class is created the first time. During the initialization the parse_noproxy method will always be called with "noproxystr" = NONE...which seems to me that this should always fail (calling .lower() on NONE)?!

Another thing I'm wondering about is the mentioned line 132 in wproxy.py: noproxy, self.noproxy_hosts = parse_noproxy(noproxy)

Shouldn't it be: self.noproxy, self.noproxy_hosts = parse_noproxy(noproxy) ?

Thank you and best regards, phil

genotrance commented 2 years ago

I've posted v0.6.3 with a fix - please verify and thanks for the review!

DK100 commented 2 years ago

It works now, thank you very much!