code: func (a *Agent) loadPersistedProxies() (map[string]persistedProxy, error) {
  	persistedProxies := make(map[string]persistedProxy)
  
  	proxyDir := filepath.Join(a.config.DataDir, proxyDir)
  	files, err := ioutil.ReadDir(proxyDir)
  	if err != nil {
  		if !os.IsNotExist(err) {
  			return nil, fmt.Errorf("Failed reading proxies dir %q: %s", proxyDir, err)
  		}
  	}
  
  	for _, fi := range files {
  		// Skip all dirs
  		if fi.IsDir() {
  			continue
  		}
  
  		// Skip all partially written temporary files
  		if strings.HasSuffix(fi.Name(), "tmp") {
  			return nil, fmt.Errorf("Ignoring temporary proxy file %v", fi.Name())
  		}
  
  		// Open the file for reading
  		file := filepath.Join(proxyDir, fi.Name())
  		fh, err := os.Open(file)
  		if err != nil {
  			return nil, fmt.Errorf("failed opening proxy file %q: %s", file, err)
  		}
  
  		// Read the contents into a buffer
  		buf, err := ioutil.ReadAll(fh)
  		fh.Close()
  		if err != nil {
  			return nil, fmt.Errorf("failed reading proxy file %q: %s", file, err)
  		}
  
  		// Try decoding the proxy definition
  		var p persistedProxy
  		if err := json.Unmarshal(buf, &p); err != nil {
  			return nil, fmt.Errorf("Failed decoding proxy file %q: %s", file, err)
  		}
  		svcID := p.Proxy.TargetServiceID
  
  		persistedProxies[svcID] = p
  	}
  
  	return persistedProxies, nil
  }
docs: // loadPersistedProxies will load connect proxy definitions from their
  // persisted state on disk and return a slice of them
  //
  // This does not add them to the local