mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
Added start of basic logging using logback
This commit is contained in:
parent
fbb60cf9e3
commit
4b72d77ad4
@ -11,6 +11,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<javafx.version>1.8</javafx.version>
|
<javafx.version>1.8</javafx.version>
|
||||||
<jettyVersion>9.4.48.v20220622</jettyVersion>
|
<jettyVersion>9.4.48.v20220622</jettyVersion>
|
||||||
|
<logback.version>1.3.5</logback.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@ -224,11 +225,12 @@
|
|||||||
<groupId>com.github.tulskiy</groupId>
|
<groupId>com.github.tulskiy</groupId>
|
||||||
<artifactId>jkeymaster</artifactId>
|
<artifactId>jkeymaster</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.3</version>
|
||||||
</dependency>
|
<exclusions>
|
||||||
<dependency>
|
<exclusion>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>2.0.0-alpha0</version>
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.maven/maven-artifact -->
|
<!-- https://mvnrepository.com/artifact/org.apache.maven/maven-artifact -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -274,17 +276,32 @@
|
|||||||
<groupId>com.github.ganskef</groupId>
|
<groupId>com.github.ganskef</groupId>
|
||||||
<artifactId>littleproxy-mitm</artifactId>
|
<artifactId>littleproxy-mitm</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>G-Earth</groupId>
|
<groupId>G-Earth</groupId>
|
||||||
<artifactId>G-Wasm-Minimal</artifactId>
|
<artifactId>G-Wasm-Minimal</artifactId>
|
||||||
<version>1.0.3</version>
|
<version>1.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-core</artifactId>
|
||||||
|
<version>${logback.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>${logback.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
@ -48,7 +48,13 @@ public class GEarth extends Application {
|
|||||||
stage = primaryStage;
|
stage = primaryStage;
|
||||||
|
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml"));
|
||||||
Parent root = loader.load();
|
Parent root;
|
||||||
|
try {
|
||||||
|
root = loader.load();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
controller = loader.getController();
|
controller = loader.getController();
|
||||||
controller.setStage(primaryStage);
|
controller.setStage(primaryStage);
|
||||||
stage.initStyle(StageStyle.TRANSPARENT);
|
stage.initStyle(StageStyle.TRANSPARENT);
|
||||||
|
@ -9,14 +9,17 @@ import gearth.protocol.connection.proxy.ProxyProvider;
|
|||||||
import gearth.protocol.connection.proxy.nitro.http.NitroHttpProxy;
|
import gearth.protocol.connection.proxy.nitro.http.NitroHttpProxy;
|
||||||
import gearth.protocol.connection.proxy.nitro.http.NitroHttpProxyServerCallback;
|
import gearth.protocol.connection.proxy.nitro.http.NitroHttpProxyServerCallback;
|
||||||
import gearth.protocol.connection.proxy.nitro.websocket.NitroWebsocketProxy;
|
import gearth.protocol.connection.proxy.nitro.websocket.NitroWebsocketProxy;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.ServerSocket;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class NitroProxyProvider implements ProxyProvider, NitroHttpProxyServerCallback, StateChangeListener {
|
public class NitroProxyProvider implements ProxyProvider, NitroHttpProxyServerCallback, StateChangeListener {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(NitroProxyProvider.class);
|
||||||
|
|
||||||
private final HProxySetter proxySetter;
|
private final HProxySetter proxySetter;
|
||||||
private final HStateSetter stateSetter;
|
private final HStateSetter stateSetter;
|
||||||
private final HConnection connection;
|
private final HConnection connection;
|
||||||
@ -52,20 +55,27 @@ public class NitroProxyProvider implements ProxyProvider, NitroHttpProxyServerCa
|
|||||||
|
|
||||||
connection.getStateObservable().addListener(this);
|
connection.getStateObservable().addListener(this);
|
||||||
|
|
||||||
|
logger.info("Starting http proxy");
|
||||||
|
|
||||||
if (!nitroHttpProxy.start()) {
|
if (!nitroHttpProxy.start()) {
|
||||||
System.out.println("Failed to start nitro proxy");
|
logger.error("Failed to start nitro proxy");
|
||||||
abort();
|
abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("Starting websocket proxy");
|
||||||
|
|
||||||
if (!nitroWebsocketProxy.start()) {
|
if (!nitroWebsocketProxy.start()) {
|
||||||
System.out.println("Failed to start nitro websocket proxy");
|
logger.error("Failed to start nitro websocket proxy");
|
||||||
abort();
|
abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
websocketPort = nitroWebsocketProxy.getPort();
|
websocketPort = nitroWebsocketProxy.getPort();
|
||||||
|
|
||||||
|
logger.info("Websocket proxy is listening on port {}", websocketPort);
|
||||||
|
logger.info("Nitro proxy started");
|
||||||
|
|
||||||
stateSetter.setState(HState.WAITING_FOR_CLIENT);
|
stateSetter.setState(HState.WAITING_FOR_CLIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,19 +85,25 @@ public class NitroProxyProvider implements ProxyProvider, NitroHttpProxyServerCa
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abortLock.compareAndSet(true, true)) {
|
if (!abortLock.compareAndSet(false, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("Aborting nitro proxy");
|
||||||
|
|
||||||
stateSetter.setState(HState.ABORTING);
|
stateSetter.setState(HState.ABORTING);
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
logger.info("Stopping nitro http proxy");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
nitroHttpProxy.stop();
|
nitroHttpProxy.stop();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("Stopping nitro websocket proxy");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
nitroWebsocketProxy.stop();
|
nitroWebsocketProxy.stop();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -97,6 +113,8 @@ public class NitroProxyProvider implements ProxyProvider, NitroHttpProxyServerCa
|
|||||||
stateSetter.setState(HState.NOT_CONNECTED);
|
stateSetter.setState(HState.NOT_CONNECTED);
|
||||||
|
|
||||||
connection.getStateObservable().removeListener(this);
|
connection.getStateObservable().removeListener(this);
|
||||||
|
|
||||||
|
logger.info("Nitro proxy stopped");
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,13 @@ import gearth.protocol.connection.*;
|
|||||||
import gearth.protocol.connection.proxy.nitro.NitroConstants;
|
import gearth.protocol.connection.proxy.nitro.NitroConstants;
|
||||||
import gearth.protocol.connection.proxy.nitro.NitroProxyProvider;
|
import gearth.protocol.connection.proxy.nitro.NitroProxyProvider;
|
||||||
import gearth.protocol.packethandler.nitro.NitroPacketHandler;
|
import gearth.protocol.packethandler.nitro.NitroPacketHandler;
|
||||||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
|
||||||
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
import org.eclipse.jetty.websocket.jsr356.JsrSession;
|
||||||
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.websocket.*;
|
import javax.websocket.*;
|
||||||
import javax.websocket.server.ServerEndpoint;
|
import javax.websocket.server.ServerEndpoint;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,6 +22,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
@ServerEndpoint(value = "/")
|
@ServerEndpoint(value = "/")
|
||||||
public class NitroWebsocketClient implements NitroSession {
|
public class NitroWebsocketClient implements NitroSession {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(NitroWebsocketClient.class);
|
||||||
|
|
||||||
private final HProxySetter proxySetter;
|
private final HProxySetter proxySetter;
|
||||||
private final HStateSetter stateSetter;
|
private final HStateSetter stateSetter;
|
||||||
private final HConnection connection;
|
private final HConnection connection;
|
||||||
@ -45,6 +46,8 @@ public class NitroWebsocketClient implements NitroSession {
|
|||||||
|
|
||||||
@OnOpen
|
@OnOpen
|
||||||
public void onOpen(Session session) throws Exception {
|
public void onOpen(Session session) throws Exception {
|
||||||
|
logger.info("WebSocket connection accepted");
|
||||||
|
|
||||||
activeSession = (JsrSession) session;
|
activeSession = (JsrSession) session;
|
||||||
activeSession.setMaxBinaryMessageBufferSize(NitroConstants.WEBSOCKET_BUFFER_SIZE);
|
activeSession.setMaxBinaryMessageBufferSize(NitroConstants.WEBSOCKET_BUFFER_SIZE);
|
||||||
|
|
||||||
|
@ -6,8 +6,9 @@ import gearth.protocol.connection.proxy.nitro.NitroConstants;
|
|||||||
import gearth.protocol.packethandler.PacketHandler;
|
import gearth.protocol.packethandler.PacketHandler;
|
||||||
import gearth.protocol.packethandler.nitro.NitroPacketHandler;
|
import gearth.protocol.packethandler.nitro.NitroPacketHandler;
|
||||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||||
import org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension;
|
|
||||||
import org.eclipse.jetty.websocket.jsr356.JsrExtension;
|
import org.eclipse.jetty.websocket.jsr356.JsrExtension;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.websocket.*;
|
import javax.websocket.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -16,6 +17,8 @@ import java.util.*;
|
|||||||
|
|
||||||
public class NitroWebsocketServer extends Endpoint implements NitroSession {
|
public class NitroWebsocketServer extends Endpoint implements NitroSession {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(NitroWebsocketServer.class);
|
||||||
|
|
||||||
private static final HashSet<String> SKIP_HEADERS = new HashSet<>(Arrays.asList(
|
private static final HashSet<String> SKIP_HEADERS = new HashSet<>(Arrays.asList(
|
||||||
"Sec-WebSocket-Extensions",
|
"Sec-WebSocket-Extensions",
|
||||||
"Sec-WebSocket-Key",
|
"Sec-WebSocket-Key",
|
||||||
@ -36,6 +39,8 @@ public class NitroWebsocketServer extends Endpoint implements NitroSession {
|
|||||||
|
|
||||||
public void connect(String websocketUrl, Map<String, List<String>> clientHeaders) throws IOException {
|
public void connect(String websocketUrl, Map<String, List<String>> clientHeaders) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
logger.info("Connecting to origin websocket at {}", websocketUrl);
|
||||||
|
|
||||||
ClientEndpointConfig.Builder builder = ClientEndpointConfig.Builder.create();
|
ClientEndpointConfig.Builder builder = ClientEndpointConfig.Builder.create();
|
||||||
|
|
||||||
builder.extensions(Collections.singletonList(new JsrExtension(new ExtensionConfig("permessage-deflate;client_max_window_bits"))));
|
builder.extensions(Collections.singletonList(new JsrExtension(new ExtensionConfig("permessage-deflate;client_max_window_bits"))));
|
||||||
@ -57,6 +62,8 @@ public class NitroWebsocketServer extends Endpoint implements NitroSession {
|
|||||||
ClientEndpointConfig config = builder.build();
|
ClientEndpointConfig config = builder.build();
|
||||||
|
|
||||||
ContainerProvider.getWebSocketContainer().connectToServer(this, config, URI.create(websocketUrl));
|
ContainerProvider.getWebSocketContainer().connectToServer(this, config, URI.create(websocketUrl));
|
||||||
|
|
||||||
|
logger.info("Connected to origin websocket");
|
||||||
} catch (DeploymentException e) {
|
} catch (DeploymentException e) {
|
||||||
throw new IOException("Failed to deploy websocket client", e);
|
throw new IOException("Failed to deploy websocket client", e);
|
||||||
}
|
}
|
||||||
|
16
G-Earth/src/main/resources/logback.xml
Normal file
16
G-Earth/src/main/resources/logback.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="debug">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<logger name="com.tulskiy.keymaster" level="WARN"/>
|
||||||
|
<logger name="io.netty" level="WARN"/>
|
||||||
|
<logger name="org.littleshoot" level="OFF"/>
|
||||||
|
<logger name="org.eclipse.jetty" level="WARN"/>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue
Block a user