Skip to content

Commit 116add9

Browse files
committed
Restore file
1 parent 5494a47 commit 116add9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tmc-plugin/src/fi/helsinki/cs/tmc/spyware/HostInformationGenerator.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public String updateHostInformation(EventReceiver receiver) {
3131
LoggableEvent event
3232
= new LoggableEvent(
3333
"host_information_update",
34-
data.toString().getBytes(UTF8));
34+
data.toString().getBytes(Charset.forName("UTF-8")));
3535
receiver.receiveEvent(event);
3636

3737
return hostId;
@@ -40,6 +40,14 @@ public String updateHostInformation(EventReceiver receiver) {
4040
private static JsonMaker getStaticHostInformation() {
4141
JsonMaker builder = JsonMaker.create();
4242

43+
try {
44+
InetAddress localMachine = java.net.InetAddress.getLocalHost();
45+
builder.add("hostAddress", localMachine.getHostAddress());
46+
builder.add("hostName", localMachine.getHostName());
47+
} catch (Exception ex) {
48+
log.log(Level.WARNING, "Exception while getting host name information: {0}", ex);
49+
}
50+
4351
try {
4452
Enumeration<NetworkInterface> iterator = NetworkInterface.getNetworkInterfaces();
4553
List<String> macs = new ArrayList<String>(2);
@@ -116,5 +124,5 @@ private static String byteToHex(byte[] bytes) {
116124
}
117125
return sb.toString();
118126
}
119-
}
120127

128+
}

0 commit comments

Comments
 (0)