MCPcopy
hub / github.com/syncthing/syncthing / introduceDevice

Method introduceDevice

lib/model/model.go:1845–1870  ·  view source on GitHub ↗
(device protocol.Device, introducerCfg config.DeviceConfiguration)

Source from the content-addressed store, hash-verified

1843}
1844
1845func (m *model) introduceDevice(device protocol.Device, introducerCfg config.DeviceConfiguration) config.DeviceConfiguration {
1846 addresses := []string{"dynamic"}
1847 for _, addr := range device.Addresses {
1848 if addr != "dynamic" {
1849 addresses = append(addresses, addr)
1850 }
1851 }
1852
1853 slog.Info("Adding device to config (vouched for by introducer)", device.ID.LogAttr(), slog.Any("introducer", introducerCfg.DeviceID.Short()))
1854 newDeviceCfg := m.cfg.DefaultDevice()
1855 newDeviceCfg.DeviceID = device.ID
1856 newDeviceCfg.Name = device.Name
1857 newDeviceCfg.Compression = introducerCfg.Compression
1858 newDeviceCfg.Addresses = addresses
1859 newDeviceCfg.CertName = device.CertName
1860 newDeviceCfg.IntroducedBy = introducerCfg.DeviceID
1861
1862 // The introducers' introducers are also our introducers.
1863 if device.Introducer {
1864 slog.Info("Device is now also an introducer", device.ID.LogAttr())
1865 newDeviceCfg.Introducer = true
1866 newDeviceCfg.SkipIntroductionRemovals = device.SkipIntroductionRemovals
1867 }
1868
1869 return newDeviceCfg
1870}
1871
1872// Closed is called when a connection has been closed
1873func (m *model) Closed(conn protocol.Connection, err error) {

Callers 1

handleIntroductionsMethod · 0.95

Calls 3

ShortMethod · 0.80
DefaultDeviceMethod · 0.65
LogAttrMethod · 0.45

Tested by

no test coverage detected