This commit is contained in:
Alessandro Autiero
2024-05-22 16:49:03 +02:00
parent 9f5590d41c
commit d478650e9b
20 changed files with 383 additions and 229 deletions

View File

@@ -57,9 +57,24 @@ void main(List<String> args) async {
throw Exception("Missing game executable at: ${version.location.path}");
}
final serverHost = result["server-host"]?.trim();
if(serverHost?.isEmpty == true){
throw Exception("Missing host name");
}
final serverPort = result["server-port"]?.trim();
if(serverPort?.isEmpty == true){
throw Exception("Missing port");
}
final serverPortNumber = serverPort == null ? null : int.tryParse(serverPort);
if(serverPort != null && serverPortNumber == null){
throw Exception("Invalid port, use only numbers");
}
var started = await startServerCli(
result["server-host"],
result["server-port"],
serverHost,
serverPortNumber,
ServerType.values.firstWhere((element) => element.name == result["server-type"])
);
if(!started){

View File

@@ -30,11 +30,11 @@ Future<void> startGame() async {
Future<void> _startLauncherProcess(FortniteVersion dummyVersion) async {
if (dummyVersion.launcher == null) {
if (dummyVersion.launcherExecutable == null) {
return;
}
_launcherProcess = await Process.start(dummyVersion.launcher!.path, []);
_launcherProcess = await Process.start(dummyVersion.launcherExecutable!.path, []);
suspend(_launcherProcess!.pid);
}

View File

@@ -3,11 +3,11 @@ import 'dart:io';
import 'package:reboot_common/common.dart';
import 'package:reboot_common/src/util/authenticator.dart' as server;
Future<bool> startServerCli(String? host, String? port, ServerType type) async {
Future<bool> startServerCli(String? host, int? port, ServerType type) async {
stdout.writeln("Starting backend server...");
switch(type){
case ServerType.local:
var result = await pingAuthenticator(host ?? kDefaultAuthenticatorHost, port ?? kDefaultAuthenticatorPort.toString());
var result = await pingAuthenticator(host ?? kDefaultAuthenticatorHost, port ?? kDefaultAuthenticatorPort);
if(result == null){
throw Exception("Local backend server is not running");
}
@@ -17,7 +17,7 @@ Future<bool> startServerCli(String? host, String? port, ServerType type) async {
case ServerType.embedded:
stdout.writeln("Starting an embedded server...");
await server.startEmbeddedAuthenticator(false);
var result = await pingAuthenticator(host ?? kDefaultAuthenticatorHost, port ?? kDefaultAuthenticatorPort.toString());
var result = await pingAuthenticator(host ?? kDefaultAuthenticatorHost, port ?? kDefaultAuthenticatorPort);
if(result == null){
throw Exception("Cannot start embedded server");
}
@@ -37,21 +37,7 @@ Future<bool> startServerCli(String? host, String? port, ServerType type) async {
}
}
Future<HttpServer?> _changeReverseProxyState(String host, String port) async {
host = host.trim();
if(host.isEmpty){
throw Exception("Missing host name");
}
port = port.trim();
if(port.isEmpty){
throw Exception("Missing port");
}
if(int.tryParse(port) == null){
throw Exception("Invalid port, use only numbers");
}
Future<HttpServer?> _changeReverseProxyState(String host, int port) async {
try{
var uri = await pingAuthenticator(host, port);
if(uri == null){