diff --git a/MareSynchronosServer/Installation-Linux.md b/MareSynchronosServer/Installation-Linux.md deleted file mode 100644 index f6e4810..0000000 --- a/MareSynchronosServer/Installation-Linux.md +++ /dev/null @@ -1,84 +0,0 @@ -# Installing Mare Server on Ubuntu 20.04 Server LTS - -## Important -- **You _will_ need a valid Certificate for the server.** -- Set one up using LetsEncrypt or use the one provided by your hoster -- The server provided is only guaranteed to run under Ubuntu 20.04 Server LTS. For anything else, you are on your own. The server is provided as a standalone .NET application which does not require .NET Core to be installed. - -## Copy files over -- Connect via SCP and copy over all files to some directory -- The directory will need to be writeable by the user - -## Install MSSQL Server 2019 CU -- Import GPG keys - ```sh - sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - ``` -- Add repository - ```sh - sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)" - ``` -- Install SQL Server 2019 - ``` - sudo apt-get update - sudo apt-get install -y mssql-server - ``` -- Run configuration - ``` - sudo /opt/mssql/bin/mssql-conf setup - ``` -- Install "3) Express" -- Set a password -- Verify server is running - ``` - systemctl status mssql-server --no-pager - ``` -- Optional: set up a separate user for Mare Synchronos - - I'll let you figure that out yourself - - The user will need database creation rights - -## Configure Mare Server -- open provided appsettings.json -- edit `DefaultConnection` to `"Server=localhost;User=sa;Password=;Database=mare;MultipleActiveResultSets=true"` - - if you created a separate user for mare on the SQL Server, specify the username and password here -- edit `CacheDirectory` and set it to a path where the file cache is supposed to be located. i.e. `/home//servercache` - - you will also need to create that folder -- optional: set Port under edit `Url` and change the `+:5000` to `+:` - - - Set up `Certificate` - - Set `Path` to the certificate file path - - Set `Password` to the password of the certificate - - If the certificate file is split in private key and public, set `KeyPath` to the private key file - - Delete all unused keys from `Certificate` - -## Set up Mare Synchonos Server as a Service -- create new file `/etc/systemd/system/MareSynchronosServer.service` with following contents - ``` - [Unit] - Description=Mare Synchronos Service - - [Service] - WorkingDirectory= - ExecStart=/MareSynchronosServer - SysLogIdentifier=MareSynchronosServer - User= - Restart=always - RestartSec=5 - - [Install] - WantedBy=multi-user.target - ``` -- Reload SystemD daemon - ``` - sudo systemctl daemon-reload - ``` -- Enable the service with - ``` - sudo systemctl enable MareSynchronosServer - ``` -- Start the service with - ``` - sudo systemctl start MareSynchronosServer - ``` -- Log in ingame and add a custom server within the Mare Synchronos Plugin configuration under the address `wss://:` -- That should be it and your server ready to go and running \ No newline at end of file diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Files.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Files.cs index ca0a16c..682d632 100644 --- a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Files.cs +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Files.cs @@ -199,6 +199,8 @@ namespace MareSynchronosServer.Hubs UploadFileRequest req = new(); req.FileData = ByteString.CopyFrom(await File.ReadAllBytesAsync(tempFileName).ConfigureAwait(false)); File.Delete(tempFileName); + req.Hash = computedHashString; + req.Uploader = AuthenticatedUserId; _ = await _fileServiceClient.UploadFileAsync(req).ConfigureAwait(false); } catch (Exception ex) diff --git a/MareSynchronosServer/MareSynchronosServer/appsettings.json b/MareSynchronosServer/MareSynchronosServer/appsettings.json index 053a19c..38ca83d 100644 --- a/MareSynchronosServer/MareSynchronosServer/appsettings.json +++ b/MareSynchronosServer/MareSynchronosServer/appsettings.json @@ -27,7 +27,7 @@ "DbContextPoolSize": 2000, "CdnFullUrl": "https:///cache/", "ServiceAddress": "http://localhost:5002", - "StaticFileServiceAddress": "http://localhost:5001" + "StaticFileServiceAddress": "http://localhost:5003" }, "AllowedHosts": "*", "Kestrel": { diff --git a/MareSynchronosServer/MareSynchronosStaticFilesServer/FileService.cs b/MareSynchronosServer/MareSynchronosStaticFilesServer/FileService.cs index 27b2fc6..92044be 100644 --- a/MareSynchronosServer/MareSynchronosStaticFilesServer/FileService.cs +++ b/MareSynchronosServer/MareSynchronosStaticFilesServer/FileService.cs @@ -30,7 +30,6 @@ public class FileService : MareSynchronosShared.Protos.FileService.FileServiceBa public override async Task UploadFile(UploadFileRequest request, ServerCallContext context) { - var filePath = Path.Combine(_basePath, request.Hash); var file = await _mareDbContext.Files.SingleOrDefaultAsync(f => f.Hash == request.Hash && f.UploaderUID == request.Uploader); if (file != null) @@ -83,7 +82,7 @@ public class FileService : MareSynchronosShared.Protos.FileService.FileServiceBa public override Task GetFileSizes(FileSizeRequest request, ServerCallContext context) { FileSizeResponse response = new(); - foreach (var hash in request.Hash) + foreach (var hash in request.Hash.Distinct()) { FileInfo fi = new(Path.Combine(_basePath, hash)); if (fi.Exists) diff --git a/MareSynchronosServer/MareSynchronosStaticFilesServer/Startup.cs b/MareSynchronosServer/MareSynchronosStaticFilesServer/Startup.cs index 40edd0e..da879ea 100644 --- a/MareSynchronosServer/MareSynchronosStaticFilesServer/Startup.cs +++ b/MareSynchronosServer/MareSynchronosStaticFilesServer/Startup.cs @@ -65,7 +65,6 @@ public class Startup public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - app.UseStaticFiles(); app.UseHttpLogging(); app.UseRouting(); diff --git a/MareSynchronosServer/MareSynchronosStaticFilesServer/appsettings.json b/MareSynchronosServer/MareSynchronosStaticFilesServer/appsettings.json index abe9aed..630b597 100644 --- a/MareSynchronosServer/MareSynchronosStaticFilesServer/appsettings.json +++ b/MareSynchronosServer/MareSynchronosStaticFilesServer/appsettings.json @@ -12,6 +12,10 @@ "Endpoints": { "Http": { "Url": "http://+:5001" + }, + "Gprc": { + "Protocols": "Http2", + "Url": "http://+:5003" } } },