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
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,29 @@ This creates:
* `runserver-key.pem`: the certificate private key. Keep this file private.
* `runserver-token.txt`: the authentication token. Keep this file private.

The setup command prints the certificate's SHA-256 fingerprint. The server also prints the same fingerprint each time it starts; this is safe to share with GUI users and is not the authentication token. Start the remote server with the security directory:
The setup command prints the certificate's SHA-256 fingerprint. The server also prints the same fingerprint each time it starts; this is safe to share with GUI users and is not the authentication token. Create a `XTMF2.RunServer.json` file in the server's configuration directory (or pass its path with `-config`):

```json
{
"version": 1,
"serverStorageDirectory": "./xtmf-data",
"listenAddress": "0.0.0.0",
"port": 5000,
"securityDirectory": "./runserver-security",
"additionalAssemblies": [],
"allowDeployment": true,
"runWorkspaceBaseDirectory": "./run-workspaces"
}
```

This is RunServer configuration version 1. Paths in the JSON file are resolved relative to the file. The server derives its `RemoteRuns` and `Deployments` directories from `serverStorageDirectory`; each run gets its own subdirectory under `runWorkspaceBaseDirectory`, which defaults to `serverStorageDirectory/Runs`. Listening outside loopback and enabling deployment both require TLS/token security. Keep the security files private. Start the server with:

```bash
dotnet run -c Release --project src/XTMF2.Client/XTMF2.RunServer.csproj -- -tcp 0.0.0.0 5000 -security ./runserver-security
dotnet run -c Release --project src/XTMF2.Client/XTMF2.RunServer.csproj -- -config ./XTMF2.RunServer.json
```

If no arguments are supplied, RunServer looks for `XTMF2.RunServer.config` beside its executable. The GUI-launched local RunServer receives the GUI's configured storage directory directly and binds to loopback on an ephemeral port. Each remote RunServer operator manages the JSON file on that server; GUI endpoint settings only describe how clients connect.

In XTMF2, open **Settings**, open **RunServers**, and add a remote endpoint. Enter:

1. The remote machine's address and TCP port.
Expand Down
281 changes: 239 additions & 42 deletions src/XTMF2.Client/Program.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/XTMF2.GUI/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq;
using System.Threading.Tasks;
using XTMF2;
using XTMF2.Configuration;
using XTMF2.GUI.Resources;
using XTMF2.GUI.Views;

Expand Down Expand Up @@ -53,7 +54,7 @@ public override void OnFrameworkInitializationCompleted()
try
{
// Create the XTMF Runtime
Runtime = XTMFRuntime.CreateRuntime();
Runtime = XTMFRuntime.CreateRuntime(new XTMFStoragePaths(Properties.Settings.Default.DataRoot));
}
catch (XTMFCodeStyleError codeError)
{
Expand Down
5 changes: 5 additions & 0 deletions src/XTMF2.GUI/Properties/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License
using System.IO;
using System.Linq;
using System.Text.Json;
using XTMF2.Configuration;

namespace XTMF2.GUI.Properties;

Expand Down Expand Up @@ -80,6 +81,7 @@ public Settings()
public string AiModel { get; set; } = "llama3.2";
public string OllamaEndpoint { get; set; } = "http://localhost:11434";
public int AiMaxCompactionCycles { get; set; } = 100;
public string DataRoot { get; set; } = XTMFStoragePaths.GetDefaultDesktopDataRoot();
public List<RunServerEndpoint> RunServers { get; set; } = new() { RunServerEndpoint.CreateLocal() };

public void Save()
Expand Down Expand Up @@ -127,6 +129,9 @@ private static Settings Load()
settings.AiMaxCompactionCycles = loaded.AiMaxCompactionCycles is < 1 or > 100
? 100
: loaded.AiMaxCompactionCycles;
settings.DataRoot = string.IsNullOrWhiteSpace(loaded.DataRoot)
? XTMFStoragePaths.GetDefaultDesktopDataRoot()
: loaded.DataRoot;
settings.RunServers = NormalizeRunServers(loaded.RunServers);
}
}
Expand Down
43 changes: 20 additions & 23 deletions src/XTMF2.GUI/RunController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ You should have received a copy of the GNU General Public License
using XTMF2.Bus;
using XTMF2.Bus.Optimization;
using XTMF2.Controllers;
using XTMF2.Configuration;
using XTMF2.Editing;
using XTMF2.GUI.ViewModels;
using XTMF2.GUI.Properties;
Expand Down Expand Up @@ -157,36 +158,44 @@ private static bool InitializeInSeparateProcess(XTMFRuntime runtime, out RunCont
{
var xtmfGUIFilePath = typeof(XTMF2.GUI.Program).Assembly.Location;
var xtmfClientFileName = Path.Combine(Path.GetDirectoryName(xtmfGUIFilePath)!, "XTMF2.RunServer.dll");
var pipeName = $"XTMF2-RunServer-{Environment.ProcessId}-{Guid.NewGuid():N}";
Process? client = null;
try
{
var startInfo = new ProcessStartInfo()
{
FileName = "dotnet",
Arguments = $"\"{xtmfClientFileName}\" -tcp 127.0.0.1 0",
UseShellExecute = false,
CreateNoWindow = OperatingSystem.IsWindows(),
WorkingDirectory = Environment.CurrentDirectory,
RedirectStandardOutput = true,
RedirectStandardError = true
};
startInfo.ArgumentList.Add(xtmfClientFileName);
startInfo.ArgumentList.Add("-serverStorageDirectory");
startInfo.ArgumentList.Add(runtime.SystemConfiguration.StoragePaths.DataRoot);
startInfo.ArgumentList.Add("-namedPipe");
startInfo.ArgumentList.Add(pipeName);
client = new() { StartInfo = startInfo, EnableRaisingEvents = true };
client.ErrorDataReceived += (_, eventArgs) =>
client.OutputDataReceived += (_, eventArgs) =>
{
if (eventArgs.Data is not null)
Debug.WriteLine($"[Local RunServer] {eventArgs.Data}");
};
client.Start();
client.BeginErrorReadLine();
var listenLine = client.StandardOutput.ReadLine();
if (!TryParseListeningPort(listenLine, out var hostPort))
client.ErrorDataReceived += (_, eventArgs) =>
{
error = "The local RunServer did not report a listening TCP port.";
controller = null;
return false;
}
if (!XTMF2.Bus.CreateStreams.CreateTcpClient("127.0.0.1", hostPort, out var hostStream, out error))
if (eventArgs.Data is not null)
Debug.WriteLine($"[Local RunServer] {eventArgs.Data}");
};
if (!XTMF2.Bus.CreateStreams.CreateNewNamedPipeHost(pipeName, out var hostStream, out error, () =>
{
client.Start();
client.BeginOutputReadLine();
client.BeginErrorReadLine();
}) || hostStream is null)
{
if (client is { HasExited: false })
client.Kill(entireProcessTree: true);
controller = null;
return false;
}
Expand Down Expand Up @@ -820,18 +829,6 @@ private bool SendRun(
return true;
}

private static bool TryParseListeningPort(string? line, out int port)
{
port = 0;
const string prefix = "RunServer listening on ";
if (line is null || !line.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
return false;

var endpoint = line[prefix.Length..];
var separator = endpoint.LastIndexOf(':');
return separator >= 0 && int.TryParse(endpoint[(separator + 1)..], out port) && port is > 0 and <= 65535;
}

private RunController(XTMFRuntime runtime, HostBus hostBus, Process? runServerProcess = null)
{
Runtime = runtime;
Expand Down
Loading
Loading