Guacamole开发笔记

前提:成功安装guacd服务后。需要把guacd监听的IP改为自己的内网或者公网IP,而不是127.0.0.1。开放4822端口 以便外部访问

1.建立一个maven工程引入servlet,guacamole-common,guacamole-common-js 这三个依赖。

2.新建一个servlet(也可以用spring去实现)

3.html页面访问servlet

public class DummyGuacamoleTunnelServlet extends GuacamoleHTTPTunnelServlet {
    
    @Override
    protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException {

        // guacd connection information
        String hostname = "192.168.2.66";
        int port = 4822;


        GuacamoleClientInformation client= new GuacamoleClientInformation();
        client.setOptimalScreenHeight(Integer.parseInt(request.getParameter("GUAC_HEIGHT")));
        client.setOptimalScreenWidth(Integer.parseInt(request.getParameter("GUAC_WIDTH")));
        client.setOptimalResolution(Integer.parseInt(request.getParameter("GUAC_DPI")));
 
        GuacamoleConfiguration config = new GuacamoleConfiguration();
        config.setProtocol("ssh");
        config.setParameter("hostname", "192.168.2.8");
        config.setParameter("port", "22");
        config.setParameter("username", "你的主机用户名");
        config.setParameter("password", "密码");
        config.setParameter("color-scheme", "black-white");
        config.setParameter("font-name", "SimSun");
        config.setParameter("font-size", "12");
        
        GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
                new InetGuacamoleSocket(hostname, port),
                config,client
        );
        GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
        return tunnel;
    }




评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值