Esempio n. 1
0
func ServePACFile() {
	cfgMutex.Lock()
	defer cfgMutex.Unlock()
	if pacURL == "" {
		pacURL = ui.Handle("/proxy_on.pac", http.HandlerFunc(servePACFile))
	}
}
Esempio n. 2
0
func pacOn() {
	log.Debug("Setting lantern as system proxy")
	handler := func(resp http.ResponseWriter, req *http.Request) {
		resp.Header().Set("Content-Type", "application/x-ns-proxy-autoconfig")
		resp.WriteHeader(http.StatusOK)
		muPACFile.RLock()
		resp.Write(pacFile)
		muPACFile.RUnlock()
	}
	genPACFile()
	pacURL = ui.Handle("/proxy_on.pac", http.HandlerFunc(handler))
	log.Debugf("Serving PAC file at %v", pacURL)
	doPACOn()
	atomic.StoreInt32(&isPacOn, 1)
}