From e32aadda4e7f74ad882910becb6c923fae78ec84 Mon Sep 17 00:00:00 2001 From: Valmo Date: Thu, 26 Mar 2026 01:05:54 -0300 Subject: [PATCH] Splitted Connection Module --- addons/main/XEH_postInit.sqf | 7 +- addons/server/CfgVehicles.hpp | 222 ++++++------- addons/server/XEH_PREP.hpp | 7 +- addons/server/config.cpp | 6 +- addons/server/dialog.hpp | 314 ++++++++---------- .../functions/fnc_3denCoreModuleConfig.sqf | 106 ------ .../functions/fnc_3denEnrollModuleConfig.sqf | 37 +++ .../functions/fnc_3denTcpModuleConfig.sqf | 26 ++ .../functions/fnc_ZeusCoreModuleConfig.sqf | 109 ------ .../functions/fnc_ZeusEnrollModuleConfig.sqf | 33 ++ .../functions/fnc_ZeusTcpModuleConfig.sqf | 22 ++ .../server/functions/fnc_startCotRouter.sqf | 47 +++ src/tcp/tls/enrollment.rs | 48 ++- 13 files changed, 448 insertions(+), 536 deletions(-) delete mode 100644 addons/server/functions/fnc_3denCoreModuleConfig.sqf create mode 100644 addons/server/functions/fnc_3denEnrollModuleConfig.sqf create mode 100644 addons/server/functions/fnc_3denTcpModuleConfig.sqf delete mode 100644 addons/server/functions/fnc_ZeusCoreModuleConfig.sqf create mode 100644 addons/server/functions/fnc_ZeusEnrollModuleConfig.sqf create mode 100644 addons/server/functions/fnc_ZeusTcpModuleConfig.sqf create mode 100644 addons/server/functions/fnc_startCotRouter.sqf diff --git a/addons/main/XEH_postInit.sqf b/addons/main/XEH_postInit.sqf index c281c39..bc1304d 100644 --- a/addons/main/XEH_postInit.sqf +++ b/addons/main/XEH_postInit.sqf @@ -35,7 +35,12 @@ addMissionEventHandler ["ExtensionCallback", { [_function, "success", _name] call FUNC(notify); }; case "TCP SOCKET ERROR": { - [_function, "error", _name] call FUNC(notify); + _message = _function; + if (_data isNotEqualTo "") then { + _message = format ["%1: %2", _function, _data]; + }; + + [_message, "error", _name] call FUNC(notify); }; case "VIDEO": { [_function, "success", _name] call FUNC(notify); diff --git a/addons/server/CfgVehicles.hpp b/addons/server/CfgVehicles.hpp index 2072105..f1f9909 100644 --- a/addons/server/CfgVehicles.hpp +++ b/addons/server/CfgVehicles.hpp @@ -1,35 +1,28 @@ class CfgVehicles { - class Logic; - class Module_F : Logic - { - class AttributesBase - { - class Edit; - class Combo; - class ModuleDescription; - }; - + class Logic; + class Module_F : Logic { + class AttributesBase { + class Edit; + class ModuleDescription; + }; class ModuleDescription; }; class GVAR(moduleBase): Module_F { - author = PROJECT_AUTHOR; - category = QEGVAR(main,moduleCategory); - function = QUOTE({}); - functionPriority = 1; - isGlobal = 1; - isTriggerActivated = 0; - scope = 1; - scopeCurator = 2; - }; + author = PROJECT_AUTHOR; + category = QEGVAR(main,moduleCategory); + function = QUOTE({}); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + scope = 1; + scopeCurator = 2; + }; - class GVAR(coreModule): GVAR(moduleBase) { - scope = 2; - scopeCurator = 0; - displayname = "CoT Router"; + class GVAR(connectionModuleBase): GVAR(moduleBase) { + scopeCurator = 0; icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa"; category = QEGVAR(main,moduleCategory); - function = QFUNC(3denCoreModuleConfig); functionPriority = 1; isGlobal = 0; isTriggerActivated = 1; @@ -40,122 +33,101 @@ class CfgVehicles { canSetArea = 0; canSetAreaShape = 0; canSetAreaHeight = 0; + }; - class Attributes: AttributesBase { - class GVAR(moduleTransportMode): Combo { - property = QGVAR(moduleTransportMode); - displayname = "Transport Mode"; - tooltip = "Choose how ArmaTAK connects to the TAK or IronTAK server."; - typeName = "STRING"; - defaultValue = "'tcp'"; - class Values { - class tcp { - name = "TCP 8088 (Unauthenticated)"; - value = "tcp"; - default = 1; - }; - class manual_mtls { - name = "mTLS (Manual Certificate)"; - value = "manual_mtls"; - }; - class enroll_mtls { - name = "mTLS (GET config + POST signClient)"; - value = "enroll_mtls"; - }; - }; - }; - class GVAR(moduleInstanceAddress): Edit { - property = QGVAR(moduleInstanceAddress); - displayname = "TAK Server Address"; - tooltip = "TAK Server Instance Address"; + class GVAR(tcpModule): GVAR(connectionModuleBase) { + scope = 2; + displayName = "CoT Router (TCP)"; + function = QFUNC(3denTcpModuleConfig); + + class Attributes: AttributesBase { + class GVAR(moduleInstanceAddress): Edit { + property = QGVAR(moduleInstanceAddress); + displayName = "TAK Server Address"; + tooltip = "Hostname or IP address for the TAK or IronTAK server."; typeName = "STRING"; - defaultValue = "localhost"; + defaultValue = "'localhost'"; }; - class GVAR(moduleInstancePort): Edit { - property = QGVAR(moduleInstancePort); - displayname = "TAK Server TCP Port"; - tooltip = "TAK Server instance Port for TCP connection"; - typeName = "NUMBER"; - defaultValue = "8088"; - }; - class GVAR(moduleTlsServerName): Edit { - property = QGVAR(moduleTlsServerName); - displayname = "TLS Server Name"; - tooltip = "Optional hostname used for TLS certificate validation. Leave blank to reuse the address host."; - typeName = "STRING"; - defaultValue = ""; - }; - class GVAR(moduleTlsCaCertPath): Edit { - property = QGVAR(moduleTlsCaCertPath); - displayname = "TLS CA Cert Path"; - tooltip = "PEM path for the CA that signs the IronTAK or TAK server certificate."; - typeName = "STRING"; - defaultValue = ""; - }; - class GVAR(moduleTlsClientCertPath): Edit { - property = QGVAR(moduleTlsClientCertPath); - displayname = "TLS Client Cert Path"; - tooltip = "PEM path for the client certificate used by this ArmaTAK session."; - typeName = "STRING"; - defaultValue = ""; - }; - class GVAR(moduleTlsClientKeyPath): Edit { - property = QGVAR(moduleTlsClientKeyPath); - displayname = "TLS Client Key Path"; - tooltip = "PEM path for the private key that matches the client certificate."; - typeName = "STRING"; - defaultValue = ""; - }; - class GVAR(moduleEnrollmentPort): Edit { - property = QGVAR(moduleEnrollmentPort); - displayname = "Enrollment HTTPS Port"; - tooltip = "Port used for GET /Marti/api/tls/config and POST /Marti/api/tls/signClient/v2."; - typeName = "NUMBER"; - defaultValue = "8446"; - }; - class GVAR(moduleEnrollmentUsername): Edit { - property = QGVAR(moduleEnrollmentUsername); - displayname = "Enrollment Username"; - tooltip = "Socket enrollment username for Basic Auth."; - typeName = "STRING"; - defaultValue = ""; - }; - class GVAR(moduleEnrollmentPassword): Edit { - property = QGVAR(moduleEnrollmentPassword); - displayname = "Enrollment Password"; - tooltip = "Socket enrollment password for Basic Auth."; - typeName = "STRING"; - defaultValue = ""; - }; - class GVAR(moduleEnrollmentClientUid): Edit { - property = QGVAR(moduleEnrollmentClientUid); - displayname = "Enrollment Client UID"; - tooltip = "Optional device identifier sent as clientUid. Leave blank to auto-generate."; - typeName = "STRING"; - defaultValue = ""; - }; - class ModuleDescription: ModuleDescription {}; + class GVAR(moduleInstancePort): Edit { + property = QGVAR(moduleInstancePort); + displayName = "TAK Server TCP Port"; + tooltip = "Port for the unauthenticated TCP socket."; + typeName = "NUMBER"; + defaultValue = "8088"; }; + class ModuleDescription: ModuleDescription {}; + }; class ModuleDescription: ModuleDescription { - description = "Generate the initial ARMATAK configuration, syncronizing all players to the TAK server instance"; + description = "Connect ArmaTAK to a TAK server over plain TCP."; sync[] = {"LocationArea_F"}; }; }; - class GVAR(coreModuleCurator): GVAR(coreModule) { + class GVAR(enrollModule): GVAR(connectionModuleBase) { + scope = 2; + displayName = "CoT Router (Authenticated)"; + function = QFUNC(3denEnrollModuleConfig); + + class Attributes: AttributesBase { + class GVAR(moduleInstanceAddress): Edit { + property = QGVAR(moduleInstanceAddress); + displayname = "TAK Server Address"; + tooltip = "Hostname or IP address used for enrollment and the final TLS connection."; + typeName = "STRING"; + defaultValue = "'localhost'"; + }; + class GVAR(moduleEnrollmentPort): Edit { + property = QGVAR(moduleEnrollmentPort); + displayName = "Enrollment HTTPS Port"; + tooltip = "Port used for GET /Marti/api/tls/config and POST /Marti/api/tls/signClient/v2."; + typeName = "NUMBER"; + defaultValue = "8446"; + }; + class GVAR(moduleEnrollmentUsername): Edit { + property = QGVAR(moduleEnrollmentUsername); + displayName = "Enrollment Username"; + tooltip = "Username used in Basic Auth for client certificate enrollment."; + typeName = "STRING"; + defaultValue = "''"; + }; + class GVAR(moduleEnrollmentPassword): Edit { + property = QGVAR(moduleEnrollmentPassword); + displayName = "Enrollment Password"; + tooltip = "Password used in Basic Auth for client certificate enrollment."; + typeName = "STRING"; + defaultValue = "''"; + }; + class ModuleDescription: ModuleDescription {}; + }; + + class ModuleDescription: ModuleDescription { + description = "Enroll a client certificate and connect ArmaTAK over mTLS."; + sync[] = {"LocationArea_F"}; + }; + }; + + class GVAR(tcpModuleCurator): GVAR(tcpModule) { scope = 1; scopeCurator = 2; function = ""; - displayName = "CoT Router (Zeus)"; - curatorInfoType = "armatak_zeus_core_module_dialog"; + displayName = "CoT Router (TCP, Zeus)"; + curatorInfoType = "armatak_zeus_tcp_module_dialog"; + }; + + class GVAR(enrollModuleCurator): GVAR(enrollModule) { + scope = 1; + scopeCurator = 2; + function = ""; + displayName = "CoT Router (Authenticated, Zeus)"; + curatorInfoType = "armatak_zeus_enroll_module_dialog"; }; class GVAR(markEntity): GVAR(moduleBase) { - curatorCanAttach = 1; - category = QEGVAR(main,moduleCategory); + curatorCanAttach = 1; + category = QEGVAR(main,moduleCategory); displayname = "Mark Entity"; - function = QFUNC(routerEntityAdd); - icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa"; - }; + function = QFUNC(routerEntityAdd); + icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa"; + }; }; diff --git a/addons/server/XEH_PREP.hpp b/addons/server/XEH_PREP.hpp index 7dd10b8..1503a24 100644 --- a/addons/server/XEH_PREP.hpp +++ b/addons/server/XEH_PREP.hpp @@ -1,4 +1,7 @@ -PREP(3denCoreModuleConfig); +PREP(3denEnrollModuleConfig); +PREP(3denTcpModuleConfig); PREP(routerEntityAdd); PREP(routerEntityRemove); -PREP(ZeusCoreModuleConfig); +PREP(startCotRouter); +PREP(ZeusEnrollModuleConfig); +PREP(ZeusTcpModuleConfig); diff --git a/addons/server/config.cpp b/addons/server/config.cpp index e8dd595..f25f56f 100644 --- a/addons/server/config.cpp +++ b/addons/server/config.cpp @@ -4,8 +4,10 @@ class CfgPatches { class ADDON { name = COMPONENT_NAME; units[] = { - QGVAR(coreModule), - QGVAR(coreModuleCurator), + QGVAR(tcpModule), + QGVAR(tcpModuleCurator), + QGVAR(enrollModule), + QGVAR(enrollModuleCurator), QGVAR(markEntity) }; weapons[] = {}; diff --git a/addons/server/dialog.hpp b/addons/server/dialog.hpp index 2e80e29..5b3c003 100644 --- a/addons/server/dialog.hpp +++ b/addons/server/dialog.hpp @@ -3,222 +3,172 @@ class RscBackground; class RscButton; class RscEdit; -class armatak_zeus_core_module_dialog { +class armatak_zeus_tcp_module_dialog { idd = 999991; movingEnable = 0; class ControlsBackground { - class armatak_gui_module_zeus_core_dialog_main_frame: RscBackground { + class main_frame: RscBackground { idc = 1800; x = "0.386562 * safezoneW + safezoneX"; - y = "0.08 * safezoneH + safezoneY"; + y = "0.29 * safezoneH + safezoneY"; w = "0.216563 * safezoneW"; - h = "0.84 * safezoneH"; - colorBackground[]={0,0,0,0.45}; + h = "0.32 * safezoneH"; + colorBackground[] = {0,0,0,0.45}; }; }; class Controls { - class armatak_gui_module_zeus_core_dialog_address_edit: RscEdit { - idc = 14000; - text = "localhost"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.185 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_address_port_edit: RscEdit { - idc = 14001; - text = "8088"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.255 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_transport_mode_edit: RscEdit { - idc = 14006; - text = "tcp"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.115 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_enrollment_port_edit: RscEdit { - idc = 14007; - text = "8446"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.325 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_enrollment_user_edit: RscEdit { - idc = 14008; - text = ""; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.395 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_tls_name_edit: RscEdit { - idc = 14002; - text = ""; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.465 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_tls_ca_edit: RscEdit { - idc = 14003; - text = ""; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.535 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_tls_client_cert_edit: RscEdit { - idc = 14004; - text = ""; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.605 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_tls_client_key_edit: RscEdit { - idc = 14005; - text = ""; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.675 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_enrollment_password_edit: RscEdit { - idc = 14009; - text = ""; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.745 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_enrollment_client_uid_edit: RscEdit { - idc = 14010; - text = ""; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.815 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.044 * safezoneH"; - colorBackground[]={0,0,0,0.5}; - }; - class armatak_gui_module_zeus_core_dialog_transport_mode_text: RscText { - idc = 1006; - text = "Transport Mode (tcp/manual_mtls/enroll_mtls)"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.082 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_address_text: RscText { + class address_text: RscText { idc = 1000; text = "TAK Server Address"; x = "0.391719 * safezoneW + safezoneX"; - y = "0.152 * safezoneH + safezoneY"; + y = "0.332 * safezoneH + safezoneY"; w = "0.20625 * safezoneW"; h = "0.033 * safezoneH"; }; - class armatak_gui_module_zeus_core_dialog_address_port_text: RscText { + class address_edit: RscEdit { + idc = 14000; + text = "localhost"; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.365 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.044 * safezoneH"; + colorBackground[] = {0,0,0,0.5}; + }; + class port_text: RscText { idc = 1001; text = "TAK Server Port"; x = "0.391719 * safezoneW + safezoneX"; - y = "0.222 * safezoneH + safezoneY"; + y = "0.425 * safezoneH + safezoneY"; w = "0.20625 * safezoneW"; h = "0.033 * safezoneH"; }; - class armatak_gui_module_zeus_core_dialog_enrollment_port_text: RscText { - idc = 1007; - text = "Enrollment HTTPS Port"; + class port_edit: RscEdit { + idc = 14001; + text = "8088"; x = "0.391719 * safezoneW + safezoneX"; - y = "0.292 * safezoneH + safezoneY"; + y = "0.458 * safezoneH + safezoneY"; w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; + h = "0.044 * safezoneH"; + colorBackground[] = {0,0,0,0.5}; }; - class armatak_gui_module_zeus_core_dialog_enrollment_user_text: RscText { - idc = 1008; - text = "Enrollment Username"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.362 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_tls_name_text: RscText { - idc = 1002; - text = "TLS Server Name"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.432 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_tls_ca_text: RscText { - idc = 1003; - text = "TLS CA Cert Path"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.502 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_tls_client_cert_text: RscText { - idc = 1004; - text = "TLS Client Cert Path"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.572 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_tls_client_key_text: RscText { - idc = 1005; - text = "TLS Client Key Path"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.642 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_enrollment_password_text: RscText { - idc = 1009; - text = "Enrollment Password"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.712 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_enrollment_client_uid_text: RscText { - idc = 1010; - text = "Enrollment Client UID"; - x = "0.391719 * safezoneW + safezoneX"; - y = "0.782 * safezoneH + safezoneY"; - w = "0.20625 * safezoneW"; - h = "0.033 * safezoneH"; - }; - class armatak_gui_module_zeus_core_dialog_address_button_cancel: RscButton { + class button_cancel: RscButton { idc = 1601; text = "Cancel"; action = "closeDialog 2;"; x = "0.551563 * safezoneW + safezoneX"; - y = "0.855 * safezoneH + safezoneY"; + y = "0.535 * safezoneH + safezoneY"; w = "0.0464063 * safezoneW"; h = "0.055 * safezoneH"; }; - class armatak_gui_module_zeus_core_dialog_address_button_ok: RscButton { + class button_ok: RscButton { idc = 1600; text = "Ok"; - action = QUOTE(call FUNC(zeusCoreModuleConfig)); + action = QUOTE(call FUNC(ZeusTcpModuleConfig)); x = "0.5 * safezoneW + safezoneX"; - y = "0.855 * safezoneH + safezoneY"; + y = "0.535 * safezoneH + safezoneY"; + w = "0.0464063 * safezoneW"; + h = "0.055 * safezoneH"; + }; + }; +}; + +class armatak_zeus_enroll_module_dialog { + idd = 999992; + movingEnable = 0; + class ControlsBackground { + class main_frame: RscBackground { + idc = 1810; + x = "0.386562 * safezoneW + safezoneX"; + y = "0.2 * safezoneH + safezoneY"; + w = "0.216563 * safezoneW"; + h = "0.52 * safezoneH"; + colorBackground[] = {0,0,0,0.45}; + }; + }; + class Controls { + class address_text: RscText { + idc = 1010; + text = "TAK Server Address"; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.242 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.033 * safezoneH"; + }; + class address_edit: RscEdit { + idc = 14100; + text = "localhost"; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.275 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.044 * safezoneH"; + colorBackground[] = {0,0,0,0.5}; + }; + class enroll_port_text: RscText { + idc = 1011; + text = "Enrollment HTTPS Port"; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.335 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.033 * safezoneH"; + }; + class enroll_port_edit: RscEdit { + idc = 14101; + text = "8446"; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.368 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.044 * safezoneH"; + colorBackground[] = {0,0,0,0.5}; + }; + class username_text: RscText { + idc = 1012; + text = "Enrollment Username"; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.428 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.033 * safezoneH"; + }; + class username_edit: RscEdit { + idc = 14102; + text = ""; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.461 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.044 * safezoneH"; + colorBackground[] = {0,0,0,0.5}; + }; + class password_text: RscText { + idc = 1013; + text = "Enrollment Password"; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.521 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.033 * safezoneH"; + }; + class password_edit: RscEdit { + idc = 14103; + text = ""; + x = "0.391719 * safezoneW + safezoneX"; + y = "0.554 * safezoneH + safezoneY"; + w = "0.20625 * safezoneW"; + h = "0.044 * safezoneH"; + colorBackground[] = {0,0,0,0.5}; + }; + class button_cancel: RscButton { + idc = 1611; + text = "Cancel"; + action = "closeDialog 2;"; + x = "0.551563 * safezoneW + safezoneX"; + y = "0.645 * safezoneH + safezoneY"; + w = "0.0464063 * safezoneW"; + h = "0.055 * safezoneH"; + }; + class button_ok: RscButton { + idc = 1610; + text = "Ok"; + action = QUOTE(call FUNC(ZeusEnrollModuleConfig)); + x = "0.5 * safezoneW + safezoneX"; + y = "0.645 * safezoneH + safezoneY"; w = "0.0464063 * safezoneW"; h = "0.055 * safezoneH"; }; diff --git a/addons/server/functions/fnc_3denCoreModuleConfig.sqf b/addons/server/functions/fnc_3denCoreModuleConfig.sqf deleted file mode 100644 index 8f609c7..0000000 --- a/addons/server/functions/fnc_3denCoreModuleConfig.sqf +++ /dev/null @@ -1,106 +0,0 @@ -#include "..\script_component.hpp" - -params [ - ["_logic", objNull, [objNull]], - ["_units", [], [[]]], - ["_activated", true, [true]] -]; - - if (isServer) exitWith { - ["Connecting to TCP Socket", "success", "TCP Socket"] call EFUNC(main,notify); - - _transport_mode = _logic getVariable [QGVAR(moduleTransportMode), "tcp"]; - _tak_server_instance_address = _logic getVariable QGVAR(moduleInstanceAddress); - _tak_server_instance_port = _logic getVariable QGVAR(moduleInstancePort); - _tak_server_tls_name = _logic getVariable [QGVAR(moduleTlsServerName), ""]; - _tak_server_tls_ca_cert_path = _logic getVariable [QGVAR(moduleTlsCaCertPath), ""]; - _tak_server_tls_client_cert_path = _logic getVariable [QGVAR(moduleTlsClientCertPath), ""]; - _tak_server_tls_client_key_path = _logic getVariable [QGVAR(moduleTlsClientKeyPath), ""]; - _tak_server_enrollment_port = _logic getVariable [QGVAR(moduleEnrollmentPort), 8446]; - _tak_server_enrollment_username = _logic getVariable [QGVAR(moduleEnrollmentUsername), ""]; - _tak_server_enrollment_password = _logic getVariable [QGVAR(moduleEnrollmentPassword), ""]; - _tak_server_enrollment_client_uid = _logic getVariable [QGVAR(moduleEnrollmentClientUid), ""]; - - _tak_server_fulladdress = _tak_server_instance_address + ":" + (str _tak_server_instance_port); - - missionNamespace setVariable ["armatak_server_instance", _tak_server_fulladdress]; - missionNamespace setVariable ["armatak_tcp_socket_is_running", true]; - - if (_tak_server_tls_name == "") then { - _tak_server_tls_name = _tak_server_instance_address; - }; - - switch (_transport_mode) do { - case "manual_mtls": { - "armatak" callExtension [ - "tcp_socket:start_mtls", - [ - _tak_server_fulladdress, - _tak_server_tls_name, - _tak_server_tls_ca_cert_path, - _tak_server_tls_client_cert_path, - _tak_server_tls_client_key_path - ] - ]; - }; - case "enroll_mtls": { - "armatak" callExtension [ - "tcp_socket:start_enroll_mtls", - [ - _tak_server_instance_address, - _tak_server_tls_name, - str _tak_server_enrollment_port, - _tak_server_enrollment_username, - _tak_server_enrollment_password, - _tak_server_enrollment_client_uid - ] - ]; - }; - default { - "armatak" callExtension ["tcp_socket:start", [_tak_server_fulladdress]]; - }; - }; - - _syncUnits = synchronizedObjects _logic; - - missionNamespace setVariable ["armatak_server_syncedUnits", _syncUnits]; - - GVAR(syncedUnits) = missionNamespace getVariable "armatak_server_syncedUnits"; - - [{ - GVAR(syncedUnits) = missionNamespace getVariable "armatak_server_syncedUnits"; - - { - _objectType = _x call BIS_fnc_objectType; - switch (true) do { - case ((_objectType select 0) == "Soldier"): { - _callsign = [_x] call armatak_fnc_extract_unit_callsign; - _group_name = [group _x] call armatak_fnc_extract_group_color; - _group_role = [_x] call armatak_fnc_extract_group_role; - - [_x, _callsign, _group_name, _group_role] call armatak_fnc_send_eud_cot; - [_x] call armatak_fnc_send_digital_pointer_cot; - }; - case ((_objectType select 0) == "Vehicle"): { - _atak_type = [_x] call armatak_fnc_extract_role; - _callsign = [_x] call armatak_fnc_extract_marker_callsign; - - [_x, _atak_type, _callsign] call armatak_fnc_send_marker_cot; - - _x call armatak_fnc_extract_sensor_data; - }; - case ((_objectType select 0) == "VehicleAutonomous"): { - _atak_type = [_x] call armatak_fnc_extract_role; - _callsign = [_x] call armatak_fnc_extract_marker_callsign; - - [_x, _atak_type, _callsign] call armatak_fnc_send_drone_cot; - [_x] call armatak_fnc_send_digital_pointer_cot; - - _x call armatak_fnc_extract_sensor_data; - }; - }; - } forEach GVAR(syncedUnits); - }, 1, []] call CBA_fnc_addPerFrameHandler; -}; - -true; diff --git a/addons/server/functions/fnc_3denEnrollModuleConfig.sqf b/addons/server/functions/fnc_3denEnrollModuleConfig.sqf new file mode 100644 index 0000000..094ff29 --- /dev/null +++ b/addons/server/functions/fnc_3denEnrollModuleConfig.sqf @@ -0,0 +1,37 @@ +#include "..\script_component.hpp" + +params [ + ["_logic", objNull, [objNull]], + ["_units", [], [[]]], + ["_activated", true, [true]] +]; + +if (isServer) exitWith { + if (missionNamespace getVariable ["armatak_tcp_socket_is_running", false]) exitWith { + ["Socket was called twice", "error", "TCP Socket"] call EFUNC(main,notify); + }; + + ["Connecting to authenticated TAK socket", "success", "TCP Socket"] call EFUNC(main,notify); + + _tak_server_instance_address = _logic getVariable [QGVAR(moduleInstanceAddress), "localhost"]; + _tak_server_enrollment_port = _logic getVariable [QGVAR(moduleEnrollmentPort), 8446]; + _tak_server_enrollment_username = _logic getVariable [QGVAR(moduleEnrollmentUsername), ""]; + _tak_server_enrollment_password = _logic getVariable [QGVAR(moduleEnrollmentPassword), ""]; + + "armatak" callExtension [ + "tcp_socket:start_enroll_mtls", + [ + _tak_server_instance_address, + _tak_server_instance_address, + str _tak_server_enrollment_port, + _tak_server_enrollment_username, + _tak_server_enrollment_password, + "" + ] + ]; + + missionNamespace setVariable ["armatak_server_syncedUnits", synchronizedObjects _logic]; + _tak_server_instance_address call FUNC(startCotRouter); +}; + +true diff --git a/addons/server/functions/fnc_3denTcpModuleConfig.sqf b/addons/server/functions/fnc_3denTcpModuleConfig.sqf new file mode 100644 index 0000000..5ad0d11 --- /dev/null +++ b/addons/server/functions/fnc_3denTcpModuleConfig.sqf @@ -0,0 +1,26 @@ +#include "..\script_component.hpp" + +params [ + ["_logic", objNull, [objNull]], + ["_units", [], [[]]], + ["_activated", true, [true]] +]; + +if (isServer) exitWith { + if (missionNamespace getVariable ["armatak_tcp_socket_is_running", false]) exitWith { + ["Socket was called twice", "error", "TCP Socket"] call EFUNC(main,notify); + }; + + ["Connecting to TCP Socket", "success", "TCP Socket"] call EFUNC(main,notify); + + _tak_server_instance_address = _logic getVariable [QGVAR(moduleInstanceAddress), "localhost"]; + _tak_server_instance_port = _logic getVariable [QGVAR(moduleInstancePort), 8088]; + _tak_server_fulladdress = _tak_server_instance_address + ":" + (str _tak_server_instance_port); + + "armatak" callExtension ["tcp_socket:start", [_tak_server_fulladdress]]; + + missionNamespace setVariable ["armatak_server_syncedUnits", synchronizedObjects _logic]; + _tak_server_fulladdress call FUNC(startCotRouter); +}; + +true diff --git a/addons/server/functions/fnc_ZeusCoreModuleConfig.sqf b/addons/server/functions/fnc_ZeusCoreModuleConfig.sqf deleted file mode 100644 index 5a84ac3..0000000 --- a/addons/server/functions/fnc_ZeusCoreModuleConfig.sqf +++ /dev/null @@ -1,109 +0,0 @@ -#include "..\script_component.hpp" - -params ["_logic"]; - -_socket_is_running = missionNamespace getVariable ["armatak_tcp_socket_is_running", false]; - -if (_socket_is_running) exitWith { - ["Socket was called twice", "error", "TCP Socket"] call EFUNC(main,notify); - closeDialog 1; -}; - -disableSerialization; - -["Connecting to TCP Socket", "success", "TCP Socket"] call EFUNC(main,notify); - -_transport_mode = toLower (ctrlText 14006); -_tak_server_instance_address = ctrlText 14000; -_tak_server_instance_port = ctrlText 14001; -_tak_server_tls_name = ctrlText 14002; -_tak_server_tls_ca_cert_path = ctrlText 14003; -_tak_server_tls_client_cert_path = ctrlText 14004; -_tak_server_tls_client_key_path = ctrlText 14005; -_tak_server_enrollment_port = ctrlText 14007; -_tak_server_enrollment_username = ctrlText 14008; -_tak_server_enrollment_password = ctrlText 14009; -_tak_server_enrollment_client_uid = ctrlText 14010; - -_tak_server_fulladdress = ((_tak_server_instance_address) + ":" + (_tak_server_instance_port)); - -missionNamespace setVariable ["armatak_server_instance", _tak_server_fulladdress]; -missionNamespace setVariable ["armatak_tcp_socket_is_running", true]; - -if (_tak_server_tls_name == "") then { - _tak_server_tls_name = _tak_server_instance_address; -}; - -switch (_transport_mode) do { - case "manual_mtls": { - "armatak" callExtension [ - "tcp_socket:start_mtls", - [ - _tak_server_fulladdress, - _tak_server_tls_name, - _tak_server_tls_ca_cert_path, - _tak_server_tls_client_cert_path, - _tak_server_tls_client_key_path - ] - ]; - }; - case "enroll_mtls": { - "armatak" callExtension [ - "tcp_socket:start_enroll_mtls", - [ - _tak_server_instance_address, - _tak_server_tls_name, - _tak_server_enrollment_port, - _tak_server_enrollment_username, - _tak_server_enrollment_password, - _tak_server_enrollment_client_uid - ] - ]; - }; - default { - "armatak" callExtension ["tcp_socket:start", [_tak_server_fulladdress]]; - }; -}; - -_syncUnits = []; - -missionNamespace setVariable ["armatak_server_syncedUnits", _syncUnits]; - - GVAR(syncedUnits) = missionNamespace getVariable "armatak_server_syncedUnits"; - - [{ - GVAR(syncedUnits) = missionNamespace getVariable "armatak_server_syncedUnits"; - - { - _objectType = _x call BIS_fnc_objectType; - switch (true) do { - case ((_objectType select 0) == "Soldier"): { - _callsign = [_x] call armatak_fnc_extract_unit_callsign; - _group_name = [group _x] call armatak_fnc_extract_group_color; - _group_role = [_x] call armatak_fnc_extract_group_role; - - [_x, _callsign, _group_name, _group_role] call armatak_fnc_send_eud_cot; - [_x] call armatak_fnc_send_digital_pointer_cot; - }; - case ((_objectType select 0) == "Vehicle"): { - _atak_type = [_x] call armatak_fnc_extract_role; - _callsign = [_x] call armatak_fnc_extract_marker_callsign; - - [_x, _atak_type, _callsign] call armatak_fnc_send_marker_cot; - - _x call armatak_fnc_extract_sensor_data; - }; - case ((_objectType select 0) == "VehicleAutonomous"): { - _atak_type = [_x] call armatak_fnc_extract_role; - _callsign = [_x] call armatak_fnc_extract_marker_callsign; - - [_x, _atak_type, _callsign] call armatak_fnc_send_drone_cot; - [_x] call armatak_fnc_send_digital_pointer_cot; - - _x call armatak_fnc_extract_sensor_data; - }; - }; - } forEach GVAR(syncedUnits); - }, 1, []] call CBA_fnc_addPerFrameHandler; -deleteVehicle _logic; -closeDialog 1; diff --git a/addons/server/functions/fnc_ZeusEnrollModuleConfig.sqf b/addons/server/functions/fnc_ZeusEnrollModuleConfig.sqf new file mode 100644 index 0000000..263f214 --- /dev/null +++ b/addons/server/functions/fnc_ZeusEnrollModuleConfig.sqf @@ -0,0 +1,33 @@ +#include "..\script_component.hpp" + +params ["_logic"]; + +if (missionNamespace getVariable ["armatak_tcp_socket_is_running", false]) exitWith { + ["Socket was called twice", "error", "TCP Socket"] call EFUNC(main,notify); + closeDialog 1; +}; + +disableSerialization; + +["Connecting to authenticated TAK socket", "success", "TCP Socket"] call EFUNC(main,notify); + +_tak_server_instance_address = ctrlText 14100; +_tak_server_enrollment_port = ctrlText 14101; +_tak_server_enrollment_username = ctrlText 14102; +_tak_server_enrollment_password = ctrlText 14103; + +"armatak" callExtension [ + "tcp_socket:start_enroll_mtls", + [ + _tak_server_instance_address, + _tak_server_instance_address, + _tak_server_enrollment_port, + _tak_server_enrollment_username, + _tak_server_enrollment_password, + "" + ] +]; + +_tak_server_instance_address call FUNC(startCotRouter); +deleteVehicle _logic; +closeDialog 1; diff --git a/addons/server/functions/fnc_ZeusTcpModuleConfig.sqf b/addons/server/functions/fnc_ZeusTcpModuleConfig.sqf new file mode 100644 index 0000000..8caee33 --- /dev/null +++ b/addons/server/functions/fnc_ZeusTcpModuleConfig.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" + +params ["_logic"]; + +if (missionNamespace getVariable ["armatak_tcp_socket_is_running", false]) exitWith { + ["Socket was called twice", "error", "TCP Socket"] call EFUNC(main,notify); + closeDialog 1; +}; + +disableSerialization; + +["Connecting to TCP Socket", "success", "TCP Socket"] call EFUNC(main,notify); + +_tak_server_instance_address = ctrlText 14000; +_tak_server_instance_port = ctrlText 14001; +_tak_server_fulladdress = _tak_server_instance_address + ":" + _tak_server_instance_port; + +"armatak" callExtension ["tcp_socket:start", [_tak_server_fulladdress]]; + +_tak_server_fulladdress call FUNC(startCotRouter); +deleteVehicle _logic; +closeDialog 1; diff --git a/addons/server/functions/fnc_startCotRouter.sqf b/addons/server/functions/fnc_startCotRouter.sqf new file mode 100644 index 0000000..14d72b9 --- /dev/null +++ b/addons/server/functions/fnc_startCotRouter.sqf @@ -0,0 +1,47 @@ +#include "..\script_component.hpp" + +params [["_server_instance", "", [""]]]; + +missionNamespace setVariable ["armatak_server_instance", _server_instance]; +missionNamespace setVariable ["armatak_tcp_socket_is_running", true]; + +if (isNil { missionNamespace getVariable "armatak_server_syncedUnits" }) then { + missionNamespace setVariable ["armatak_server_syncedUnits", []]; +}; + +GVAR(syncedUnits) = missionNamespace getVariable "armatak_server_syncedUnits"; + +[{ + GVAR(syncedUnits) = missionNamespace getVariable "armatak_server_syncedUnits"; + + { + _objectType = _x call BIS_fnc_objectType; + switch (true) do { + case ((_objectType select 0) == "Soldier"): { + _callsign = [_x] call armatak_fnc_extract_unit_callsign; + _group_name = [group _x] call armatak_fnc_extract_group_color; + _group_role = [_x] call armatak_fnc_extract_group_role; + + [_x, _callsign, _group_name, _group_role] call armatak_fnc_send_eud_cot; + [_x] call armatak_fnc_send_digital_pointer_cot; + }; + case ((_objectType select 0) == "Vehicle"): { + _atak_type = [_x] call armatak_fnc_extract_role; + _callsign = [_x] call armatak_fnc_extract_marker_callsign; + + [_x, _atak_type, _callsign] call armatak_fnc_send_marker_cot; + _x call armatak_fnc_extract_sensor_data; + }; + case ((_objectType select 0) == "VehicleAutonomous"): { + _atak_type = [_x] call armatak_fnc_extract_role; + _callsign = [_x] call armatak_fnc_extract_marker_callsign; + + [_x, _atak_type, _callsign] call armatak_fnc_send_drone_cot; + [_x] call armatak_fnc_send_digital_pointer_cot; + _x call armatak_fnc_extract_sensor_data; + }; + }; + } forEach GVAR(syncedUnits); +}, 1, []] call CBA_fnc_addPerFrameHandler; + +true diff --git a/src/tcp/tls/enrollment.rs b/src/tcp/tls/enrollment.rs index b08e9e2..46395fb 100644 --- a/src/tcp/tls/enrollment.rs +++ b/src/tcp/tls/enrollment.rs @@ -51,6 +51,21 @@ fn enrollment_http_client() -> Result { .map_err(|e| format!("failed to build enrollment HTTP client: {}", e)) } +fn response_error_details(response: reqwest::blocking::Response) -> String { + let status = response.status(); + match response.text() { + Ok(body) => { + let trimmed = body.trim(); + if trimmed.is_empty() { + status.to_string() + } else { + format!("{}: {}", status, trimmed) + } + } + Err(_) => status.to_string(), + } +} + fn fetch_enrollment_config(host: &str, enroll_port: &str) -> Result { let url = format!( "https://{}:{}/Marti/api/tls/config", @@ -58,11 +73,20 @@ fn fetch_enrollment_config(host: &str, enroll_port: &str) -> Result