()
| 1426 | type securityLevelKey struct{} |
| 1427 | |
| 1428 | func (ac *addrConn) securityLevelLocked() string { |
| 1429 | var secLevel string |
| 1430 | // During disconnection, ac.transport is nil. Fall back to the security level |
| 1431 | // stored in the current address during connection. |
| 1432 | if ac.transport == nil { |
| 1433 | secLevel, _ = ac.curAddr.Attributes.Value(securityLevelKey{}).(string) |
| 1434 | return secLevel |
| 1435 | } |
| 1436 | authInfo := ac.transport.Peer().AuthInfo |
| 1437 | if ci, ok := authInfo.(interface { |
| 1438 | GetCommonAuthInfo() credentials.CommonAuthInfo |
| 1439 | }); ok { |
| 1440 | secLevel = ci.GetCommonAuthInfo().SecurityLevel.String() |
| 1441 | // Store the security level in the current address' attributes so |
| 1442 | // that it remains available for disconnection metrics after the |
| 1443 | // transport is closed. |
| 1444 | ac.curAddr.Attributes = ac.curAddr.Attributes.WithValue(securityLevelKey{}, secLevel) |
| 1445 | } |
| 1446 | return secLevel |
| 1447 | } |
| 1448 | |
| 1449 | // tryAllAddrs tries to create a connection to the addresses, and stop when at |
| 1450 | // the first successful one. It returns an error if no address was successfully |
no test coverage detected