Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scouter.client.build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<module>../scouter.client.product</module>
</modules>
<properties>
<tycho-version>2.3.0</tycho-version>
<tycho-version>2.5.0</tycho-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>eclipse-simultaneous-2021-09</id>
<id>eclipse-simultaneous-2021-12</id>
<layout>p2</layout>
<url>https://download.eclipse.org/releases/2021-09/</url>
<url>https://download.eclipse.org/releases/2021-12/</url>
</repository>
</repositories>

Expand All @@ -35,7 +35,7 @@
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<configuration>
<environments>
<environment>
<os>win32</os>
Expand Down
26 changes: 15 additions & 11 deletions scouter.client/.classpath
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry exported="true" kind="lib" path="lib/scouter.common.jar" sourcepath="/scouter.common"/>
<classpathentry exported="true" kind="lib" path="lib/scouter.server.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate-core-3.3.2.GA.jar"/>
<classpathentry exported="true" kind="lib" path="lib/opencsv-2.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/opal-1.0.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/activation-1.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-api-2.3.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-core-2.3.0.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-impl-2.3.0.1.jar"/>
<classpathentry kind="lib" path="lib/scouter.common.jar" sourcepath="/scouter.common"/>
<classpathentry kind="lib" path="lib/scouter.server.jar"/>
<classpathentry kind="lib" path="lib/hibernate-core-3.3.2.GA.jar"/>
<classpathentry kind="lib" path="lib/opencsv-2.4.jar"/>
<classpathentry kind="lib" path="lib/opal-1.0.3.jar"/>
<classpathentry kind="lib" path="lib/activation-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/jaxb-api-2.3.1.jar"/>
<classpathentry kind="lib" path="lib/jaxb-core-2.3.0.1.jar"/>
<classpathentry kind="lib" path="lib/jaxb-impl-2.3.0.1.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion scouter.client/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Require-Bundle:
org.eclipse.swt,
org.eclipse.e4.core.commands,
org.eclipse.e4.ui.services
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
lib/scouter.common.jar,
Expand Down
64 changes: 34 additions & 30 deletions scouter.client/src/scouter/client/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import scouter.client.net.LoginMgr;
import scouter.client.net.LoginResult;
import scouter.client.popup.LoginDialog2;
import scouter.client.popup.LoginDialog2.ILoginDialog;
import scouter.client.preferences.PreferenceConstants;
import scouter.client.preferences.ServerPrefUtil;
import scouter.client.server.Server;
Expand All @@ -41,6 +40,8 @@
import java.util.HashSet;
import java.util.Set;

import static java.io.File.separator;

/**
* This class controls all aspects of the application's execution
*/
Expand All @@ -53,15 +54,15 @@ public Object start(IApplicationContext context) throws Exception {
// instanceLocation.set(new URL("file", null, System.getProperty("user.home") + "/scouter-workspace-test"), false);

String workspaceRootName = instanceLocation.getURL().getFile();
String importWorkingDirName = workspaceRootName + "/import-working";
String importWorkingDirName = workspaceRootName + separator+ "import-working";

try {
ClientFileUtil.copy(new File(importWorkingDirName + "/" + ClientFileUtil.XLOG_COLUMN_FILE),
new File(workspaceRootName + "/" + ClientFileUtil.XLOG_COLUMN_FILE));
ClientFileUtil.copy(new File(importWorkingDirName + "/" + ClientFileUtil.GROUP_FILE),
new File(workspaceRootName + "/" + ClientFileUtil.GROUP_FILE));
ClientFileUtil.copy(new File(importWorkingDirName + "/" + ClientFileUtil.WORKSPACE_METADATA_DIR),
new File(workspaceRootName + "/" + ClientFileUtil.WORKSPACE_METADATA_DIR));
ClientFileUtil.copy(new File(importWorkingDirName + separator + ClientFileUtil.XLOG_COLUMN_FILE),
new File(workspaceRootName + separator + ClientFileUtil.XLOG_COLUMN_FILE));
ClientFileUtil.copy(new File(importWorkingDirName + separator + ClientFileUtil.GROUP_FILE),
new File(workspaceRootName + separator + ClientFileUtil.GROUP_FILE));
ClientFileUtil.copy(new File(importWorkingDirName + separator + ClientFileUtil.WORKSPACE_METADATA_DIR),
new File(workspaceRootName + separator + ClientFileUtil.WORKSPACE_METADATA_DIR));
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -72,7 +73,7 @@ public Object start(IApplicationContext context) throws Exception {
Object exitStrategy = IApplication.EXIT_OK;
try {
boolean loginSuccessed = loginAutomaticallyWhenAutoLoginEnabled();
if (loginSuccessed == false) {
if (!loginSuccessed) {
loginSuccessed = openLoginDialog(display);
}
if (loginSuccessed) {
Expand All @@ -85,15 +86,11 @@ public Object start(IApplicationContext context) throws Exception {
}

private boolean openLoginDialog(Display display) {
LoginDialog2 dialog = new LoginDialog2(display.getActiveShell(), new ILoginDialog() {
@Override
public void loginSuccess(String serverAddr, int serverId) {
Server server = ServerManager.getInstance().getServer(serverId);
ServerPrefUtil.storeDefaultServer(server.getIp()+":"+server.getPort());
ServerManager.getInstance().setDefaultServer(server);
}

}, LoginDialog2.TYPE_STARTUP, null);
LoginDialog2 dialog = new LoginDialog2(display.getActiveShell(), (serverAddr, serverId) -> {
Server server = ServerManager.getInstance().getServer(serverId);
ServerPrefUtil.storeDefaultServer(server.getIp()+":"+server.getPort());
ServerManager.getInstance().setDefaultServer(server);
}, LoginDialog2.TYPE_STARTUP, null, null);
return (dialog.open() == Window.OK);
}

Expand All @@ -102,18 +99,28 @@ private boolean loginAutomaticallyWhenAutoLoginEnabled() {
String[] serverList = ServerPrefUtil.getStoredServerList();
if (serverList != null && serverList.length > 0) {
String[] autoList = ServerPrefUtil.getStoredAutoLoginServerList();
HashSet<String> autoSet = new HashSet<String>();
HashSet<String> autoSet = new HashSet<>();
if (autoList != null && autoList.length > 0) {
autoSet = new HashSet<String>(Arrays.asList(autoList));
autoSet = new HashSet<>(Arrays.asList(autoList));
}
String defaultSrv = ServerPrefUtil.getStoredDefaultServer();
ServerManager manager = ServerManager.getInstance();
for (String addr : serverList) {
String[] iport = addr.split(":");
if (iport == null || iport.length < 2) {
if (iport.length < 2) {
continue;
}
Server server = new Server(iport[0], iport[1]);

String socksIp = null;
String socksPort = null;
if (ServerPrefUtil.isSocksLogin(addr)) {
String socksAddr = ServerPrefUtil.getStoredSocksServer(addr);
String[] socksAddrs = socksAddr.split(":");
socksIp = socksAddrs[0];
socksPort = socksAddrs[1];
}

Server server = new Server(iport[0], iport[1], null, socksIp, socksPort);
if (addr.equals(defaultSrv)) {
manager.setDefaultServer(server);
} else {
Expand All @@ -125,7 +132,7 @@ private boolean loginAutomaticallyWhenAutoLoginEnabled() {
int index = accountInfo.indexOf(PreferenceConstants.P_SVR_DIVIDER);
if (index > -1) {
String id = accountInfo.substring(0, index);
String pwd = accountInfo.substring(index + 1, accountInfo.length());
String pwd = accountInfo.substring(index + 1);
LoginResult result = LoginMgr.silentLogin(server, id, pwd);
if (result.success) {
autoLogined = true;
Expand All @@ -134,7 +141,7 @@ private boolean loginAutomaticallyWhenAutoLoginEnabled() {
}
}
}
if (autoLogined && autoSet.contains(defaultSrv) == false) {
if (autoLogined && !autoSet.contains(defaultSrv)) {
Set<Integer> openSet = manager.getOpenServerList();
Integer[] array = openSet.toArray(new Integer[openSet.size()]);
Server server = manager.getServer(array[0]);
Expand All @@ -160,12 +167,9 @@ public void stop() {
if (workbench == null)
return;
final Display display = workbench.getDisplay();
display.syncExec(new Runnable() {

public void run() {
if (!display.isDisposed())
workbench.close();
}
display.syncExec(() -> {
if (!display.isDisposed())
workbench.close();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
import org.eclipse.jface.action.Action;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IWorkbenchWindow;

import scouter.client.popup.LoginDialog2;
import scouter.client.util.ImageUtil;


public class AddServerAction extends Action {
public final static String ID = AddServerAction.class.getName();
public static final String ID = AddServerAction.class.getName();

private final IWorkbenchWindow window;

Expand All @@ -42,9 +41,10 @@ public AddServerAction(IWorkbenchWindow window, String label, Image image) {

LoginDialog2 dialog;

@Override
public void run() {
if (window != null) {
dialog = new LoginDialog2(window.getShell(), null, LoginDialog2.TYPE_ADD_SERVER, null);
dialog = new LoginDialog2(window.getShell(), null, LoginDialog2.TYPE_ADD_SERVER, null, null);
dialog.open();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public void run() {
ConsoleProxy.errorSafe(result.getErrorMessage());
}
} else {
LoginDialog2 dialog = new LoginDialog2(Display.getDefault().getActiveShell(), null, LoginDialog2.TYPE_OPEN_SERVER, server.getIp() + ":" + server.getPort());

LoginDialog2 dialog = new LoginDialog2(Display.getDefault().getActiveShell(), null, LoginDialog2.TYPE_OPEN_SERVER, server.getIp() + ":" + server.getPort(), server.getSocksAddr());
dialog.open();
}
}
Expand Down
22 changes: 16 additions & 6 deletions scouter.client/src/scouter/client/net/ClientTCP.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,6 +20,7 @@
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Socket;

import scouter.client.server.Server;
Expand All @@ -31,18 +32,24 @@


public class ClientTCP{

Socket socket;
DataInputX in;
DataOutputX out;

public void open(int serverId) {
public void open(int serverId, boolean socksLogin) {
close();
Server server = ServerManager.getInstance().getServer(serverId);
if (server == null) {
return;
}
try {
socket = new Socket();
if (socksLogin) {
InetSocketAddress proxyAddr = new InetSocketAddress(server.getSocksIp(), server.getSocksPort() );
socket = new Socket(new Proxy(Proxy.Type.SOCKS, proxyAddr));
}else {
socket = new Socket();
}
///
socket.setKeepAlive(true);
socket.setTcpNoDelay(true);
Expand All @@ -58,8 +65,11 @@ public void open(int serverId) {
out.writeInt(NetCafe.TCP_CLIENT);
out.flush();
//*************//
if (server.isConnected() == false) {
System.out.println("Success to connect " + server.getIp() + ":" + server.getPort());
if (!server.isConnected()) {
System.out.println(
String.format("Success to connect %s:%d (%s)",
server.getIp(), server.getPort(),
server.isSocksLogin()?server.getSocksIp()+":"+server.getSocksPort() : "direct"));
}
server.setConnected(true);
} catch (Throwable t) {
Expand All @@ -80,7 +90,7 @@ public DataInputX getInput() {
}

public boolean isSessionOk() {
return socket != null && socket.isClosed() == false;
return socket != null && !socket.isClosed();
}

public void close() {
Expand Down
8 changes: 4 additions & 4 deletions scouter.client/src/scouter/client/net/ConnectionPool.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,9 +21,9 @@

public class ConnectionPool {

private final static int POOL_SIZE = 3;
private static final int POOL_SIZE = 3;

private LinkedList<TcpProxy> pool = new LinkedList<TcpProxy>();
private final LinkedList<TcpProxy> pool = new LinkedList<>();

public int size() {
return pool.size();
Expand All @@ -41,7 +41,7 @@ void put(TcpProxy t) {
}

public void closeAll() {
while (pool.size() > 0) {
while (!pool.isEmpty()) {
pool.removeFirst().close();
}
}
Expand Down
4 changes: 2 additions & 2 deletions scouter.client/src/scouter/client/net/INetReader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,5 +23,5 @@


public interface INetReader {
public void process(DataInputX in) throws IOException;
void process(DataInputX in) throws IOException;
}
3 changes: 3 additions & 0 deletions scouter.client/src/scouter/client/net/LoginMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public static LoginResult silentLogin(Server server, String user, String passwor
param.put("pass", password);
param.put("version", Version.getClientFullVersion());
param.put("hostname", SysJMX.getHostName());
param.put("isSocks", server.isSocksLogin());
param.put("socksIp", server.getSocksIp());
param.put("socksPort", server.getSocksPort());

MapPack out = TcpProxy.loginProxy(server.getId(), param);
if (out == null) {
Expand Down
Loading