mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 05:08:03 +01:00
Standardize a utility method for getting local host names.
This commit is contained in:
committed by
Jon Chambers
parent
827a3af419
commit
c634185b6f
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2013-2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Locale;
|
||||
|
||||
public class HostnameUtil {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HostnameUtil.class);
|
||||
|
||||
public static String getLocalHostname() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostName().toLowerCase(Locale.US);
|
||||
} catch (final UnknownHostException e) {
|
||||
log.warn("Failed to get hostname", e);
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user