From 18de8b9ed9f6ba9780d3292d2828f67de08b7483 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 24 Jul 2009 09:46:24 +0000
Subject: [PATCH] Refactor the code of dsreplication and extract some of its commodity methods and move them to the classes they apply to.
---
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 4399381..e77eb9e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -42,6 +42,7 @@
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
+import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
@@ -1687,6 +1688,39 @@
}
/**
+ * Basic method to know if the host is local or not. This is only used to
+ * know if we can perform a port check or not.
+ * @param host the host to analyze.
+ * @return <CODE>true</CODE> if it is the local host and <CODE>false</CODE>
+ * otherwise.
+ */
+ public static boolean isLocalHost(String host)
+ {
+ boolean isLocalHost = false;
+ if (!"localhost".equalsIgnoreCase(host))
+ {
+ try
+ {
+ InetAddress localAddress = InetAddress.getLocalHost();
+ InetAddress[] addresses = InetAddress.getAllByName(host);
+ for (int i=0; i<addresses.length && !isLocalHost; i++)
+ {
+ isLocalHost = localAddress.equals(addresses[i]);
+ }
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Failing checking host names: "+t, t);
+ }
+ }
+ else
+ {
+ isLocalHost = true;
+ }
+ return isLocalHost;
+ }
+
+ /**
* Returns the HTML representation of a plain text string which is obtained
* by converting some special characters (like '<') into its equivalent
* escaped HTML representation.
--
Gitblit v1.10.0