diff --git a/build.xml b/build.xml
index 70e590d8..1cae598e 100755
--- a/build.xml
+++ b/build.xml
@@ -7,7 +7,7 @@
-
+
@@ -113,7 +113,14 @@
-
+
+
+
+
+
+
+
+
@@ -157,13 +164,14 @@
+
-
@@ -198,7 +206,10 @@
-
+
+
+
+
diff --git a/resources/Labels.txt b/resources/Labels.txt
index b7ac351d..d77bc142 100755
--- a/resources/Labels.txt
+++ b/resources/Labels.txt
@@ -103,7 +103,7 @@ text.fetchers.selectedList=Selected fetchers
text.fetchers.availableList=Available fetchers
text.fetchers.info=Fetcher information:
text.fetchers.info.notAvailable=Unfortunately, no additional information about this fetcher is available.
-text.about=%NAME\n\nVersion %VERSION\n%COPYLEFT\n\n%WEBSITE\n%MAILTO\n\nThis is an Open Source Software released under the GPL.
+text.about=%NAME\n\nVersion %VERSION (build %BUILD)\n%COPYLEFT\n\n%WEBSITE\n%MAILTO\n\nThis is an Open Source Software released under the GPL.
text.gettingStarted=Dummy
text.gettingStarted1=Angry IP Scanner is an IP address scanner tool.\n\nIt is used for scanning IP addresses for finding alive hosts, gathering any kind of needed information about each host.
text.gettingStarted2=Main terminology:\n\nFeeder - generator of IP addresses for scanning. Angry IP Scanner provides various kinds of feeders: IP Range, Random, and IP List File. You can select a feeder using the combo box next to the "Start" button.\n\nFetcher - gathers specific information about a host, e.g. ping time, hostname, open ports. Feeders usually represent columns in the scanning results list.
diff --git a/src/net/azib/ipscan/config/Version.java b/src/net/azib/ipscan/config/Version.java
index 2035c45d..698a4d26 100755
--- a/src/net/azib/ipscan/config/Version.java
+++ b/src/net/azib/ipscan/config/Version.java
@@ -3,6 +3,11 @@
*/
package net.azib.ipscan.config;
+import java.net.URI;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.logging.Level;
+
/**
* Class with accessors to version information of the program.
*
@@ -12,10 +17,6 @@ package net.azib.ipscan.config;
public class Version {
public static final String NAME = "Angry IP Scanner";
- public static final String VERSION = "2.9-alpha";
-
- public static final String FULL_NAME = NAME + " " + VERSION;
-
public static final String COPYLEFT = "\u00A9 2007 Anton Keks";
public static final String WEBSITE = "http://www.azib.net/ipscan/";
@@ -26,5 +27,51 @@ public class Version {
public static final String PLUGINS_URL = "http://www.azib.net/ipscan/plugins/";
- public static final String LATEST_VERSION_URL = "http://www.azib.net/ipscan/IPSCAN.VERSION";
+ public static final String LATEST_VERSION_URL = "http://www.azib.net/ipscan/IPSCAN.VERSION";
+
+ private static String version;
+ private static String build;
+
+ /**
+ * @return version of currently running Angry IP Scanner (retrieved from the jar file)
+ */
+ public static String getVersion() {
+ if (version == null) {
+ loadVersionFromJar();
+ }
+ return version;
+ }
+
+ /**
+ * @return build number of currently running Angry IP Scanner (retrieved from the jar file)
+ */
+ public static String getBuildNumber() {
+ if (build == null) {
+ loadVersionFromJar();
+ }
+ return build;
+ }
+
+ private static void loadVersionFromJar() {
+ String path = Version.class.getClassLoader().getResource(Version.class.getName().replace('.', '/') + ".class").toString();
+ if (path.startsWith("jar:file:")) {
+ path = path.substring(4, path.indexOf('!'));
+ try {
+ JarFile jarFile = new JarFile(new URI(path).getPath());
+ Attributes attrs = jarFile.getManifest().getMainAttributes();
+ version = attrs.getValue("Version");
+ build = attrs.getValue("Build");
+ return;
+ }
+ catch (Exception e) {
+ LoggerFactory.getLogger().log(Level.WARNING, "Cannot obtain version", e);
+ }
+ }
+ version = "Current";
+ build = "unknown";
+ }
+
+ public static String getFullName() {
+ return NAME + " " + getVersion();
+ }
}
diff --git a/src/net/azib/ipscan/exporters/TXTExporter.java b/src/net/azib/ipscan/exporters/TXTExporter.java
index fa69d36e..dc879882 100755
--- a/src/net/azib/ipscan/exporters/TXTExporter.java
+++ b/src/net/azib/ipscan/exporters/TXTExporter.java
@@ -55,7 +55,7 @@ public class TXTExporter implements Exporter {
output = new OutputStreamWriter(outputStream, Labels.getLabel("encoding"));
if (!isAppend) {
output.write(Labels.getLabel("exporter.txt.generated"));
- println(Version.FULL_NAME);
+ println(Version.getFullName());
println(Version.WEBSITE);
output.write(NEWLINE);
diff --git a/src/net/azib/ipscan/exporters/XMLExporter.java b/src/net/azib/ipscan/exporters/XMLExporter.java
index fa243000..4c7ea485 100755
--- a/src/net/azib/ipscan/exporters/XMLExporter.java
+++ b/src/net/azib/ipscan/exporters/XMLExporter.java
@@ -56,7 +56,7 @@ public class XMLExporter implements Exporter {
public void start(OutputStream outputStream, String feederInfo) throws IOException {
output = new PrintWriter(new OutputStreamWriter(outputStream, ENCODING));
output.println("");
- output.println("");
+ output.println("");
output.println("");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
diff --git a/src/net/azib/ipscan/gui/AboutDialog.java b/src/net/azib/ipscan/gui/AboutDialog.java
index b88f8181..13129f95 100755
--- a/src/net/azib/ipscan/gui/AboutDialog.java
+++ b/src/net/azib/ipscan/gui/AboutDialog.java
@@ -51,7 +51,8 @@ public class AboutDialog extends AbstractModalDialog {
Link textLabel = new Link(shell, SWT.NONE);
String text = Labels.getLabel("text.about");
text = text.replaceAll("%NAME", Version.NAME);
- text = text.replaceAll("%VERSION", Version.VERSION);
+ text = text.replaceAll("%VERSION", Version.getVersion());
+ text = text.replaceAll("%BUILD", Version.getBuildNumber());
text = text.replaceAll("%COPYLEFT", Version.COPYLEFT);
text = text.replaceAll("%WEBSITE", Version.WEBSITE);
text = text.replaceAll("%MAILTO", Version.MAILTO);
diff --git a/src/net/azib/ipscan/gui/actions/HelpActions.java b/src/net/azib/ipscan/gui/actions/HelpActions.java
index 94950765..29b838a9 100755
--- a/src/net/azib/ipscan/gui/actions/HelpActions.java
+++ b/src/net/azib/ipscan/gui/actions/HelpActions.java
@@ -82,12 +82,12 @@ public class HelpActions {
reader.close();
MessageBox messageBox = new MessageBox(event.display.getActiveShell(), SWT.ICON_INFORMATION);
- messageBox.setText(Version.FULL_NAME);
+ messageBox.setText(Version.getFullName());
- if (!Version.VERSION.equals(latestVersion)) {
+ if (!Version.getVersion().equals(latestVersion)) {
String message = Labels.getLabel("text.version.old");
message = message.replaceFirst("%LATEST", latestVersion);
- message = message.replaceFirst("%VERSION", Version.VERSION);
+ message = message.replaceFirst("%VERSION", Version.getVersion());
messageBox.setMessage(message);
}
else {
diff --git a/test/net/azib/ipscan/exporters/TXTExporterTest.java b/test/net/azib/ipscan/exporters/TXTExporterTest.java
index 3b1eee87..b8e2b0c6 100755
--- a/test/net/azib/ipscan/exporters/TXTExporterTest.java
+++ b/test/net/azib/ipscan/exporters/TXTExporterTest.java
@@ -35,7 +35,7 @@ public class TXTExporterTest extends AbstractExporterTestCase {
public void testHeaderWithoutAppend() throws IOException {
exporter.start(outputStream, "feederstuff");
exporter.end();
- assertContains(Version.FULL_NAME);
+ assertContains(Version.NAME);
assertContains(Version.WEBSITE);
}
@@ -44,7 +44,7 @@ public class TXTExporterTest extends AbstractExporterTestCase {
exporter.setAppend(true);
exporter.start(outputStream, "feederstuff");
exporter.end();
- assertNotContains(Version.FULL_NAME);
+ assertNotContains(Version.NAME);
assertNotContains(Version.WEBSITE);
}
diff --git a/test/net/azib/ipscan/exporters/XMLExporterTest.java b/test/net/azib/ipscan/exporters/XMLExporterTest.java
index 8622e9ba..2ce040dd 100755
--- a/test/net/azib/ipscan/exporters/XMLExporterTest.java
+++ b/test/net/azib/ipscan/exporters/XMLExporterTest.java
@@ -40,7 +40,7 @@ public class XMLExporterTest extends AbstractExporterTestCase {
public void testHeaderWithoutAppend() throws IOException {
exporter.start(outputStream, "feederstuff");
exporter.end();
- assertContains(Version.FULL_NAME);
+ assertContains(Version.NAME);
assertContains(Version.WEBSITE);
}