ThreadController.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @(#)file TestController.java
  3. * @(#)author
  4. * @(#)version 1.0
  5. * @(#)date 2022. 9. 2.
  6. * @(#)since
  7. *
  8. * Copyright (c) www.hsnc.co.kr, Inc.
  9. * All rights reserved.
  10. * This software is the proprietary information of Hanwha S&C, Inc.
  11. */
  12. package com.udapsoft.waf.system.controller;
  13. import java.io.IOException;
  14. import java.io.PrintWriter;
  15. import javax.servlet.ServletConfig;
  16. import javax.servlet.ServletException;
  17. import javax.servlet.http.HttpServlet;
  18. import javax.servlet.http.HttpServletRequest;
  19. import javax.servlet.http.HttpServletResponse;
  20. import kr.co.hsnc.common.base.WAFLogger;
  21. import kr.co.udapsoft.common.commonSign.CommonMailThreadManager;
  22. import kr.co.udapsoft.common.commonSign.CommonSignThreadManager;
  23. /**
  24. * <p>Thread Controller Class</p>
  25. * CommonThread, CommonMailThread Stop Servlet
  26. * @version 1.0
  27. * @author
  28. */
  29. @SuppressWarnings("serial")
  30. public class ThreadController extends HttpServlet {
  31. @Override
  32. public void init(ServletConfig config) throws ServletException {
  33. }
  34. @Override
  35. protected void doGet(HttpServletRequest req, HttpServletResponse res)
  36. throws ServletException, IOException {
  37. WAFLogger.debug("doGet!!!!!!!!!!!!!!");
  38. WAFLogger.debug("remoteAddr=" + req.getRemoteAddr());
  39. String ip = req.getRemoteAddr();
  40. if ("127.0.0.1".equals(ip) || "0:0:0:0:0:0:0:1".equals(ip)
  41. || "211.38.140.247".equals(ip) || "fe80::f17e:bfd1:1ac5:4ccd%17".equals(ip)) {
  42. WAFLogger.debug("before sign=" + CommonSignThreadManager.isRun());
  43. WAFLogger.debug("before mail=" + CommonMailThreadManager.isRun());
  44. CommonSignThreadManager.doStop();
  45. CommonMailThreadManager.doStop();
  46. WAFLogger.debug("after sign=" + CommonSignThreadManager.isRun());
  47. WAFLogger.debug("after mail=" + CommonMailThreadManager.isRun());
  48. } else {
  49. throw new ServletException("Thread stop error!!");
  50. }
  51. res.setContentType("text/html; charset=utf-8");
  52. PrintWriter out = res.getWriter();
  53. out.println("<html>");
  54. out.println("Thread Stopped.");
  55. out.println("</html>");
  56. }
  57. @Override
  58. public void destroy() {
  59. super.destroy();
  60. }
  61. }