This commit is contained in:
parent
feebab63e5
commit
4fc74e3375
18
pom.xml
18
pom.xml
|
|
@ -100,6 +100,24 @@
|
|||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Servlet API -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Main Guacamole library -->
|
||||
<dependency>
|
||||
<groupId>org.apache.guacamole</groupId>
|
||||
<artifactId>guacamole-common</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package net.educoder.bridge.webssh.config;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class SimpleCORSFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest reqs = (HttpServletRequest) req;
|
||||
String curOrigin = reqs.getHeader("Origin");
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
response.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
response.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||
response.setHeader("Content-Type","application/octet-stream");
|
||||
chain.doFilter(req, res);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {}
|
||||
|
||||
@Override
|
||||
public void destroy() {}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package net.educoder.bridge.webssh.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class WebSocketAutoConfig {
|
||||
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package net.educoder.bridge.webssh.controller;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.GuacamoleSocket;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
import org.apache.guacamole.net.InetGuacamoleSocket;
|
||||
import org.apache.guacamole.net.SimpleGuacamoleTunnel;
|
||||
import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
import org.apache.guacamole.websocket.GuacamoleWebSocketTunnelEndpoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
|
||||
@ServerEndpoint(value = "/webSocket", subprotocols = "guacamole")
|
||||
@Component
|
||||
public class WebSocketTunnel extends GuacamoleWebSocketTunnelEndpoint {
|
||||
@Override
|
||||
protected GuacamoleTunnel createTunnel(Session session, EndpointConfig endpointConfig) throws GuacamoleException {
|
||||
|
||||
String hostname = "121.40.224.66";
|
||||
int port = 54482;
|
||||
|
||||
GuacamoleConfiguration config = new GuacamoleConfiguration();
|
||||
config.setProtocol("rdp");
|
||||
config.setParameter("hostname", "39.105.62.120");
|
||||
config.setParameter("port", "40045");
|
||||
config.setParameter("username", "Administrator");
|
||||
config.setParameter("password", "Edu_123123");
|
||||
config.setParameter("security", "nla");
|
||||
config.setParameter("ignore-cert", "true");
|
||||
|
||||
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
|
||||
new InetGuacamoleSocket(hostname, port),
|
||||
config
|
||||
);
|
||||
|
||||
GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
|
||||
return tunnel;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue