mirror of https://github.com/rusefi/rusefi-1.git
proxy progress
This commit is contained in:
parent
7bedd0e799
commit
d089d78eae
|
@ -101,6 +101,12 @@
|
||||||
<echo message="Building ${server_jar_file}"/>
|
<echo message="Building ${server_jar_file}"/>
|
||||||
|
|
||||||
<jar destfile="${server_jar_file}">
|
<jar destfile="${server_jar_file}">
|
||||||
|
<manifest>
|
||||||
|
<attribute name="Main-Class" value="com.rusefi.Launcher"/>
|
||||||
|
<attribute name="Built-Date" value="${TODAY}"/>
|
||||||
|
<attribute name="Signature-Vendor" value="rusEFI LLC"/>
|
||||||
|
</manifest>
|
||||||
|
|
||||||
<zipfileset src="${jar_file}" includes="**/*.class"/>
|
<zipfileset src="${jar_file}" includes="**/*.class"/>
|
||||||
<zipfileset src="lib/server/cactoos.jar" includes="**/*.class"/>
|
<zipfileset src="lib/server/cactoos.jar" includes="**/*.class"/>
|
||||||
<zipfileset src="lib/server/javax.json.jar" includes="**/*.class"/>
|
<zipfileset src="lib/server/javax.json.jar" includes="**/*.class"/>
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||||
import com.rusefi.maintenance.ExecHelper;
|
import com.rusefi.maintenance.ExecHelper;
|
||||||
|
import com.rusefi.server.Backend;
|
||||||
import com.rusefi.tools.online.Online;
|
import com.rusefi.tools.online.Online;
|
||||||
import com.rusefi.tune.xml.Msq;
|
import com.rusefi.tune.xml.Msq;
|
||||||
import com.rusefi.ui.AuthTokenPanel;
|
import com.rusefi.ui.AuthTokenPanel;
|
||||||
|
@ -60,6 +61,8 @@ public class ConsoleTools {
|
||||||
registerTool("compile_fsio_line", ConsoleTools::invokeCompileExpressionTool, "Convert a line to RPN form.");
|
registerTool("compile_fsio_line", ConsoleTools::invokeCompileExpressionTool, "Convert a line to RPN form.");
|
||||||
registerTool("compile_fsio_file", ConsoleTools::runCompileTool, "Convert all lines from a file to RPN form.");
|
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("print_auth_token", args -> printAuthToken(), "Print current rusEFI Online authentication token.");
|
registerTool("print_auth_token", args -> printAuthToken(), "Print current rusEFI Online authentication token.");
|
||||||
registerTool(SET_AUTH_TOKEN, ConsoleTools::setAuthToken, "Set rusEFI authentication token.");
|
registerTool(SET_AUTH_TOKEN, ConsoleTools::setAuthToken, "Set rusEFI authentication token.");
|
||||||
registerTool("upload_tune", ConsoleTools::uploadTune, "Upload specified tune file using auth token from settings");
|
registerTool("upload_tune", ConsoleTools::uploadTune, "Upload specified tune file using auth token from settings");
|
||||||
|
|
|
@ -41,15 +41,7 @@ public class ServerTest {
|
||||||
@Before
|
@Before
|
||||||
public void setTestCertificate() throws MalformedURLException {
|
public void setTestCertificate() throws MalformedURLException {
|
||||||
File certificate = new File("certificate/test.jks");
|
File certificate = new File("certificate/test.jks");
|
||||||
if (!certificate.exists())
|
Backend.setupCertificates(certificate, "password");
|
||||||
throw new IllegalStateException("Certificate not found " + certificate);
|
|
||||||
|
|
||||||
String file = certificate.toURI().toURL().getFile();
|
|
||||||
String password = "password";
|
|
||||||
System.setProperty("javax.net.ssl.keyStore", file);
|
|
||||||
System.setProperty("javax.net.ssl.keyStorePassword", password);
|
|
||||||
System.setProperty("javax.net.ssl.trustStore", file);
|
|
||||||
System.setProperty("javax.net.ssl.trustStorePassword", password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<orderEntry type="library" name="jSerialComm" level="project" />
|
<orderEntry type="library" name="jSerialComm" level="project" />
|
||||||
<orderEntry type="library" name="json-simple" level="project" />
|
<orderEntry type="library" name="json-simple" level="project" />
|
||||||
<orderEntry type="module" module-name="models" />
|
<orderEntry type="module" module-name="models" />
|
||||||
<orderEntry type="module" module-name="proxy_server" scope="TEST" />
|
<orderEntry type="module" module-name="proxy_server" />
|
||||||
<orderEntry type="library" scope="TEST" name="takes" level="project" />
|
<orderEntry type="library" scope="TEST" name="takes" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -18,7 +18,9 @@ import org.takes.rs.RsJson;
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
import javax.json.JsonArrayBuilder;
|
import javax.json.JsonArrayBuilder;
|
||||||
import javax.json.JsonObject;
|
import javax.json.JsonObject;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -70,6 +72,17 @@ public class Backend {
|
||||||
// }, "rusEFI Server Cleanup").start();
|
// }, "rusEFI Server Cleanup").start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setupCertificates(File certificate, String password) throws MalformedURLException {
|
||||||
|
if (!certificate.exists())
|
||||||
|
throw new IllegalStateException("Certificate not found " + certificate);
|
||||||
|
Objects.requireNonNull(password, "password");
|
||||||
|
|
||||||
|
String file = certificate.toURI().toURL().getFile();
|
||||||
|
System.setProperty("javax.net.ssl.keyStore", file);
|
||||||
|
System.setProperty("javax.net.ssl.keyStorePassword", password);
|
||||||
|
System.setProperty("javax.net.ssl.trustStore", file);
|
||||||
|
System.setProperty("javax.net.ssl.trustStorePassword", password);
|
||||||
|
}
|
||||||
|
|
||||||
public void runApplicationConnector(int serverPortForApplications, Listener serverSocketCreationCallback) {
|
public void runApplicationConnector(int serverPortForApplications, Listener serverSocketCreationCallback) {
|
||||||
// connection from authenticator app which proxies for Tuner Studio
|
// connection from authenticator app which proxies for Tuner Studio
|
||||||
|
@ -219,4 +232,17 @@ public class Backend {
|
||||||
return clients.size();
|
return clients.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void start(String[] args) throws MalformedURLException {
|
||||||
|
setupCertificates(new File("keystore.jks"), System.getProperty("RUSEFI_PROXY_PASSWORD"));
|
||||||
|
|
||||||
|
Function<String, UserDetails> userDetailsFunction = new JsonUserDetailsResolver();
|
||||||
|
|
||||||
|
Backend backend = new Backend(userDetailsFunction, 8001, Logger.CONSOLE);
|
||||||
|
backend.runApplicationConnector(8002, parameter -> {
|
||||||
|
});
|
||||||
|
backend.runControllerConnector(8003, parameter -> {
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.rusefi.server;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class JsonUserDetailsResolver implements Function<String, UserDetails> {
|
||||||
|
@Override
|
||||||
|
public UserDetails apply(String authToken) {
|
||||||
|
// todo
|
||||||
|
return new UserDetails("", 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.rusefi.server;
|
||||||
|
|
||||||
|
public class JsonUserDetailsResolverSandbox {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JsonUserDetailsResolver resolver = new JsonUserDetailsResolver();
|
||||||
|
|
||||||
|
System.out.println(resolver.apply("haba-haba"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue