OnHello is called when an device connects to us. This allows us to extract some information from the Hello message and add it to a list of known devices ahead of any checks.
(remoteID protocol.DeviceID, addr net.Addr, hello protocol.Hello)
| 2262 | // This allows us to extract some information from the Hello message |
| 2263 | // and add it to a list of known devices ahead of any checks. |
| 2264 | func (m *model) OnHello(remoteID protocol.DeviceID, addr net.Addr, hello protocol.Hello) error { |
| 2265 | if _, ok := m.cfg.Device(remoteID); !ok { |
| 2266 | if err := m.observed.AddOrUpdatePendingDevice(remoteID, hello.DeviceName, addr.String()); err != nil { |
| 2267 | slog.Warn("Failed to persist pending device entry to database", slogutil.Error(err)) |
| 2268 | } |
| 2269 | m.evLogger.Log(events.PendingDevicesChanged, map[string][]interface{}{ |
| 2270 | "added": {map[string]string{ |
| 2271 | "deviceID": remoteID.String(), |
| 2272 | "name": hello.DeviceName, |
| 2273 | "address": addr.String(), |
| 2274 | }}, |
| 2275 | }) |
| 2276 | // DEPRECATED: Only for backwards compatibility, should be removed. |
| 2277 | m.evLogger.Log(events.DeviceRejected, map[string]string{ |
| 2278 | "name": hello.DeviceName, |
| 2279 | "device": remoteID.String(), |
| 2280 | "address": addr.String(), |
| 2281 | }) |
| 2282 | return errDeviceUnknown |
| 2283 | } |
| 2284 | return nil |
| 2285 | } |
| 2286 | |
| 2287 | // AddConnection adds a new peer connection to the model. An initial index will |
| 2288 | // be sent to the connected peer, thereafter index updates whenever the local |
nothing calls this directly
no test coverage detected