From 05e9ca46467359670d2ba088ef20704ff30a10b8 Mon Sep 17 00:00:00 2001 From: mischa <16416509+miwarnec@users.noreply.github.com> Date: Fri, 3 Nov 2023 19:39:19 +0100 Subject: [PATCH] feature: Edgegap Hosting Plugin (#3636) * edgegap plugin from https://github.com/edgegap/edgegap-unity-plugin * newtonsoft.json plugin from https://github.com/JamesNK/Newtonsoft.Json/releases/tag/13.0.3 ( * fix stylesheet paths * version * fix stylesheet paths * syntax: remove redundant private identifiers * readme * syntax: use explicit type instead of var * syntax: remove redundant private identifiers * styling * rename folder * plugins * styles * readme updated * fix deprecated warning * mark mirror changes * naming * stylesheet path const * namespace Edgegap * remove unused imports * delete scenes * syntax * mirror.hosting.asmdef * only in editor * syntax * show error in error window * fix typo * syntax * RunCommand_DockerVersion helper to prepare for platform indepenent code * add logging * logging better * syntax * mac and linux cmd docker version support * syntax * improve error * syntax * check linux build support * detailed instructions * restart warning * gitignore builds * mirror change mark * docker build and push command platform independent * improve log * helpful docker daemon error * unauthorized access error --- .gitignore | 1 + Assets/Mirror/Hosting.meta | 8 + Assets/Mirror/Hosting/Edgegap.meta | 8 + Assets/Mirror/Hosting/Edgegap/Editor.meta | 8 + .../Edgegap/Editor/EdgegapBuildUtils.cs | 219 ++++++ .../Edgegap/Editor/EdgegapBuildUtils.cs.meta | 11 + .../Edgegap/Editor/EdgegapScriptEditor.cs | 27 + .../Editor/EdgegapScriptEditor.cs.meta | 11 + .../Edgegap/Editor/EdgegapServerData.uss | 81 ++ .../Edgegap/Editor/EdgegapServerData.uss.meta | 11 + .../Editor/EdgegapServerDataManager.cs | 242 ++++++ .../Editor/EdgegapServerDataManager.cs.meta | 11 + .../Edgegap/Editor/EdgegapToolScript.cs | 15 + .../Edgegap/Editor/EdgegapToolScript.cs.meta | 11 + .../Hosting/Edgegap/Editor/EdgegapWindow.cs | 698 ++++++++++++++++++ .../Edgegap/Editor/EdgegapWindow.cs.meta | 11 + .../Hosting/Edgegap/Editor/EdgegapWindow.uss | 60 ++ .../Edgegap/Editor/EdgegapWindow.uss.meta | 11 + .../Hosting/Edgegap/Editor/EdgegapWindow.uxml | 52 ++ .../Edgegap/Editor/EdgegapWindow.uxml.meta | 10 + .../Mirror/Hosting/Edgegap/Editor/Fonts.meta | 8 + .../Edgegap/Editor/Fonts/BaronNeue.otf | Bin 0 -> 27176 bytes .../Edgegap/Editor/Fonts/BaronNeue.otf.meta | 21 + .../Mirror/Hosting/Edgegap/Editor/Images.meta | 8 + .../Images/logo_transparent_400_alpha25.png | Bin 0 -> 12831 bytes .../logo_transparent_400_alpha25.png.meta | 96 +++ Assets/Mirror/Hosting/Edgegap/Enums.meta | 8 + .../Hosting/Edgegap/Enums/ApiEnvironment.cs | 71 ++ .../Edgegap/Enums/ApiEnvironment.cs.meta | 11 + .../Hosting/Edgegap/Enums/ServerStatus.cs | 84 +++ .../Edgegap/Enums/ServerStatus.cs.meta | 11 + .../Mirror/Hosting/Edgegap/Enums/ToolState.cs | 46 ++ .../Hosting/Edgegap/Enums/ToolState.cs.meta | 11 + Assets/Mirror/Hosting/Edgegap/Models.meta | 8 + .../Models/AppVersionUpdatePatchData.cs | 16 + .../Models/AppVersionUpdatePatchData.cs.meta | 11 + .../Hosting/Edgegap/Models/DeployPostData.cs | 24 + .../Edgegap/Models/DeployPostData.cs.meta | 11 + Assets/Mirror/Hosting/Edgegap/Models/SDK.meta | 8 + .../Models/SDK/ApiModelContainercrashdata.cs | 63 ++ .../SDK/ApiModelContainercrashdata.cs.meta | 11 + .../Models/SDK/ApiModelContainerlogs.cs | 71 ++ .../Models/SDK/ApiModelContainerlogs.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/AppCreation.cs | 53 ++ .../Edgegap/Models/SDK/AppCreation.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/AppVersion.cs | 240 ++++++ .../Edgegap/Models/SDK/AppVersion.cs.meta | 11 + .../SDK/AppVersionCreateSessionConfig.cs | 81 ++ .../SDK/AppVersionCreateSessionConfig.cs.meta | 11 + .../Edgegap/Models/SDK/AppVersionEnv.cs | 63 ++ .../Edgegap/Models/SDK/AppVersionEnv.cs.meta | 11 + .../Edgegap/Models/SDK/AppVersionPort.cs | 81 ++ .../Edgegap/Models/SDK/AppVersionPort.cs.meta | 11 + .../Edgegap/Models/SDK/AppVersionProbe.cs | 54 ++ .../Models/SDK/AppVersionProbe.cs.meta | 11 + .../Edgegap/Models/SDK/AppVersionUpdate.cs | 240 ++++++ .../Models/SDK/AppVersionUpdate.cs.meta | 11 + .../SDK/AppVersionUpdateSessionConfig.cs | 81 ++ .../SDK/AppVersionUpdateSessionConfig.cs.meta | 11 + .../Models/SDK/AppVersionWhitelistEntry.cs | 72 ++ .../SDK/AppVersionWhitelistEntry.cs.meta | 11 + .../SDK/AppVersionWhitelistEntryPayload.cs | 63 ++ .../AppVersionWhitelistEntryPayload.cs.meta | 11 + .../SDK/AppVersionWhitelistEntrySuccess.cs | 53 ++ .../AppVersionWhitelistEntrySuccess.cs.meta | 11 + .../Models/SDK/AppVersionWhitelistResponse.cs | 44 ++ .../SDK/AppVersionWhitelistResponse.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/AppVersions.cs | 52 ++ .../Edgegap/Models/SDK/AppVersions.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Application.cs | 81 ++ .../Edgegap/Models/SDK/Application.cs.meta | 11 + .../Edgegap/Models/SDK/ApplicationPatch.cs | 63 ++ .../Models/SDK/ApplicationPatch.cs.meta | 11 + .../Edgegap/Models/SDK/ApplicationPost.cs | 63 ++ .../Models/SDK/ApplicationPost.cs.meta | 11 + .../Edgegap/Models/SDK/Applications.cs | 44 ++ .../Edgegap/Models/SDK/Applications.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/BaseModel.cs | 52 ++ .../Edgegap/Models/SDK/BaseModel.cs.meta | 11 + .../Edgegap/Models/SDK/BulkSessionDelete.cs | 54 ++ .../Models/SDK/BulkSessionDelete.cs.meta | 11 + .../Edgegap/Models/SDK/BulkSessionPost.cs | 54 ++ .../Models/SDK/BulkSessionPost.cs.meta | 11 + .../Models/SDK/ComponentCredentials.cs | 54 ++ .../Models/SDK/ComponentCredentials.cs.meta | 11 + .../Models/SDK/ContainerLogStorageModel.cs | 54 ++ .../SDK/ContainerLogStorageModel.cs.meta | 11 + .../Models/SDK/CustomBulkSessionModel.cs | 54 ++ .../Models/SDK/CustomBulkSessionModel.cs.meta | 11 + .../Models/SDK/CustomBulkSessionsModel.cs | 44 ++ .../SDK/CustomBulkSessionsModel.cs.meta | 11 + .../Models/SDK/CustomSessionDeleteModel.cs | 45 ++ .../SDK/CustomSessionDeleteModel.cs.meta | 11 + .../Edgegap/Models/SDK/CustomSessionModel.cs | 45 ++ .../Models/SDK/CustomSessionModel.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Delete.cs | 54 ++ .../Hosting/Edgegap/Models/SDK/Delete.cs.meta | 11 + .../Edgegap/Models/SDK/DeployEnvModel.cs | 63 ++ .../Edgegap/Models/SDK/DeployEnvModel.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/DeployModel.cs | 180 +++++ .../Edgegap/Models/SDK/DeployModel.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Deployment.cs | 134 ++++ .../Edgegap/Models/SDK/Deployment.cs.meta | 11 + .../Edgegap/Models/SDK/DeploymentLocation.cs | 99 +++ .../Models/SDK/DeploymentLocation.cs.meta | 11 + .../Models/SDK/DeploymentSessionContext.cs | 90 +++ .../SDK/DeploymentSessionContext.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Deployments.cs | 72 ++ .../Edgegap/Models/SDK/Deployments.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Error.cs | 45 ++ .../Hosting/Edgegap/Models/SDK/Error.cs.meta | 11 + .../Edgegap/Models/SDK/GeoIpListModel.cs | 63 ++ .../Edgegap/Models/SDK/GeoIpListModel.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Location.cs | 108 +++ .../Edgegap/Models/SDK/Location.cs.meta | 11 + .../Edgegap/Models/SDK/LocationModel.cs | 54 ++ .../Edgegap/Models/SDK/LocationModel.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Locations.cs | 53 ++ .../Edgegap/Models/SDK/Locations.cs.meta | 11 + .../Models/SDK/MatchmakerComponentCreate.cs | 81 ++ .../SDK/MatchmakerComponentCreate.cs.meta | 11 + .../SDK/MatchmakerComponentEnvListResponse.cs | 54 ++ ...MatchmakerComponentEnvListResponse.cs.meta | 11 + .../SDK/MatchmakerComponentEnvsCreate.cs | 54 ++ .../SDK/MatchmakerComponentEnvsCreate.cs.meta | 11 + .../SDK/MatchmakerComponentEnvsResponse.cs | 54 ++ .../MatchmakerComponentEnvsResponse.cs.meta | 11 + .../SDK/MatchmakerComponentEnvsUpdate.cs | 54 ++ .../SDK/MatchmakerComponentEnvsUpdate.cs.meta | 11 + .../SDK/MatchmakerComponentListResponse.cs | 54 ++ .../MatchmakerComponentListResponse.cs.meta | 11 + .../Models/SDK/MatchmakerComponentResponse.cs | 81 ++ .../SDK/MatchmakerComponentResponse.cs.meta | 11 + .../Models/SDK/MatchmakerComponentUpdate.cs | 81 ++ .../SDK/MatchmakerComponentUpdate.cs.meta | 11 + .../Edgegap/Models/SDK/MatchmakerCreate.cs | 45 ++ .../Models/SDK/MatchmakerCreate.cs.meta | 11 + .../Models/SDK/MatchmakerListResponse.cs | 54 ++ .../Models/SDK/MatchmakerListResponse.cs.meta | 11 + .../SDK/MatchmakerManagedReleaseCreate.cs | 45 ++ .../MatchmakerManagedReleaseCreate.cs.meta | 11 + .../SDK/MatchmakerManagedReleaseResponse.cs | 45 ++ .../MatchmakerManagedReleaseResponse.cs.meta | 11 + .../SDK/MatchmakerManagedReleaseUpdate.cs | 45 ++ .../MatchmakerManagedReleaseUpdate.cs.meta | 11 + .../SDK/MatchmakerReleaseConfigCreate.cs | 54 ++ .../SDK/MatchmakerReleaseConfigCreate.cs.meta | 11 + .../SDK/MatchmakerReleaseConfigResponse.cs | 54 ++ .../MatchmakerReleaseConfigResponse.cs.meta | 11 + .../SDK/MatchmakerReleaseConfigUpdate.cs | 54 ++ .../SDK/MatchmakerReleaseConfigUpdate.cs.meta | 11 + .../Models/SDK/MatchmakerReleaseCreate.cs | 63 ++ .../SDK/MatchmakerReleaseCreate.cs.meta | 11 + .../Models/SDK/MatchmakerReleaseCreateBase.cs | 45 ++ .../SDK/MatchmakerReleaseCreateBase.cs.meta | 11 + .../Models/SDK/MatchmakerReleaseResponse.cs | 63 ++ .../SDK/MatchmakerReleaseResponse.cs.meta | 11 + .../SDK/MatchmakerReleaseResponseBase.cs | 63 ++ .../SDK/MatchmakerReleaseResponseBase.cs.meta | 11 + .../Models/SDK/MatchmakerReleaseUpdate.cs | 63 ++ .../SDK/MatchmakerReleaseUpdate.cs.meta | 11 + .../Models/SDK/MatchmakerReleaseUpdateBase.cs | 45 ++ .../SDK/MatchmakerReleaseUpdateBase.cs.meta | 11 + .../Edgegap/Models/SDK/MatchmakerResponse.cs | 45 ++ .../Models/SDK/MatchmakerResponse.cs.meta | 11 + .../Edgegap/Models/SDK/MatchmakerUpdate.cs | 45 ++ .../Models/SDK/MatchmakerUpdate.cs.meta | 11 + .../Edgegap/Models/SDK/MetricsModel.cs | 60 ++ .../Edgegap/Models/SDK/MetricsModel.cs.meta | 11 + .../Edgegap/Models/SDK/MetricsResponse.cs | 68 ++ .../Models/SDK/MetricsResponse.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Monitor.cs | 99 +++ .../Edgegap/Models/SDK/Monitor.cs.meta | 11 + .../Edgegap/Models/SDK/NetworkMetricsModel.cs | 52 ++ .../Models/SDK/NetworkMetricsModel.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Pagination.cs | 89 +++ .../Edgegap/Models/SDK/Pagination.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Paginator.cs | 45 ++ .../Edgegap/Models/SDK/Paginator.cs.meta | 11 + .../Edgegap/Models/SDK/PatchSessionModel.cs | 45 ++ .../Models/SDK/PatchSessionModel.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/PortMapping.cs | 99 +++ .../Edgegap/Models/SDK/PortMapping.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Request.cs | 135 ++++ .../Edgegap/Models/SDK/Request.cs.meta | 11 + .../Edgegap/Models/SDK/SelectorEnvModel.cs | 54 ++ .../Models/SDK/SelectorEnvModel.cs.meta | 11 + .../Edgegap/Models/SDK/SelectorModel.cs | 63 ++ .../Edgegap/Models/SDK/SelectorModel.cs.meta | 11 + .../Edgegap/Models/SDK/SessionContext.cs | 108 +++ .../Edgegap/Models/SDK/SessionContext.cs.meta | 11 + .../Edgegap/Models/SDK/SessionDelete.cs | 63 ++ .../Edgegap/Models/SDK/SessionDelete.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/SessionGet.cs | 161 ++++ .../Edgegap/Models/SDK/SessionGet.cs.meta | 11 + .../Edgegap/Models/SDK/SessionModel.cs | 144 ++++ .../Edgegap/Models/SDK/SessionModel.cs.meta | 11 + .../Edgegap/Models/SDK/SessionRequest.cs | 90 +++ .../Edgegap/Models/SDK/SessionRequest.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/SessionUser.cs | 63 ++ .../Edgegap/Models/SDK/SessionUser.cs.meta | 11 + .../Edgegap/Models/SDK/SessionUserContext.cs | 45 ++ .../Models/SDK/SessionUserContext.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Sessions.cs | 63 ++ .../Edgegap/Models/SDK/Sessions.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/StaticSites.cs | 90 +++ .../Edgegap/Models/SDK/StaticSites.cs.meta | 11 + .../Edgegap/Models/SDK/StaticSitesList.cs | 53 ++ .../Models/SDK/StaticSitesList.cs.meta | 11 + .../Hosting/Edgegap/Models/SDK/Status.cs | 215 ++++++ .../Hosting/Edgegap/Models/SDK/Status.cs.meta | 11 + .../Edgegap/Models/SDK/TotalMetricsModel.cs | 68 ++ .../Models/SDK/TotalMetricsModel.cs.meta | 11 + Assets/Mirror/Hosting/Edgegap/Plugins.meta | 8 + .../Edgegap/Plugins/Newtonsoft.Json.dll | Bin 0 -> 680720 bytes .../Edgegap/Plugins/Newtonsoft.Json.dll.meta | 33 + .../Hosting/Edgegap/Plugins/version.txt | 2 + .../Hosting/Edgegap/Plugins/version.txt.meta | 7 + Assets/Mirror/Hosting/Mirror.Hosting.asmdef | 18 + .../Mirror/Hosting/Mirror.Hosting.asmdef.meta | 7 + Assets/Mirror/Hosting/Readme.txt | 5 + Assets/Mirror/Hosting/Readme.txt.meta | 3 + 222 files changed, 9345 insertions(+) create mode 100644 Assets/Mirror/Hosting.meta create mode 100755 Assets/Mirror/Hosting/Edgegap.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.uss create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.uss.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.uxml create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.uxml.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/Fonts.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/Fonts/BaronNeue.otf create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/Fonts/BaronNeue.otf.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/Images.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/Images/logo_transparent_400_alpha25.png create mode 100755 Assets/Mirror/Hosting/Edgegap/Editor/Images/logo_transparent_400_alpha25.png.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Enums.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Enums/ApiEnvironment.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Enums/ApiEnvironment.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Enums/ServerStatus.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Enums/ServerStatus.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Enums/ToolState.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Enums/ToolState.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/AppVersionUpdatePatchData.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/AppVersionUpdatePatchData.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/DeployPostData.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/DeployPostData.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApiModelContainercrashdata.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApiModelContainercrashdata.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApiModelContainerlogs.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApiModelContainerlogs.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppCreation.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppCreation.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersion.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersion.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionCreateSessionConfig.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionCreateSessionConfig.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionEnv.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionEnv.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionPort.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionPort.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionProbe.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionProbe.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionUpdate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionUpdate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionUpdateSessionConfig.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionUpdateSessionConfig.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistEntry.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistEntry.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistEntryPayload.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistEntryPayload.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistEntrySuccess.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistEntrySuccess.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersionWhitelistResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersions.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/AppVersions.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Application.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Application.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApplicationPatch.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApplicationPatch.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApplicationPost.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ApplicationPost.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Applications.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Applications.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/BaseModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/BaseModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/BulkSessionDelete.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/BulkSessionDelete.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/BulkSessionPost.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/BulkSessionPost.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ComponentCredentials.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ComponentCredentials.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ContainerLogStorageModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/ContainerLogStorageModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomBulkSessionModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomBulkSessionModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomBulkSessionsModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomBulkSessionsModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomSessionDeleteModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomSessionDeleteModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomSessionModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/CustomSessionModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Delete.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Delete.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeployEnvModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeployEnvModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeployModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeployModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Deployment.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Deployment.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeploymentLocation.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeploymentLocation.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeploymentSessionContext.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/DeploymentSessionContext.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Deployments.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Deployments.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Error.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Error.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/GeoIpListModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/GeoIpListModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Location.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Location.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/LocationModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/LocationModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Locations.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Locations.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentCreate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentCreate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvListResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvListResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvsCreate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvsCreate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvsResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvsResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvsUpdate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentEnvsUpdate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentListResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentListResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentUpdate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerComponentUpdate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerCreate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerCreate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerListResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerListResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerManagedReleaseCreate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerManagedReleaseCreate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerManagedReleaseResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerManagedReleaseResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerManagedReleaseUpdate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerManagedReleaseUpdate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseConfigCreate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseConfigCreate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseConfigResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseConfigResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseConfigUpdate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseConfigUpdate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseCreate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseCreate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseCreateBase.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseCreateBase.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseResponseBase.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseResponseBase.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseUpdate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseUpdate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseUpdateBase.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerReleaseUpdateBase.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerUpdate.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MatchmakerUpdate.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MetricsModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MetricsModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MetricsResponse.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/MetricsResponse.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Monitor.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Monitor.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/NetworkMetricsModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/NetworkMetricsModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Pagination.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Pagination.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Paginator.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Paginator.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/PatchSessionModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/PatchSessionModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/PortMapping.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/PortMapping.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Request.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Request.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SelectorEnvModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SelectorEnvModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SelectorModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SelectorModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionContext.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionContext.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionDelete.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionDelete.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionGet.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionGet.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionModel.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionRequest.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionRequest.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionUser.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionUser.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionUserContext.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/SessionUserContext.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Sessions.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Sessions.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/StaticSites.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/StaticSites.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/StaticSitesList.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/StaticSitesList.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Status.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/Status.cs.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/TotalMetricsModel.cs create mode 100755 Assets/Mirror/Hosting/Edgegap/Models/SDK/TotalMetricsModel.cs.meta create mode 100644 Assets/Mirror/Hosting/Edgegap/Plugins.meta create mode 100755 Assets/Mirror/Hosting/Edgegap/Plugins/Newtonsoft.Json.dll create mode 100644 Assets/Mirror/Hosting/Edgegap/Plugins/Newtonsoft.Json.dll.meta create mode 100644 Assets/Mirror/Hosting/Edgegap/Plugins/version.txt create mode 100644 Assets/Mirror/Hosting/Edgegap/Plugins/version.txt.meta create mode 100644 Assets/Mirror/Hosting/Mirror.Hosting.asmdef create mode 100644 Assets/Mirror/Hosting/Mirror.Hosting.asmdef.meta create mode 100644 Assets/Mirror/Hosting/Readme.txt create mode 100644 Assets/Mirror/Hosting/Readme.txt.meta diff --git a/.gitignore b/.gitignore index 1f8408e23..1b8a70714 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ UserSettings/Search.settings # ===================================== # Database.sqlite Database/ +Builds/ # ===================================== # # Visual Studio / MonoDevelop / Rider # diff --git a/Assets/Mirror/Hosting.meta b/Assets/Mirror/Hosting.meta new file mode 100644 index 000000000..43de0c569 --- /dev/null +++ b/Assets/Mirror/Hosting.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b13bce90dfb604c2d9170e3640f59ad9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap.meta b/Assets/Mirror/Hosting/Edgegap.meta new file mode 100755 index 000000000..c4f5fd2c1 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b7c51dc3e45095f4a8a960150837fe7b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor.meta b/Assets/Mirror/Hosting/Edgegap/Editor.meta new file mode 100755 index 000000000..e5593273f --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 635b395f47dc9f742b4d71144921bb0d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs new file mode 100755 index 000000000..8bad9d62d --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using UnityEditor; +using UnityEditor.Build.Reporting; + +using Debug = UnityEngine.Debug; + +namespace Edgegap +{ + internal static class EdgegapBuildUtils + { + + public static BuildReport BuildServer() + { + IEnumerable scenes = EditorBuildSettings.scenes.Select(s=>s.path); + BuildPlayerOptions options = new BuildPlayerOptions + { + scenes = scenes.ToArray(), + target = BuildTarget.StandaloneLinux64, + #pragma warning disable CS0618 // disable deprecated warning until Edgegap updates this + options = BuildOptions.EnableHeadlessMode, + #pragma warning restore CS0618 + locationPathName = "Builds/EdgegapServer/ServerBuild" + }; + + return BuildPipeline.BuildPlayer(options); + } + + public static async Task DockerSetupAndInstallationCheck() + { + if (!File.Exists("Dockerfile")) + { + File.WriteAllText("Dockerfile", dockerFileText); + } + + string output = null; + string error = null; + await RunCommand_DockerVersion(msg => output = msg, msg => error = msg); // MIRROR CHANGE + if (!string.IsNullOrEmpty(error)) + { + Debug.LogError(error); + return false; + } + Debug.Log($"[Edgegap] Docker version detected: {output}"); // MIRROR CHANGE + return true; + } + + // MIRROR CHANGE + static async Task RunCommand_DockerVersion(Action outputReciever = null, Action errorReciever = null) + { +#if UNITY_EDITOR_WIN + await RunCommand("cmd.exe", "/c docker --version", outputReciever, errorReciever); +#elif UNITY_EDITOR_OSX + await RunCommand("/bin/bash", "-c \"docker --version\"", outputReciever, errorReciever); +#elif UNITY_EDITOR_LINUX + await RunCommand("/bin/bash", "-c \"docker --version\"", outputReciever, errorReciever); +#else + Debug.LogError("The platform is not supported yet."); +#endif + } + + // MIRROR CHANGE + public static async Task RunCommand_DockerBuild(string registry, string imageRepo, string tag, Action onStatusUpdate) + { + string realErrorMessage = null; + +#if UNITY_EDITOR_WIN + await RunCommand("docker.exe", $"build -t {registry}/{imageRepo}:{tag} .", onStatusUpdate, +#elif UNITY_EDITOR_OSX + await RunCommand("/bin/bash", $"-c \"docker build -t {registry}/{imageRepo}:{tag} .\"", onStatusUpdate, +#elif UNITY_EDITOR_LINUX + await RunCommand("/bin/bash", $"-c \"docker build -t {registry}/{imageRepo}:{tag} .\"", onStatusUpdate, +#endif + (msg) => + { + if (msg.Contains("ERROR")) + { + realErrorMessage = msg; + } + onStatusUpdate(msg); + }); + + if(realErrorMessage != null) + { + throw new Exception(realErrorMessage); + } + } + + public static async Task<(bool, string)> RunCommand_DockerPush(string registry, string imageRepo, string tag, Action onStatusUpdate) + { + string error = string.Empty; +#if UNITY_EDITOR_WIN + await RunCommand("docker.exe", $"push {registry}/{imageRepo}:{tag}", onStatusUpdate, (msg) => error += msg + "\n"); +#elif UNITY_EDITOR_OSX + await RunCommand("/bin/bash", $"-c \"docker push {registry}/{imageRepo}:{tag}\"", onStatusUpdate, (msg) => error += msg + "\n"); +#elif UNITY_EDITOR_LINUX + await RunCommand("/bin/bash", $"-c \"docker push {registry}/{imageRepo}:{tag}\"", onStatusUpdate, (msg) => error += msg + "\n"); +#endif + if (!string.IsNullOrEmpty(error)) + { + Debug.LogError(error); + return (false, error); + } + return (true, null); + } + // END MIRROR CHANGE + + static async Task RunCommand(string command, string arguments, Action outputReciever = null, Action errorReciever = null) + { + ProcessStartInfo startInfo = new ProcessStartInfo() + { + FileName = command, + Arguments = arguments, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + }; + + // MIRROR CHANGE +#if !UNITY_EDITOR_WIN + // on mac, commands like 'docker' aren't found because it's not in the application's PATH + // even if it runs on mac's terminal. + // to solve this we need to do two steps: + // 1. add /usr/bin/local to PATH if it's not there already. often this is missing in the application. + // this is where docker is usually instaled. + // 2. add PATH to ProcessStartInfo + string existingPath = Environment.GetEnvironmentVariable("PATH"); + string customPath = $"{existingPath}:/usr/local/bin"; + startInfo.EnvironmentVariables["PATH"] = customPath; + // Debug.Log("PATH: " + customPath); +#endif + // END MIRROR CHANGE + + Process proc = new Process() { StartInfo = startInfo, }; + proc.EnableRaisingEvents = true; + + ConcurrentQueue errors = new ConcurrentQueue(); + ConcurrentQueue outputs = new ConcurrentQueue(); + + void PipeQueue(ConcurrentQueue q, Action opt) + { + while (!q.IsEmpty) + { + if (q.TryDequeue(out string msg) && !string.IsNullOrWhiteSpace(msg)) + { + opt?.Invoke(msg); + } + } + } + + proc.OutputDataReceived += (s, e) => outputs.Enqueue(e.Data); + proc.ErrorDataReceived += (s, e) => errors.Enqueue(e.Data); + + proc.Start(); + proc.BeginOutputReadLine(); + proc.BeginErrorReadLine(); + + while (!proc.HasExited) + { + await Task.Delay(100); + PipeQueue(errors, errorReciever); + PipeQueue(outputs, outputReciever); + } + + PipeQueue(errors, errorReciever); + PipeQueue(outputs, outputReciever); + } + + static void Proc_OutputDataReceived(object sender, DataReceivedEventArgs e) + { + throw new NotImplementedException(); + } + + static Regex lastDigitsRegex = new Regex("([0-9])+$"); + + public static string IncrementTag(string tag) + { + Match lastDigits = lastDigitsRegex.Match(tag); + if (!lastDigits.Success) + { + return tag + " _1"; + } + + int number = int.Parse(lastDigits.Groups[0].Value); + + number++; + + return lastDigitsRegex.Replace(tag, number.ToString()); + } + + public static void UpdateEdgegapAppTag(string tag) + { + // throw new NotImplementedException(); + } + + static string dockerFileText = @"FROM ubuntu:bionic + +ARG DEBIAN_FRONTEND=noninteractive + +COPY Builds/EdgegapServer /root/build/ + +WORKDIR /root/ + +RUN chmod +x /root/build/ServerBuild + +ENTRYPOINT [ ""/root/build/ServerBuild"", ""-batchmode"", ""-nographics""] +"; + + + } +} diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs.meta b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs.meta new file mode 100755 index 000000000..03529c425 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97dadab2a073d8b47bf9a270401f0a8f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs new file mode 100755 index 000000000..8b840e95b --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs @@ -0,0 +1,27 @@ +using UnityEditor; +using UnityEngine.UIElements; + +namespace Edgegap +{ + [CustomEditor(typeof(EdgegapToolScript))] + public class EdgegapPluginScriptEditor : Editor + { + VisualElement _serverDataContainer; + + void OnEnable() + { + _serverDataContainer = EdgegapServerDataManager.GetServerDataVisualTree(); + EdgegapServerDataManager.RegisterServerDataContainer(_serverDataContainer); + } + + void OnDisable() + { + EdgegapServerDataManager.DeregisterServerDataContainer(_serverDataContainer); + } + + public override VisualElement CreateInspectorGUI() + { + return _serverDataContainer; + } + } +} diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs.meta b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs.meta new file mode 100755 index 000000000..60f708f6b --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapScriptEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c4c676ae6dcca0e458c6a8f06571f8fc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss new file mode 100755 index 000000000..15cb5e392 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss @@ -0,0 +1,81 @@ +.row__port-table { + padding: 2px 4px; + display: flex; + flex-direction: row; + align-items: center; + width: auto; + justify-content: space-around; + -unity-text-align: middle-left; +} + + .row__port-table > * { + width: 0px; + flex-grow: 1; + align-self: center; + margin: 0px; + padding: 0px; + } + +.focusable:hover { + background-color: rgba(0,0,0,0.2); + border-radius: 3px; +} + +.row__dns { + display: flex; + flex-direction: row; + align-items: center; + width: auto; + justify-content: space-between; + -unity-text-align: middle-left; +} + +.row__status { + display: flex; + flex-direction: row; + align-items: center; + width: auto; + justify-content: space-between; + -unity-text-align: middle-left; +} + +.label__header { + -unity-font-style: bold +} + +.label__status { + -unity-font-style: bold; + border-radius: 2px; + width: 100px; + color: #fff; + -unity-text-align: middle-center; +} + +.label__info-text { + padding: 8px; + margin: 4px; + border-radius: 3px; + -unity-text-align: middle-center; + white-space: normal; + background-color: rgba(42, 42, 42, 0.5); +} + +.container { + margin: 8px 0px; +} + +.bg--secondary { + background-color: #8a8a8a; +} + +.bg--success { + background-color: #90be6d; +} + +.bg--danger { + background-color: #f94144; +} + +.bg--warning { + background-color: #f9c74f; +} diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss.meta b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss.meta new file mode 100755 index 000000000..b9cce488c --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerData.uss.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: da5e3f58bd8cde14789f7c61df3f59f4 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} + disableValidation: 0 diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs new file mode 100755 index 000000000..4eebb877d --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs @@ -0,0 +1,242 @@ +using IO.Swagger.Model; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Edgegap +{ + static class EdgegapServerDataManagerUtils + { + public static Label GetHeader(string text) + { + Label header = new Label(text); + header.AddToClassList("label__header"); + + return header; + } + + public static VisualElement GetHeaderRow() + { + VisualElement row = new VisualElement(); + row.AddToClassList("row__port-table"); + row.AddToClassList("label__header"); + + row.Add(new Label("Name")); + row.Add(new Label("External")); + row.Add(new Label("Internal")); + row.Add(new Label("Protocol")); + row.Add(new Label("Link")); + + return row; + } + + public static VisualElement GetRowFromPortResponse(PortMapping port) + { + VisualElement row = new VisualElement(); + row.AddToClassList("row__port-table"); + row.AddToClassList("focusable"); + + + row.Add(new Label(port.Name)); + row.Add(new Label(port.External.ToString())); + row.Add(new Label(port.Internal.ToString())); + row.Add(new Label(port.Protocol)); + row.Add(GetCopyButton("Copy", port.Link)); + + return row; + } + + public static Button GetCopyButton(string btnText, string copiedText) + { + Button copyBtn = new Button(); + copyBtn.text = btnText; + copyBtn.clickable.clicked += () => GUIUtility.systemCopyBuffer = copiedText; + + return copyBtn; + } + + public static Button GetLinkButton(string btnText, string targetUrl) + { + Button copyBtn = new Button(); + copyBtn.text = btnText; + copyBtn.clickable.clicked += () => UnityEngine.Application.OpenURL(targetUrl); + + return copyBtn; + } + public static Label GetInfoText(string innerText) + { + Label infoText = new Label(innerText); + infoText.AddToClassList("label__info-text"); + + return infoText; + } + } + + /// + /// Utility class to centrally manage the Edgegap server data, and create / update the elements displaying the server info. + /// + public static class EdgegapServerDataManager + { + static Status _serverData; + static ApiEnvironment _apiEnvironment; + + // UI elements + static readonly StyleSheet _serverDataStylesheet; + static readonly List _serverDataContainers = new List(); + + public static Status GetServerStatus() => _serverData; + + static EdgegapServerDataManager() + { + // MIRROR CHANGE + _serverDataStylesheet = AssetDatabase.LoadAssetAtPath($"{EdgegapWindow.StylesheetPath}/EdgegapServerData.uss"); + // END MIRROR CHANGE + } + public static void RegisterServerDataContainer(VisualElement serverDataContainer) + { + _serverDataContainers.Add(serverDataContainer); + } + public static void DeregisterServerDataContainer(VisualElement serverDataContainer) + { + _serverDataContainers.Remove(serverDataContainer); + } + public static void SetServerData(Status serverData, ApiEnvironment apiEnvironment) + { + _serverData = serverData; + _apiEnvironment = apiEnvironment; + RefreshServerDataContainers(); + } + + static VisualElement GetStatusSection() + { + ServerStatus serverStatus = _serverData.GetServerStatus(); + string dashboardUrl = _apiEnvironment.GetDashboardUrl(); + string requestId = _serverData.RequestId; + string deploymentDashboardUrl = ""; + + if (!string.IsNullOrEmpty(requestId) && !string.IsNullOrEmpty(dashboardUrl)) + { + deploymentDashboardUrl = $"{dashboardUrl}/arbitrium/deployment/read/{requestId}/"; + } + + VisualElement container = new VisualElement(); + container.AddToClassList("container"); + + container.Add(EdgegapServerDataManagerUtils.GetHeader("Server Status")); + + VisualElement row = new VisualElement(); + row.AddToClassList("row__status"); + + // Status pill + Label statusLabel = new Label(serverStatus.GetLabelText()); + statusLabel.AddToClassList(serverStatus.GetStatusBgClass()); + statusLabel.AddToClassList("label__status"); + row.Add(statusLabel); + + // Link to dashboard + if (!string.IsNullOrEmpty(deploymentDashboardUrl)) + { + row.Add(EdgegapServerDataManagerUtils.GetLinkButton("See in the dashboard", deploymentDashboardUrl)); + } + else + { + row.Add(new Label("Could not resolve link to this deployment")); + } + + container.Add(row); + + return container; + } + + static VisualElement GetDnsSection() + { + string serverDns = _serverData.Fqdn; + + VisualElement container = new VisualElement(); + container.AddToClassList("container"); + + container.Add(EdgegapServerDataManagerUtils.GetHeader("Server DNS")); + + VisualElement row = new VisualElement(); + row.AddToClassList("row__dns"); + row.AddToClassList("focusable"); + + row.Add(new Label(serverDns)); + row.Add(EdgegapServerDataManagerUtils.GetCopyButton("Copy", serverDns)); + + container.Add(row); + + return container; + } + + static VisualElement GetPortsSection() + { + List serverPorts = _serverData.Ports.Values.ToList(); + + VisualElement container = new VisualElement(); + container.AddToClassList("container"); + + container.Add(EdgegapServerDataManagerUtils.GetHeader("Server Ports")); + container.Add(EdgegapServerDataManagerUtils.GetHeaderRow()); + + VisualElement portList = new VisualElement(); + + if (serverPorts.Count > 0) + { + foreach (PortMapping port in serverPorts) + { + portList.Add(EdgegapServerDataManagerUtils.GetRowFromPortResponse(port)); + } + } + else + { + portList.Add(new Label("No port configured for this app version.")); + } + + container.Add(portList); + + return container; + } + + public static VisualElement GetServerDataVisualTree() + { + VisualElement serverDataTree = new VisualElement(); + serverDataTree.styleSheets.Add(_serverDataStylesheet); + + bool hasServerData = _serverData != null; + bool isReady = hasServerData && _serverData.GetServerStatus().IsOneOf(ServerStatus.Ready, ServerStatus.Error); + + if (hasServerData) + { + serverDataTree.Add(GetStatusSection()); + + if (isReady) + { + serverDataTree.Add(GetDnsSection()); + serverDataTree.Add(GetPortsSection()); + } + else + { + serverDataTree.Add(EdgegapServerDataManagerUtils.GetInfoText("Additionnal information will be displayed when the server is ready.")); + } + } + else + { + serverDataTree.Add(EdgegapServerDataManagerUtils.GetInfoText("Server data will be displayed here when a server is running.")); + } + + return serverDataTree; + } + + static void RefreshServerDataContainers() + { + foreach (VisualElement serverDataContainer in _serverDataContainers) + { + serverDataContainer.Clear(); + serverDataContainer.Add(GetServerDataVisualTree()); // Cannot reuse a same instance of VisualElement + } + } + } +} diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs.meta b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs.meta new file mode 100755 index 000000000..65da2ab42 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapServerDataManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 39f5f27c13279a34eb116630a00e41c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs new file mode 100755 index 000000000..a949f7cf9 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs @@ -0,0 +1,15 @@ +using UnityEngine; +using Edgegap; +using IO.Swagger.Model; + +namespace Edgegap +{ + /// + /// This script acts as an interface to display and use the necessary variables from the Edgegap tool. + /// The server info can be accessed from the tool window, as well as through the public script property. + /// + public class EdgegapToolScript : MonoBehaviour + { + public Status ServerStatus => EdgegapServerDataManager.GetServerStatus(); + } +} diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs.meta b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs.meta new file mode 100755 index 000000000..d584893d2 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapToolScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5963202433da25448a22def99f5a598b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.cs b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.cs new file mode 100755 index 000000000..450de2d26 --- /dev/null +++ b/Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.cs @@ -0,0 +1,698 @@ +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; +using UnityEditor.UIElements; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Collections.Generic; +using Newtonsoft.Json; +using System.Net; +using System.Text; +using System; +using System.Threading.Tasks; +using IO.Swagger.Model; +using UnityEditor.Build.Reporting; +using Application = UnityEngine.Application; + +namespace Edgegap +{ + public class EdgegapWindow : EditorWindow + { + static readonly HttpClient _httpClient = new HttpClient(); + + const string EditorDataSerializationName = "EdgegapSerializationData"; + const int ServerStatusCronjobIntervalMs = 10000; // Interval at which the server status is updated + + // MIRROR CHANGE: specify stylesheet paths in one place + // TODO DON'T HARDCODE + public const string StylesheetPath = "Assets/Mirror/Hosting/Edgegap/Editor"; + // END MIRROR CHANGE + + readonly System.Timers.Timer _updateServerStatusCronjob = new System.Timers.Timer(ServerStatusCronjobIntervalMs); + + [SerializeField] string _userExternalIp; + [SerializeField] string _apiKey; + [SerializeField] ApiEnvironment _apiEnvironment; + [SerializeField] string _appName; + [SerializeField] string _appVersionName; + [SerializeField] string _deploymentRequestId; + + [SerializeField] string _containerRegistry; + [SerializeField] string _containerImageRepo; + [SerializeField] string _containerImageTag; + [SerializeField] bool _autoIncrementTag = true; + + + VisualTreeAsset _visualTree; + bool _shouldUpdateServerStatus = false; + + // Interactable elements + EnumField _apiEnvironmentSelect; + TextField _apiKeyInput; + TextField _appNameInput; + TextField _appVersionNameInput; + TextField _containerRegistryInput; + TextField _containerImageRepoInput; + TextField _containerImageTagInput; + Toggle _autoIncrementTagInput; + Button _connectionButton; + Button _serverActionButton; + Button _documentationBtn; + Button _buildAndPushServerBtn; + + // Readonly elements + Label _connectionStatusLabel; + VisualElement _serverDataContainer; + + [MenuItem("Edgegap/Edgegap Hosting")] // MIRROR CHANGE + public static void ShowEdgegapToolWindow() + { + EdgegapWindow window = GetWindow(); + window.titleContent = new GUIContent("Edgegap Hosting"); // MIRROR CHANGE + } + + protected void OnEnable() + { + // Set root VisualElement and style + // BEGIN MIRROR CHANGE + _visualTree = AssetDatabase.LoadAssetAtPath($"{StylesheetPath}/EdgegapWindow.uxml"); + StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath($"{StylesheetPath}/EdgegapWindow.uss"); + // END MIRROR CHANGE + rootVisualElement.styleSheets.Add(styleSheet); + + LoadToolData(); + + if (string.IsNullOrWhiteSpace(_userExternalIp)) + { + _userExternalIp = GetExternalIpAddress(); + } + } + + protected void Update() + { + if (_shouldUpdateServerStatus) + { + _shouldUpdateServerStatus = false; + UpdateServerStatus(); + } + } + + public void CreateGUI() + { + rootVisualElement.Clear(); + _visualTree.CloneTree(rootVisualElement); + + InitUIElements(); + SyncFormWithObject(); + + bool hasActiveDeployment = !string.IsNullOrEmpty(_deploymentRequestId); + + if (hasActiveDeployment) + { + RestoreActiveDeployment(); + } + else + { + DisconnectCallback(); + } + } + + protected void OnDestroy() + { + bool deploymentActive = !string.IsNullOrEmpty(_deploymentRequestId); + + if (deploymentActive) + { + EditorUtility.DisplayDialog( + "Warning", + $"You have an active deployment ({_deploymentRequestId}) that won't be stopped automatically.", + "Ok" + ); + } + } + + protected void OnDisable() + { + SyncObjectWithForm(); + SaveToolData(); + EdgegapServerDataManager.DeregisterServerDataContainer(_serverDataContainer); + } + + /// + /// Binds the form inputs to the associated variables and initializes the inputs as required. + /// Requires the VisualElements to be loaded before this call. Otherwise, the elements cannot be found. + /// + void InitUIElements() + { + _apiEnvironmentSelect = rootVisualElement.Q("environmentSelect"); + _apiKeyInput = rootVisualElement.Q("apiKey"); + _appNameInput = rootVisualElement.Q("appName"); + _appVersionNameInput = rootVisualElement.Q("appVersionName"); + + _containerRegistryInput = rootVisualElement.Q("containerRegistry"); + _containerImageRepoInput = rootVisualElement.Q("containerImageRepo"); + _containerImageTagInput = rootVisualElement.Q("tag"); + _autoIncrementTagInput = rootVisualElement.Q("autoIncrementTag"); + + _connectionButton = rootVisualElement.Q