File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,23 @@ async fn migrate_devices(
433
433
Ulid :: with_source ( rng) . into ( ) ) ;
434
434
let created_at = Ulid :: from ( session_id) . datetime ( ) . into ( ) ;
435
435
436
+ // As we're using a real IP type in the MAS database, it is possible
437
+ // that we encounter invalid IP addresses in the Synapse database.
438
+ // In that case, we should ignore them, but still log a warning.
439
+ let last_active_ip = ip. and_then ( |ip| {
440
+ ip. parse ( )
441
+ . map_err ( |e| {
442
+ tracing:: warn!(
443
+ error = & e as & dyn std:: error:: Error ,
444
+ mxid = %synapse_user_id,
445
+ %device_id,
446
+ %ip,
447
+ "Failed to parse device IP, ignoring"
448
+ ) ;
449
+ } )
450
+ . ok ( )
451
+ } ) ;
452
+
436
453
// TODO skip access tokens for deactivated users
437
454
write_buffer
438
455
. write (
@@ -445,7 +462,7 @@ async fn migrate_devices(
445
462
created_at,
446
463
is_synapse_admin : synapse_admins. contains ( & user_id) ,
447
464
last_active_at : last_seen. map ( DateTime :: from) ,
448
- last_active_ip : ip . map ( |ip| ip . parse ( ) ) . transpose ( ) . ok ( ) . flatten ( ) ,
465
+ last_active_ip,
449
466
user_agent,
450
467
} ,
451
468
)
You can’t perform that action at this time.
0 commit comments