You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

WebsshController.java 3.0 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package com.educoder.bridge.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.educoder.bridge.model.Webssh;
  4. import com.educoder.bridge.service.WebsshService;
  5. import com.educoder.bridge.utils.Base64Util;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import io.swagger.annotations.ApiParam;
  9. import org.slf4j.Logger;
  10. import org.slf4j.LoggerFactory;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.http.MediaType;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestMethod;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import org.springframework.web.servlet.ModelAndView;
  18. /**
  19. * @author guange
  20. * @date 2017/08/02
  21. */
  22. @Api(value = "提供webssh连接", hidden = true)
  23. @RestController
  24. public class WebsshController extends BaseController {
  25. private final static Logger logger = LoggerFactory.getLogger(WebsshController.class);
  26. @Autowired
  27. private WebsshService websshService;
  28. @ApiOperation(value = "获取连接容器所需的ip和端口信息", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
  29. @RequestMapping(path = "/webssh/getConnectInfo")
  30. public JSONObject getConnectInfo(
  31. @ApiParam(name = "tpiID", required = true, value = "tpiID") @RequestParam String tpiID,
  32. @ApiParam(name = "podType", required = true, value = "pod类型,0为evaluate, 1为webssh,2为evassh") @RequestParam Integer podType,
  33. @ApiParam(name = "containers", required = true, value = "需要使用的容器,base64编码") @RequestParam String containers)
  34. throws Exception {
  35. logger.info("tpiID: {}, podType: {},containers: {}", tpiID, podType, containers);
  36. containers = Base64Util.decode(containers);
  37. Webssh sshInfo = websshService.create(tpiID, podType, containers);
  38. JSONObject response = new JSONObject();
  39. response.put("address", sshInfo.getAddress());
  40. response.put("port", Integer.parseInt(sshInfo.getPort()) + "");
  41. response.put("code", 0);
  42. return response;
  43. }
  44. @RequestMapping(value={"/", "ssh"}, method= RequestMethod.GET)
  45. public ModelAndView index(@RequestParam("Host")String host,
  46. @RequestParam("Port")int port,
  47. @RequestParam("Gameid")int gameId,
  48. @RequestParam("Username")String username,
  49. @RequestParam("Password")String password,
  50. @RequestParam("Tab")String tab,
  51. @RequestParam("Rows")int rows) {
  52. //index就是视图的名称(index.ftl)
  53. logger.debug("/ssh: 接收到前端连接请求,host: {}, port: {}", host, port);
  54. ModelAndView mv = new ModelAndView();
  55. mv.setViewName("index");
  56. mv.addObject("Host", host);
  57. mv.addObject("Port", port);
  58. mv.addObject("Username", username);
  59. mv.addObject("Password", password);
  60. mv.addObject("Tab", tab);
  61. mv.addObject("Rows", rows);
  62. mv.addObject("Gameid", gameId);
  63. mv.addObject("digest", System.currentTimeMillis());
  64. return mv;
  65. }
  66. }

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...