0

我正在使用 Guacamole 0.9.12-incubating- 在服务器端扩展GuacamoleHTTPTunnelServlet,在客户端使用官方 JavaScript 代码。Guacamole 服务器从源代码编译并在 Ubuntu 17.04 上运行。

SSH 连接建立成功,但 15 秒后断开。没有键盘敲击和鼠标都不起作用。

May  7 17:14:09 dev guacd[4071]: Creating new client for protocol "ssh"
May  7 17:14:09 dev guacd[4071]: Connection ID is "$30e2e833-5640-4bc9-92c3-929ced3d6e0e"
May  7 17:14:09 dev guacd[4382]: User "@4209df46-e26a-4ced-93c4-c264578f85a5" joined connection "$30e2e833-5640-4bc9-92c3-929ced3d6e0e" (1 users now present)
May  7 17:14:10 dev guacd[4382]: SSH connection successful.
May  7 17:14:24 dev guacd[4382]: User is not responding.
May  7 17:14:24 dev guacd[4382]: User "@4209df46-e26a-4ced-93c4-c264578f85a5" disconnected (0 users remain)
May  7 17:14:24 dev guacd[4382]: Last user of connection "$30e2e833-5640-4bc9-92c3-929ced3d6e0e" disconnected
May  7 17:14:25 dev guacd[4382]: SSH connection ended.
May  7 17:14:25 dev guacd[4071]: Connection "$30e2e833-5640-4bc9-92c3-929ced3d6e0e" removed.

客户端 JavaScript 与文档中的相同 - https://guacamole.incubator.apache.org/doc/gug/writing-you-own-guacamole-app.html

当我Override在 servlet 中使用方法时,它们向我展示了击键。所以问题可能在 servlet 和 guacd 之间?

@Override
protected void doWrite(HttpServletRequest request, HttpServletResponse response, String tunnelUUID) throws GuacamoleException {
        LOGGER.debug("Do WRITE to session " + tunnelUUID);
        super.doWrite(request, response, tunnelUUID);
    }

@Override
protected void doRead(HttpServletRequest request, HttpServletResponse response, String tunnelUUID) throws GuacamoleException {
        LOGGER.debug("Do read to session " + tunnelUUID);
        super.doRead(request, response, tunnelUUID);
    }

已建立连接,但没有击键工作: 已建立 SSH 连接(在浏览器中)

谢谢。

4

1 回答 1

0

正如那里所讨论的那样,问题出在 Spring Boot 中 - https://glyptodon.org/jira/si/jira.issueviews:issue-html/GUAC-1252/GUAC-1252.html

解决方案是创建自己的实现HiddenHttpMethodFilter

@Configuration
public class GuacamoleServletConfiguration {

    @Bean
    public GuacamoleServlet guacamoleTunnelServlet() {
        return new GuacamoleServlet();
    }

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        ServletRegistrationBean bean = new ServletRegistrationBean(guacamoleTunnelServlet(), "/remote/tunnel");
        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return bean;
    }

    @Bean
    public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
        return new HiddenHttpMethodFilter() {
            @Override
            protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
                if ("POST".equals(request.getMethod()) && request.getRequestURI().startsWith("/remote/tunnel")) {
                    filterChain.doFilter(request, response);
                } else {
                    super.doFilterInternal(request, response, filterChain);
                }
            }
        };
    }
}
于 2017-05-08T14:51:18.843 回答