Skip to content

Commit

Permalink
If applied, this commit will add gateway real ip
Browse files Browse the repository at this point in the history
  • Loading branch information
UellingtonDamasceno committed Nov 22, 2024
1 parent 4820976 commit 1f98177
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/dlt/id/manager/model/IDManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public IDManager() {

public void start() {
try {
this.ip = InetAddress.getLocalHost().getHostAddress().trim();
this.ip = this.getEnvOrDefault("GATEWAY_REAL_IP", InetAddress.getLocalHost().getHostAddress().trim());
this.id = UUID.randomUUID().toString();
this.log = Logger.getLogger(IDManager.class.getName());

this.log.info("IP: " + this.ip);
this.log.log(Level.INFO, "IP: {0}", this.ip);
} catch (UnknownHostException ex) {
Logger.getLogger(IDManager.class.getName()).log(Level.SEVERE, null, ex);
}
Expand All @@ -45,5 +45,10 @@ public String getIP() {
public String getID() {
return this.id;
}

private String getEnvOrDefault(String env, String defaultValue){
String value = System.getenv(env);
return value == null ? defaultValue : value;
}

}

0 comments on commit 1f98177

Please sign in to comment.