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 11package dev .aikido .agent_api .helpers .net ;
22
3+ import dev .aikido .agent_api .helpers .logging .LogManager ;
4+ import dev .aikido .agent_api .helpers .logging .Logger ;
5+
36import java .io .IOException ;
47import java .util .Scanner ;
58
9+
610public final class Hostname {
711 private Hostname () {}
12+ private static final Logger logger = LogManager .getLogger (Hostname .class );
13+
814 public static String getHostname () {
915 // getHostName function seem unreliable, so using "hostname" command which works for both UNIX(-like) systems and Windows
1016 // See https://stackoverflow.com/a/7800008 for more info.
1117 try (Scanner s = new Scanner (Runtime .getRuntime ().exec ("hostname" ).getInputStream ()).useDelimiter ("\\ A" )) {
1218 if (s .hasNext ()) {
1319 return s .next ().trim ();
1420 }
15- } catch (IOException ignored ) {
21+ } catch (IOException e ) {
22+ logger .debug (e );
1623 }
1724 return "unknown" ;
1825 }
You can’t perform that action at this time.
0 commit comments