File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
agent_api/src/main/java/dev/aikido/agent_api/helpers/net Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
package dev .aikido .agent_api .helpers .net ;
2
2
3
+ import dev .aikido .agent_api .helpers .logging .LogManager ;
4
+ import dev .aikido .agent_api .helpers .logging .Logger ;
5
+
3
6
import java .io .IOException ;
4
7
import java .util .Scanner ;
5
8
9
+
6
10
public final class Hostname {
7
11
private Hostname () {}
12
+ private static final Logger logger = LogManager .getLogger (Hostname .class );
13
+
8
14
public static String getHostname () {
9
15
// getHostName function seem unreliable, so using "hostname" command which works for both UNIX(-like) systems and Windows
10
16
// See https://stackoverflow.com/a/7800008 for more info.
11
17
try (Scanner s = new Scanner (Runtime .getRuntime ().exec ("hostname" ).getInputStream ()).useDelimiter ("\\ A" )) {
12
18
if (s .hasNext ()) {
13
19
return s .next ().trim ();
14
20
}
15
- } catch (IOException ignored ) {
21
+ } catch (IOException e ) {
22
+ logger .debug (e );
16
23
}
17
24
return "unknown" ;
18
25
}
You can’t perform that action at this time.
0 commit comments