proxy progress
This commit is contained in:
parent
d089d78eae
commit
9c03dc8aa6
|
@ -21,6 +21,7 @@ import com.rusefi.io.LinkManager;
|
|||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||
import com.rusefi.maintenance.ExecHelper;
|
||||
import com.rusefi.proxy.NetworkConnector;
|
||||
import com.rusefi.server.Backend;
|
||||
import com.rusefi.tools.online.Online;
|
||||
import com.rusefi.tune.xml.Msq;
|
||||
|
@ -62,6 +63,8 @@ public class ConsoleTools {
|
|||
registerTool("compile_fsio_file", ConsoleTools::runCompileTool, "Convert all lines from a file to RPN form.");
|
||||
|
||||
registerTool("proxy_server", Backend::start, "NOT A USER TOOL");
|
||||
registerTool("network_connector", NetworkConnector::start, "Connect your rusEFI ECU to rusEFI Online");
|
||||
registerTool("network_authenticator", LocalApplicationProxy::start, "rusEFI Online Authenticator");
|
||||
|
||||
registerTool("print_auth_token", args -> printAuthToken(), "Print current rusEFI Online authentication token.");
|
||||
registerTool(SET_AUTH_TOKEN, ConsoleTools::setAuthToken, "Set rusEFI authentication token.");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.opensr5.Logger;
|
||||
import com.rusefi.proxy.BaseBroadcastingThread;
|
||||
import com.rusefi.server.ControllerInfo;
|
||||
import com.rusefi.server.SessionDetails;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.rusefi.io.ConnectionStateListener;
|
|||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.commands.HelloCommand;
|
||||
import com.rusefi.proxy.NetworkConnector;
|
||||
import com.rusefi.server.*;
|
||||
import com.rusefi.tools.online.ProxyClient;
|
||||
import org.junit.Before;
|
||||
|
@ -40,6 +41,8 @@ public class ServerTest {
|
|||
|
||||
@Before
|
||||
public void setTestCertificate() throws MalformedURLException {
|
||||
NetworkConnector.RUSEFI_PROXY_HOSTNAME = ProxyClient.LOCALHOST;
|
||||
|
||||
File certificate = new File("certificate/test.jks");
|
||||
Backend.setupCertificates(certificate, "password");
|
||||
}
|
||||
|
@ -200,8 +203,7 @@ public class ServerTest {
|
|||
// start authenticator
|
||||
|
||||
int authenticatorPort = 7004; // local port on which authenticator accepts connections from Tuner Studio
|
||||
IoStream authenticatorToProxyStream = TestHelper.secureConnectToLocalhost(serverPortForRemoteUsers, logger);
|
||||
LocalApplicationProxy.startAndRun(logger, applicationRequest, authenticatorPort, authenticatorToProxyStream);
|
||||
LocalApplicationProxy.startAndRun(logger, controllerPort, applicationRequest, authenticatorPort);
|
||||
|
||||
|
||||
CountDownLatch connectionEstablishedCountDownLatch = new CountDownLatch(1);
|
||||
|
|
|
@ -4,8 +4,11 @@ import com.opensr5.Logger;
|
|||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.commands.HelloCommand;
|
||||
import com.rusefi.io.tcp.BinaryProtocolProxy;
|
||||
import com.rusefi.io.tcp.TcpIoStream;
|
||||
import com.rusefi.proxy.NetworkConnector;
|
||||
import com.rusefi.server.ApplicationRequest;
|
||||
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import java.io.IOException;
|
||||
|
||||
public class LocalApplicationProxy {
|
||||
|
@ -22,7 +25,8 @@ public class LocalApplicationProxy {
|
|||
* @param authenticatorPort local port we would bind for TunerStudio to connect to
|
||||
* @param authenticatorToProxyStream
|
||||
*/
|
||||
static void startAndRun(Logger logger, ApplicationRequest applicationRequest, int authenticatorPort, IoStream authenticatorToProxyStream) throws IOException {
|
||||
static void startAndRun(Logger logger, int controllerPort, ApplicationRequest applicationRequest, int authenticatorPort) throws IOException {
|
||||
IoStream authenticatorToProxyStream = new TcpIoStream(logger, SSLSocketFactory.getDefault().createSocket(NetworkConnector.RUSEFI_PROXY_HOSTNAME, controllerPort));
|
||||
LocalApplicationProxy localApplicationProxy = new LocalApplicationProxy(logger, applicationRequest);
|
||||
localApplicationProxy.run(authenticatorToProxyStream);
|
||||
|
||||
|
@ -33,4 +37,7 @@ public class LocalApplicationProxy {
|
|||
// right from connection push session authentication data
|
||||
new HelloCommand(logger, applicationRequest.toJson()).handle(authenticatorToProxyStream);
|
||||
}
|
||||
|
||||
public static void start(String[] strings) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.rusefi;
|
||||
package com.rusefi.proxy;
|
||||
|
||||
import com.opensr5.Logger;
|
||||
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
|
@ -1,26 +1,26 @@
|
|||
package com.rusefi;
|
||||
package com.rusefi.proxy;
|
||||
|
||||
import com.opensr5.Logger;
|
||||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.commands.HelloCommand;
|
||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||
import com.rusefi.io.tcp.TcpIoStream;
|
||||
import com.rusefi.proxy.BaseBroadcastingThread;
|
||||
import com.rusefi.server.ControllerInfo;
|
||||
import com.rusefi.server.SessionDetails;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
import static com.rusefi.tools.online.ProxyClient.LOCALHOST;
|
||||
|
||||
/**
|
||||
* Connector between rusEFI ECU and rusEFI server
|
||||
*/
|
||||
public class NetworkConnector {
|
||||
public static String RUSEFI_PROXY_HOSTNAME = "proxy.rusefi.com";
|
||||
|
||||
@NotNull
|
||||
static SessionDetails runNetworkConnector(int serverPortForControllers, IoStream targetEcuSocket, final Logger logger, String authToken) throws IOException {
|
||||
public static SessionDetails runNetworkConnector(int serverPortForControllers, IoStream targetEcuSocket, final Logger logger, String authToken) throws IOException {
|
||||
HelloCommand.send(targetEcuSocket, logger);
|
||||
String controllerSignature = HelloCommand.getHelloResponse(targetEcuSocket.getDataBuffer(), logger);
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class NetworkConnector {
|
|||
|
||||
SessionDetails deviceSessionDetails = new SessionDetails(ci, authToken, SessionDetails.createOneTimeCode());
|
||||
|
||||
BaseBroadcastingThread baseBroadcastingThread = new BaseBroadcastingThread(SSLSocketFactory.getDefault().createSocket(LOCALHOST, serverPortForControllers),
|
||||
BaseBroadcastingThread baseBroadcastingThread = new BaseBroadcastingThread(SSLSocketFactory.getDefault().createSocket(RUSEFI_PROXY_HOSTNAME, serverPortForControllers),
|
||||
deviceSessionDetails,
|
||||
logger) {
|
||||
@Override
|
||||
|
@ -44,4 +44,7 @@ public class NetworkConnector {
|
|||
baseBroadcastingThread.start();
|
||||
return deviceSessionDetails;
|
||||
}
|
||||
|
||||
public static void start(String[] strings) {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue