Răsfoiți Sursa

'修改了获取服务器ip'

o2wwx 5 ani în urmă
părinte
comite
b5faa43efe

+ 11 - 3
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/command/ActionGet.java

@@ -11,17 +11,25 @@ import com.x.base.core.project.config.Node;
 
 /*获取服器信息列表*/
 class ActionGet extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String currentIP) throws Exception {
 		
 			ActionResult<Wo> result = new ActionResult<>();			
 			Nodes nodes = Config.nodes();
+			
 			if (null == nodes) {
-				throw new ExceptionEntityNotExist(id, "Nodes");
+				throw new ExceptionEntityNotExist(currentIP, "Nodes");
 			}
 			List<NodeInfo> nodeInfoList = new ArrayList<>();
+			
 			for(String key:nodes.keySet()){
 				NodeInfo  nodeInfo  = new NodeInfo();
-				nodeInfo.setNodeAddress(key);
+				
+				if(key.equalsIgnoreCase("127.0.0.1")) {
+					nodeInfo.setNodeAddress(currentIP);	
+				}else {
+				    nodeInfo.setNodeAddress(key);
+				}
+				
 				nodeInfo.setNode(nodes.get(key));
 				nodeInfoList.add(nodeInfo);
 			}

+ 2 - 1
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/command/CommandAction.java

@@ -62,8 +62,9 @@ public class CommandAction<Wo> extends StandardJaxrsAction {
 	public void getNodeInfoList(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		ActionResult<ActionGet.Wo> result = new ActionResult<>();
+		String currentIP = request.getLocalAddr();
 		try {
-			result = (ActionResult<ActionGet.Wo>) new ActionGet().execute(effectivePerson, "");
+			result = (ActionResult<ActionGet.Wo>) new ActionGet().execute(effectivePerson, currentIP);
 		} catch (Exception e) {
 			e.printStackTrace();
 			result.error(e);