示例#1
0
func ServePACFile() {
	cfgMutex.Lock()
	defer cfgMutex.Unlock()
	if pacURL == "" {
		pacURL = ui.Handle("/proxy_on.pac", http.HandlerFunc(servePACFile))
	}
}
示例#2
0
文件: pac.go 项目: shizhh/lantern
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)
}