genotrance / px

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

Version 0.9.2 does not find px.ini in script folder #213

Open nicerloop opened 8 months ago

nicerloop commented 8 months ago

Hi,

I installed px using scoop. The script ends in $HOME\scoop\apps\px\current. I installed px to run on login: $HOME\scoop\apps\px\current\pythonw.exe -m px --install I configured px to use my upstream proxy.pac: px --pac=<proxy.pac.url> --save --config=$HOME\scoop\apps\px\current\px.ini Upon re-relogin, px is started but does not use the configure upstream proxy.pac.

I tried to work around by:

Did I misundertood how this is supposed to work?

Thank you.

genotrance commented 8 months ago

Can you please confirm if px.ini does get updated in the script directory with your pac url?

On powershell, you need to change $HOME to $Env:USERPROFILE. On cmd, it would be %USERPROFILE%. I presume you have simply used $HOME as an example here but just in case.

genotrance commented 8 months ago

Never mind - this is broken when running Px in -m px mode. You will need to manually edit the Run command in the registry with the config path to get it working. I'm not sure what CWD is the default when it is run from the registry - could be $HOME but you will need to test it and then put a px.ini there alternatively.

nicerloop commented 8 months ago

Can you please confirm if px.ini does get updated in the script directory with your pac url?

I confirm the explicitly targeted px.ini does get updated with the PAC URL.

On powershell, you need to change $HOME to $Env:USERPROFILE. On cmd, it would be %USERPROFILE%. I presume you have simply used $HOME as an example here but just in case.

I use powershell core, and the $HOME path does point to the same location as $ENV:USERPROFILE. This is not the source of my problem.

nicerloop commented 8 months ago

Regarding the --install option and the Run registry command:

I'm not sure what CWD is the default when it is run from the registry - could be $HOME but you will need to test it and then put a px.ini there alternatively.

It seems the CWD is C:\Windows\System32 which is NOT a location I can put a user-scoped configuration file, even if I had the required rights.

Never mind - this is broken when running Px in -m px mode.

But px --help states that the px.ini config file default location is working directory or script directory. I hoped this to find my px.ini configuration located in the install folder. It seems from a cursory reading of the sources that it should find my px.ini next to pythonw.exe in the install folder. But I am not a python developer.

You will need to manually edit the Run command in the registry with the config path to get it working.

I will try that.

nicerloop commented 7 months ago

After configuring Px from the command line from the $HOME folder:

px --pac=<proxy.pac.url> --save

I manually set the Run registry key with the following PowerShell command:

Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run -Name Px -Value "$HOME\scoop\apps\px\current\pythonw.exe -m px --config=$HOME\px.ini"

and Px correctly started on login without a window and with the upstream Proxy Auto-Configuration.

Could you fix: 1) the px.ini discovery to correctly find it when located next to px.exe or pythonw 2) the --install command to also set the --config parameter

The documentation should be updated to reflect the actual working installation for Windows.