samuong / alpaca

A local HTTP proxy for command-line tools. Supports PAC scripts and NTLM authentication.
Apache License 2.0
196 stars 35 forks source link

Don't call checkForUpdates without a fetcher #26

Closed camh- closed 5 years ago

camh- commented 5 years ago

ProxyFinder.checkForUpdates() should only be called if pf.fetcher is not nil. It does this on the HTTP serving path, but not on the initial call. Move the call to checkForUpdates() inside the branch that creates the pacfetcher.

Fixes this bug:

sam@sam-desktop:~/alpaca$ go build && ./alpaca
2019/09/19 19:13:28 proxyfinder.go:24: No PAC URL specified or detected; all requests will be made directly
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x855e7e]

goroutine 1 [running]:
main.(*pacFetcher).download(0x0, 0x0, 0x0, 0x0)
        /home/sam/alpaca/pacfetcher.go:51 +0x4e
main.(*ProxyFinder).checkForUpdates(0xc00000e0c0)
        /home/sam/alpaca/proxyfinder.go:50 +0x76
main.NewProxyFinder(0x0, 0x0, 0xc000170480, 0x0)
        /home/sam/alpaca/proxyfinder.go:31 +0xa9
main.main()
        /home/sam/alpaca/main.go:67 +0x2b8