File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
java/server/src/org/openqa/grid/common Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 26
26
import org .openqa .grid .common .exception .GridConfigurationException ;
27
27
import org .openqa .grid .internal .utils .configuration .GridNodeConfiguration ;
28
28
import org .openqa .selenium .Platform ;
29
+ import org .openqa .selenium .net .NetworkUtils ;
29
30
import org .openqa .selenium .remote .DesiredCapabilities ;
30
31
import org .openqa .selenium .remote .JsonToBeanConverter ;
31
32
@@ -176,6 +177,7 @@ public static RegistrationRequest build(GridNodeConfiguration configuration) {
176
177
if (configuration .host != null ) {
177
178
res .configuration .host = configuration .host ;
178
179
}
180
+ res .configuration .host = guessHost (res .configuration .host );
179
181
if (configuration .port != null ) {
180
182
res .configuration .port = configuration .port ;
181
183
}
@@ -201,6 +203,18 @@ private void addPlatformInfoToCapabilities() {
201
203
}
202
204
}
203
205
206
+ private static String guessHost (String host ) {
207
+ if (host == null || "ip" .equalsIgnoreCase (host )) {
208
+ NetworkUtils util = new NetworkUtils ();
209
+ return util .getIp4NonLoopbackAddressOfThisMachine ().getHostAddress ();
210
+ } else if ("host" .equalsIgnoreCase (host )) {
211
+ NetworkUtils util = new NetworkUtils ();
212
+ return util .getIp4NonLoopbackAddressOfThisMachine ().getHostName ();
213
+ } else {
214
+ return host ;
215
+ }
216
+ }
217
+
204
218
/**
205
219
* add config, but overwrite capabilities.
206
220
*
Original file line number Diff line number Diff line change 23
23
"proxy" : " org.openqa.grid.selenium.proxy.DefaultRemoteProxy" ,
24
24
"maxSession" : 5 ,
25
25
"port" : 5555 ,
26
- "host" : " localhost" ,
27
26
"register" : true ,
28
27
"registerCycle" : 5000 ,
29
28
"hub" : " http://localhost:4444"
You can’t perform that action at this time.
0 commit comments