Skip to content

Commit

Permalink
compare with pacURL when clear proxy setting on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
fffw committed Aug 4, 2015
1 parent d679235 commit fc35740
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
31 changes: 15 additions & 16 deletions src/github.com/getlantern/flashlight/flashlight.go
Expand Up @@ -86,17 +86,6 @@ func init() {
func main() {
parseFlags()

if *clearProxySettings {
// This is a workaround that attempts to fix a Windows-only problem where
// Lantern was unable to clean the system's proxy settings before logging
// off.
//
// See: https://github.com/getlantern/lantern/issues/2776
setUpPacTool()
doPACOff()
return
}

showui = !*headless

if showui {
Expand Down Expand Up @@ -217,6 +206,16 @@ func runClientProxy(cfg *config.Config) {
exit(err)
}

if *clearProxySettings {
// This is a workaround that attempts to fix a Windows-only problem where
// Lantern was unable to clean the system's proxy settings before logging
// off.
//
// See: https://github.com/getlantern/lantern/issues/2776
doPACOff("http://" + cfg.UIAddr + "/proxy_on.pac")
exit(nil)
}

// Create the client-side proxy.
client := &client.Client{
Addr: cfg.Addr,
Expand Down Expand Up @@ -252,13 +251,13 @@ func runClientProxy(cfg *config.Config) {
}()

/*
Temporarily disabling localdiscover. See:
https://github.com/getlantern/lantern/issues/2813
// Continually search for local Lantern instances and update the UI
go func() {
Temporarily disabling localdiscover. See:
https://github.com/getlantern/lantern/issues/2813
// Continually search for local Lantern instances and update the UI
go func() {
addExitFunc(localdiscovery.Stop)
localdiscovery.Start(!showui, strconv.Itoa(tcpAddr.Port))
}()
}()
*/

// watchDirectAddrs will spawn a goroutine that will add any site that is
Expand Down
12 changes: 6 additions & 6 deletions src/github.com/getlantern/flashlight/pac.go
Expand Up @@ -123,8 +123,8 @@ func watchDirectAddrs() {
directHosts[host] = true
genPACFile()
// reapply so browser will fetch the PAC URL again
doPACOff()
doPACOn()
doPACOff(pacURL)
doPACOn(pacURL)
}
}
}()
Expand All @@ -142,26 +142,26 @@ func pacOn() {
genPACFile()
pacURL = ui.Handle("/proxy_on.pac", http.HandlerFunc(handler))
log.Debugf("Serving PAC file at %v", pacURL)
doPACOn()
doPACOn(pacURL)
atomic.StoreInt32(&isPacOn, 1)
}

func pacOff() {
if atomic.CompareAndSwapInt32(&isPacOn, 1, 0) {
log.Debug("Unsetting lantern as system proxy")
doPACOff()
doPACOff(pacURL)
log.Debug("Unset lantern as system proxy")
}
}

func doPACOn() {
func doPACOn(pacURL string) {
err := pac.On(pacURL)
if err != nil {
log.Errorf("Unable to set lantern as system proxy: %v", err)
}
}

func doPACOff() {
func doPACOff(pacURL string) {
err := pac.Off(pacURL)
if err != nil {
log.Errorf("Unable to unset lantern as system proxy: %v", err)
Expand Down

0 comments on commit fc35740

Please sign in to comment.