MCPcopy Create free account
hub / github.com/M66B/FairEmail / getLocalHost

Method getLocalHost

app/src/main/java/com/sun/mail/iap/Protocol.java:654–688  ·  view source on GitHub ↗

Get the name of the local host. The property <prefix>.localhost overrides <prefix>.localaddress, which overrides what InetAddress would tell us. @return the name of the local host

()

Source from the content-addressed store, hash-verified

652 * @return the name of the local host
653 */
654 protected synchronized String getLocalHost() {
655 // get our hostname and cache it for future use
656 if (localHostName == null || localHostName.length() <= 0)
657 localHostName =
658 props.getProperty(prefix + ".localhost");
659 if (localHostName == null || localHostName.length() <= 0)
660 localHostName =
661 props.getProperty(prefix + ".localaddress");
662 try {
663 if (localHostName == null || localHostName.length() <= 0) {
664 InetAddress localHost = InetAddress.getLocalHost();
665 localHostName = localHost.getCanonicalHostName();
666 // if we can't get our name, use local address literal
667 if (localHostName == null)
668 // XXX - not correct for IPv6
669 localHostName = "[" + localHost.getHostAddress() + "]";
670 }
671 } catch (UnknownHostException uhex) {
672 }
673
674 // last chance, try to get our address from our socket
675 if (localHostName == null || localHostName.length() <= 0) {
676 if (socket != null && socket.isBound()) {
677 InetAddress localHost = socket.getLocalAddress();
678 localHostName = localHost.getCanonicalHostName();
679 // if we can't get our name, use local address literal
680 if (localHostName == null)
681 // XXX - not correct for IPv6
682 localHostName = "[" + localHost.getHostAddress() + "]";
683 }
684 }
685 if (TextUtils.isEmpty(localHostName))
686 localHostName = "localhost";
687 return localHostName;
688 }
689
690 /**
691 * Is protocol tracing enabled?

Callers 2

authntlmMethod · 0.45
getLocalHostNameMethod · 0.45

Calls 6

getHostAddressMethod · 0.80
lengthMethod · 0.45
getPropertyMethod · 0.45
isBoundMethod · 0.45
getLocalAddressMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected