code: func (m *model) generateClusterConfig(device protocol.DeviceID) protocol.ClusterConfig {
  	var message protocol.ClusterConfig
  
  	m.fmut.RLock()
  	defer m.fmut.RUnlock()
  
  	for _, folderCfg := range m.cfg.FolderList() {
  		if !folderCfg.SharedWith(device) {
  			continue
  		}
  
  		protocolFolder := protocol.Folder{
  			ID:                 folderCfg.ID,
  			Label:              folderCfg.Label,
  			ReadOnly:           folderCfg.Type == config.FolderTypeSendOnly,
  			IgnorePermissions:  folderCfg.IgnorePerms,
  			IgnoreDelete:       folderCfg.IgnoreDelete,
  			DisableTempIndexes: folderCfg.DisableTempIndexes,
  			Paused:             folderCfg.Paused,
  		}
  
  		var fs *db.FileSet
  		if !folderCfg.Paused {
  			fs = m.folderFiles[folderCfg.ID]
  		}
  
  		for _, device := range folderCfg.Devices {
  			deviceCfg, _ := m.cfg.Device(device.DeviceID)
  
  			protocolDevice := protocol.Device{
  				ID:          deviceCfg.DeviceID,
  				Name:        deviceCfg.Name,
  				Addresses:   deviceCfg.Addresses,
  				Compression: deviceCfg.Compression,
  				CertName:    deviceCfg.CertName,
  				Introducer:  deviceCfg.Introducer,
  			}
  
  			if fs != nil {
  				if deviceCfg.DeviceID == m.id {
  					protocolDevice.IndexID = fs.IndexID(protocol.LocalDeviceID)
  					protocolDevice.MaxSequence = fs.Sequence(protocol.LocalDeviceID)
  				} else {
  					protocolDevice.IndexID = fs.IndexID(deviceCfg.DeviceID)
  					protocolDevice.MaxSequence = fs.Sequence(deviceCfg.DeviceID)
  				}
  			}
  
  			protocolFolder.Devices = append(protocolFolder.Devices, protocolDevice)
  		}
  
  		message.Folders = append(message.Folders, protocolFolder)
  	}
  
  	return message
  }
docs: // generateClusterConfig returns a ClusterConfigMessage that is correct for
  // the given peer device