@@ -98,31 +98,41 @@ impl UIState {
98
98
connections_to_procs : & ' a HashMap < LocalSocket , String > ,
99
99
local_socket : & LocalSocket ,
100
100
) -> Option < & ' a String > {
101
- let & LocalSocket { port, protocol, .. } = local_socket;
102
-
103
101
let name = connections_to_procs
102
+ // direct match
104
103
. get ( local_socket)
104
+ // IPv4-mapped IPv6 addresses
105
+ . or_else ( || {
106
+ let swapped: IpAddr = match local_socket. ip {
107
+ IpAddr :: V4 ( v4) => v4. to_ipv6_mapped ( ) . into ( ) ,
108
+ IpAddr :: V6 ( v6) => v6. to_ipv4_mapped ( ) ?. into ( ) ,
109
+ } ;
110
+ connections_to_procs. get ( & LocalSocket {
111
+ ip : swapped,
112
+ ..* local_socket
113
+ } )
114
+ } )
115
+ // address unspecified
105
116
. or_else ( || {
106
117
connections_to_procs. get ( & LocalSocket {
107
118
ip : Ipv4Addr :: UNSPECIFIED . into ( ) ,
108
- port,
109
- protocol,
119
+ ..* local_socket
110
120
} )
111
121
} )
112
122
. or_else ( || {
113
123
connections_to_procs. get ( & LocalSocket {
114
124
ip : Ipv6Addr :: UNSPECIFIED . into ( ) ,
115
- port,
116
- protocol,
125
+ ..* local_socket
117
126
} )
118
127
} ) ;
119
128
120
129
// only log each orphan connection once
121
130
if name. is_none ( ) && self . known_orphan_sockets . borrow_mut ( ) . insert ( * local_socket) {
122
131
match connections_to_procs
123
132
. iter ( )
124
- . find ( |( socket, _) | socket. port == port && socket. protocol == protocol)
125
- {
133
+ . find ( |( & LocalSocket { port, protocol, .. } , _) | {
134
+ port == local_socket. port && protocol == local_socket. protocol
135
+ } ) {
126
136
Some ( ( lookalike, name) ) => {
127
137
warn ! (
128
138
r#""{name}" owns a similar looking connection, but its local ip doesn't match."#
0 commit comments