File tree Expand file tree Collapse file tree
java/server/src/org/openqa/grid/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626import org .openqa .grid .common .exception .GridConfigurationException ;
2727import org .openqa .grid .internal .utils .configuration .GridNodeConfiguration ;
2828import org .openqa .selenium .Platform ;
29+ import org .openqa .selenium .net .NetworkUtils ;
2930import org .openqa .selenium .remote .DesiredCapabilities ;
3031import org .openqa .selenium .remote .JsonToBeanConverter ;
3132
@@ -176,6 +177,7 @@ public static RegistrationRequest build(GridNodeConfiguration configuration) {
176177 if (configuration .host != null ) {
177178 res .configuration .host = configuration .host ;
178179 }
180+ res .configuration .host = guessHost (res .configuration .host );
179181 if (configuration .port != null ) {
180182 res .configuration .port = configuration .port ;
181183 }
@@ -201,6 +203,18 @@ private void addPlatformInfoToCapabilities() {
201203 }
202204 }
203205
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+
204218 /**
205219 * add config, but overwrite capabilities.
206220 *
Original file line number Diff line number Diff line change 2323 "proxy" : " org.openqa.grid.selenium.proxy.DefaultRemoteProxy" ,
2424 "maxSession" : 5 ,
2525 "port" : 5555 ,
26- "host" : " localhost" ,
2726 "register" : true ,
2827 "registerCycle" : 5000 ,
2928 "hub" : " http://localhost:4444"
You can’t perform that action at this time.
0 commit comments