mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 16:43:30 +00:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ee9030c00 | |||
| 5b29a40990 | |||
| 708fe5e670 | |||
| e32aadda4e | |||
| c35b7f0268 | |||
| 876cf900c3 | |||
| 778ac0ac54 | |||
| b816144fb0 | |||
| 61ba9f6d63 | |||
| f88c02a7aa | |||
| 5ffc08e6f1 | |||
| 9392380c78 | |||
| a18343b81d | |||
|
|
13cd08c655 | ||
|
|
8fe14dc18d | ||
|
|
1bec26df8a | ||
|
|
c5d5da636f | ||
|
|
c2e137e67c | ||
|
|
de5ac9dbb5 | ||
|
|
ef3be1e768 | ||
|
|
9bda92d389 | ||
|
|
9763cb6697 | ||
|
|
5ac49e12f8 | ||
|
|
2108d20b01 | ||
|
|
524e7a0b3e | ||
|
|
7e4379ada4 | ||
|
|
572b2a360f | ||
|
|
083ccd2906 | ||
|
|
35a45d2cd4 | ||
|
|
2b241fbeaf | ||
|
|
ad9ba834cc | ||
|
|
469403d9b5 | ||
|
|
01ea754f57 | ||
|
|
fd8a25790e | ||
|
|
9ede7237b8 | ||
|
|
1242b1f79f | ||
|
|
9f8f326446 | ||
|
|
bf3b0cf0d4 | ||
|
|
42098401f2 | ||
|
|
ef787a6a09 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,6 +3,7 @@
|
|||||||
hemtt
|
hemtt
|
||||||
hemtt.exe
|
hemtt.exe
|
||||||
*.biprivatekey
|
*.biprivatekey
|
||||||
|
.hemttprivatekey
|
||||||
source/
|
source/
|
||||||
.vscode
|
.vscode
|
||||||
releases/
|
releases/
|
||||||
@@ -87,4 +88,4 @@ target/
|
|||||||
.cxx
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
|
|
||||||
*.apk
|
*.apk
|
||||||
|
|||||||
1074
Cargo.lock
generated
1074
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,10 @@ chrono = "0.4.39"
|
|||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
log4rs = "1.3.0"
|
log4rs = "1.3.0"
|
||||||
once_cell = "1.19.0"
|
reqwest = { version = "0.12.15", default-features = false, features = ["blocking", "json", "rustls-tls"] }
|
||||||
|
rcgen = { version = "0.13.2", default-features = false, features = ["crypto", "pem", "aws_lc_rs"] }
|
||||||
|
rustls = "0.23.23"
|
||||||
|
rustls-pemfile = "2.2.0"
|
||||||
serde = { version = "1.0.210", features = ["derive"] }
|
serde = { version = "1.0.210", features = ["derive"] }
|
||||||
|
|
||||||
[dependencies.uuid]
|
[dependencies.uuid]
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
ARMATAK is a server side Arma 3 addons for streaming unit positions to TAK Clients in sessions on real locations maps. It can be runned both as a clientside mod or a serverside mod, when runned serverside, it will create a TCP Socket connection between Arma 3 and the TAK Server, sending the game session information into it. When used clientside, Arma 3 will host a websocket server that you can connect to your phone and mock the phone's location to the player's in game location.
|
ARMATAK is a server side Arma 3 addons for streaming unit positions to TAK Clients in sessions on real locations maps. It can be runned both as a clientside mod or a serverside mod, when runned serverside, it will create a TCP Socket connection between Arma 3 and the TAK Server, sending the game session information into it. When used clientside, Arma 3 will host a websocket server that you can connect to your phone and mock the phone's location to the player's in game location.
|
||||||
|
|
||||||
|
The server-side CoT router supports two transports:
|
||||||
|
- Plain TCP, for legacy TAK ingress.
|
||||||
|
- Mutual TLS, using the TAK Server authentication API, so the Arma session can publish as an authenticated TAK device on port `8089`.
|
||||||
|
|
||||||
## Get in Touch
|
## Get in Touch
|
||||||
|
|
||||||
[Join the Discord Server for ARMATAK!](https://discord.gg/svK64PCycU)
|
[Join the Discord Server for ARMATAK!](https://discord.gg/svK64PCycU)
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
#include "..\script_component.hpp"
|
#include "..\script_component.hpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Author: Valmo Trindade
|
* Author: Valmo Trindade
|
||||||
* This function is used to convert the position of a unit to the world world location.
|
* This function is used to convert the position of a unit to the world world location.
|
||||||
*
|
*
|
||||||
* Argument:
|
* Argument:
|
||||||
* 0: in game latitude <NUMBER> is the latitude of the unit.
|
* 0: in game latitude <NUMBER> is the latitude of the unit.
|
||||||
* 1: in game longitude <NUMBER> is the longitude of the unit.
|
* 1: in game longitude <NUMBER> is the longitude of the unit.
|
||||||
* 2: in game altitude <NUMBER> is the altitude of the unit.
|
* 2: in game altitude <NUMBER> is the altitude of the unit.
|
||||||
* 3: in game bearing <NUMBER> is the bearing of the unit.
|
* 3: in game bearing <NUMBER> is the bearing of the unit.
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* ARRAY -> [latitude, longitude, altitude, bearing]
|
* ARRAY -> [latitude, longitude, altitude, bearing]
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [player] call armatak_client_fnc_convertClientLocation;
|
* [player] call armatak_client_fnc_convertClientLocation;
|
||||||
*
|
*
|
||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
params["_latitude", "_longitude", "_altitude"];
|
params["_latitude", "_longitude", "_altitude"];
|
||||||
@@ -38,6 +38,9 @@ switch (toLower worldName) do {
|
|||||||
case "vr": {
|
case "vr": {
|
||||||
_realLocation = _position call armatak_fnc_convert_to_vr;
|
_realLocation = _position call armatak_fnc_convert_to_vr;
|
||||||
};
|
};
|
||||||
|
case "lawn": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_lawn;
|
||||||
|
};
|
||||||
case "cucui": {
|
case "cucui": {
|
||||||
_realLocation = _position call armatak_fnc_convert_to_cucui;
|
_realLocation = _position call armatak_fnc_convert_to_cucui;
|
||||||
};
|
};
|
||||||
@@ -74,9 +77,36 @@ switch (toLower worldName) do {
|
|||||||
case "kunduz_valley": {
|
case "kunduz_valley": {
|
||||||
_realLocation = _position call armatak_fnc_convert_to_kunduz_valley;
|
_realLocation = _position call armatak_fnc_convert_to_kunduz_valley;
|
||||||
};
|
};
|
||||||
|
case "malvinasfalkands": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_malvinas_malvinasfalkands;
|
||||||
|
};
|
||||||
|
case "pebble_island_airfield": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_malvinas_pebble_island_airfield;
|
||||||
|
};
|
||||||
|
case "p_argentino_stanley": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_malvinas_p_argentino_stanley;
|
||||||
|
};
|
||||||
|
case "top_malo_house": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_malvinas_top_malo_house;
|
||||||
|
};
|
||||||
|
case "pradera_ganso": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_malvinas_pradera_ganso;
|
||||||
|
};
|
||||||
case "tanoa": {
|
case "tanoa": {
|
||||||
_realLocation = _position call armatak_fnc_convert_to_tanoa;
|
_realLocation = _position call armatak_fnc_convert_to_tanoa;
|
||||||
}
|
};
|
||||||
|
case "zagor_zagorsk_reserved_forest": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_zagor_zagorsk_reserved_forest;
|
||||||
|
};
|
||||||
|
case "umb_colombia": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_colombia;
|
||||||
|
};
|
||||||
|
case "clafghan": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_clafghan;
|
||||||
|
};
|
||||||
|
case "rut_mandol": {
|
||||||
|
_realLocation = _position call armatak_fnc_convert_to_rut_mandol;
|
||||||
|
};
|
||||||
default {
|
default {
|
||||||
_warning = format ["<t color='#FF8021'>ARMATAK</t><br/> %1", "Unsupported Map"];
|
_warning = format ["<t color='#FF8021'>ARMATAK</t><br/> %1", "Unsupported Map"];
|
||||||
[[_warning, 1.5]] call CBA_fnc_notify;
|
[[_warning, 1.5]] call CBA_fnc_notify;
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ class CfgFunctions {
|
|||||||
class send_group_cots {
|
class send_group_cots {
|
||||||
file = "\armatak\armatak\addons\main\functions\api\fn_send_group_cots.sqf";
|
file = "\armatak\armatak\addons\main\functions\api\fn_send_group_cots.sqf";
|
||||||
};
|
};
|
||||||
|
class send_enemy_cot {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\api\fn_send_enemy_cot.sqf";
|
||||||
|
};
|
||||||
class send_eud_cot {
|
class send_eud_cot {
|
||||||
file = "\armatak\armatak\addons\main\functions\api\fn_send_eud_cot.sqf";
|
file = "\armatak\armatak\addons\main\functions\api\fn_send_eud_cot.sqf";
|
||||||
};
|
};
|
||||||
@@ -31,6 +34,9 @@ class CfgFunctions {
|
|||||||
class extract_role {
|
class extract_role {
|
||||||
file = "\armatak\armatak\addons\main\functions\extract_data\fn_extract_role.sqf";
|
file = "\armatak\armatak\addons\main\functions\extract_data\fn_extract_role.sqf";
|
||||||
};
|
};
|
||||||
|
class extract_sensor_data {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\extract_data\fn_extract_sensor_data.sqf";
|
||||||
|
};
|
||||||
class extract_unit_callsign {
|
class extract_unit_callsign {
|
||||||
file = "\armatak\armatak\addons\main\functions\extract_data\fn_extract_unit_callsign.sqf";
|
file = "\armatak\armatak\addons\main\functions\extract_data\fn_extract_unit_callsign.sqf";
|
||||||
};
|
};
|
||||||
@@ -62,12 +68,30 @@ class CfgFunctions {
|
|||||||
class convert_to_kunduz_valley {
|
class convert_to_kunduz_valley {
|
||||||
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_kunduz_valley.sqf";
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_kunduz_valley.sqf";
|
||||||
};
|
};
|
||||||
|
class convert_to_lawn {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_lawn.sqf";
|
||||||
|
};
|
||||||
class convert_to_livonia {
|
class convert_to_livonia {
|
||||||
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_livonia.sqf";
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_livonia.sqf";
|
||||||
};
|
};
|
||||||
class convert_to_malden {
|
class convert_to_malden {
|
||||||
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_malden.sqf";
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_malden.sqf";
|
||||||
};
|
};
|
||||||
|
class convert_to_malvinas_malvinasfalkands {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_malvinas_malvinasfalkands.sqf";
|
||||||
|
};
|
||||||
|
class convert_to_malvinas_p_argentino_stanley {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_malvinas_p_argentino_stanley.sqf";
|
||||||
|
};
|
||||||
|
class convert_to_malvinas_pebble_island_airfield {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_malvinas_pebble_island_airfield.sqf";
|
||||||
|
};
|
||||||
|
class convert_to_malvinas_pradera_ganso {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_malvinas_pradera_ganso.sqf";
|
||||||
|
};
|
||||||
|
class convert_to_malvinas_top_malo_house {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_malvinas_top_malo_house.sqf";
|
||||||
|
};
|
||||||
class convert_to_southen_sahrani {
|
class convert_to_southen_sahrani {
|
||||||
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_southen_sahrani.sqf";
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_southen_sahrani.sqf";
|
||||||
};
|
};
|
||||||
@@ -86,6 +110,18 @@ class CfgFunctions {
|
|||||||
class convert_to_vr {
|
class convert_to_vr {
|
||||||
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_vr.sqf";
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_vr.sqf";
|
||||||
};
|
};
|
||||||
|
class convert_to_zagor_zagorsk_reserved_forest {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_zagor_zagorsk_reserved_forest.sqf";
|
||||||
|
};
|
||||||
|
class convert_to_colombia {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_colombia.sqf";
|
||||||
|
};
|
||||||
|
class convert_to_clafghan {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_clafghan.sqf";
|
||||||
|
};
|
||||||
|
class convert_to_rut_mandol {
|
||||||
|
file = "\armatak\armatak\addons\main\functions\map\fn_convert_to_rut_mandol.sqf";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,12 @@ addMissionEventHandler ["ExtensionCallback", {
|
|||||||
[_function, "success", _name] call FUNC(notify);
|
[_function, "success", _name] call FUNC(notify);
|
||||||
};
|
};
|
||||||
case "TCP SOCKET ERROR": {
|
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": {
|
case "VIDEO": {
|
||||||
[_function, "success", _name] call FUNC(notify);
|
[_function, "success", _name] call FUNC(notify);
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ params ["_unit"];
|
|||||||
_digitalPointer = laserTarget _unit;
|
_digitalPointer = laserTarget _unit;
|
||||||
|
|
||||||
if (!isNull _digitalPointer) then {
|
if (!isNull _digitalPointer) then {
|
||||||
_digitalPointerPosition = _digitalPointer call armatak_client_fnc_extractClientPosition;
|
_digitalPointerPosition = _digitalPointer call armatak_client_fnc_extractClientPosition;
|
||||||
|
|
||||||
_link_uid = [_unit] call armatak_fnc_extract_uuid;
|
_link_uid = [_unit] call armatak_fnc_extract_uuid;
|
||||||
_contact_callsign = ([player] call armatak_fnc_extract_unit_callsign) + ".DP1";
|
_contact_callsign = ([player] call armatak_fnc_extract_unit_callsign) + ".DP1";
|
||||||
|
|
||||||
_dpCot = [_link_uid, _contact_callsign, _digitalPointerPosition select 0, _digitalPointerPosition select 1, _digitalPointerPosition select 2];
|
_dpCot = [_link_uid, _contact_callsign, _digitalPointerPosition select 1, _digitalPointerPosition select 2, _digitalPointerPosition select 3];
|
||||||
|
|
||||||
"armatak" callExtension ["tcp_socket:send_digital_pointer_cot", [_dpCot]];
|
"armatak" callExtension ["tcp_socket:cot:digital_pointer", [_dpCot]];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// function name: armatak_fnc_extract_drone
|
// function name: armatak_fnc_send_drone_cot
|
||||||
// function author: Valmo
|
// function author: Valmo
|
||||||
// function description: Gets the drone information for the CoT Router
|
// function description: Gets the drone information for the CoT Router
|
||||||
|
|
||||||
params["_drone"];
|
params["_drone"];
|
||||||
|
|
||||||
private _atak_role = "a-f-A";
|
private _atak_role = "a-f-A";
|
||||||
private _atak_callsign = [_unit] call armatak_fnc_extract_unit_callsign;
|
private _atak_callsign = [_drone] call armatak_fnc_extract_marker_callsign;
|
||||||
|
|
||||||
switch (side _drone) do {
|
switch (side _drone) do {
|
||||||
case "WEST": {
|
case "WEST": {
|
||||||
@@ -25,4 +25,10 @@ switch (side _drone) do {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_pre_defined_role = _drone getVariable "_atak_group_role";
|
||||||
|
|
||||||
|
if (!isNil "_pre_defined_role") then {
|
||||||
|
_callsign = _pre_defined_role;
|
||||||
|
};
|
||||||
|
|
||||||
_cot = [_drone, _atak_role, _atak_callsign] call armatak_fnc_send_marker_cot;
|
_cot = [_drone, _atak_role, _atak_callsign] call armatak_fnc_send_marker_cot;
|
||||||
|
|||||||
15
addons/main/functions/api/fn_send_enemy_cot.sqf
Normal file
15
addons/main/functions/api/fn_send_enemy_cot.sqf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// function name: armatak_fnc_send_eud_cot
|
||||||
|
// function author: Valmo
|
||||||
|
// function description: Gets the information necessary for generating the EUD Cursor Over Time
|
||||||
|
|
||||||
|
params ["_unit"];
|
||||||
|
|
||||||
|
_unit_position = _unit call armatak_client_fnc_extractClientPosition;
|
||||||
|
|
||||||
|
_uuid = _unit call armatak_fnc_extract_uuid;
|
||||||
|
_type = _unit call armatak_fnc_extract_role;
|
||||||
|
_callsign = _unit call armatak_fnc_extract_marker_callsign;
|
||||||
|
|
||||||
|
_marker_cot = [_uuid, _type, _unit_position select 1, _unit_position select 2, _unit_position select 3, _callsign, _unit_position select 5, _unit_position select 6];
|
||||||
|
|
||||||
|
"armatak" callExtension ["tcp_socket:cot:marker", [_marker_cot]];
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// function name: armatak_fnc_extract_eud_cot_info
|
// function name: armatak_fnc_send_eud_cot
|
||||||
// function author: Valmo
|
// function author: Valmo
|
||||||
// function description: Gets the information necessary for generating the EUD Cursor Over Time
|
// function description: Gets the information necessary for generating the EUD Cursor Over Time
|
||||||
|
|
||||||
@@ -8,6 +8,5 @@ _position = _unit call armatak_client_fnc_extractClientPosition;
|
|||||||
|
|
||||||
_uuid = _unit call armatak_fnc_extract_uuid;
|
_uuid = _unit call armatak_fnc_extract_uuid;
|
||||||
|
|
||||||
_eud_cot = [_uuid, _position select 0, _position select 1, _position select 2, _callsign, _group_name, _group_role, _position select 3, speed player / 3.6];
|
_eud_cot = [_uuid, _position select 1, _position select 2, _position select 3, _callsign, _group_name, _group_role, _position select 5, _position select 6];
|
||||||
|
"armatak" callExtension ["tcp_socket:cot:eud", [_eud_cot]];
|
||||||
"armatak" callExtension ["tcp_socket:send_eud_cot", [_eud_cot]];
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
params ["_unit", "_type", "_callsign"];
|
params ["_unit", "_type", "_callsign"];
|
||||||
|
|
||||||
_unit_position = _unit call armatak_client_fnc_extractClientPosition;
|
_unit_position = _unit call armatak_client_fnc_extractClientPosition;
|
||||||
|
|
||||||
_uuid = _unit call armatak_fnc_extract_uuid;
|
_uuid = _unit call armatak_fnc_extract_uuid;
|
||||||
|
|
||||||
_marker_cot = [_uuid, _type, _unit_position select 0, _unit_position select 1, _unit_position select 2, _callsign, _unit_position select 3, speed _unit / 3.6];
|
_marker_cot = [_uuid, _type, _unit_position select 1, _unit_position select 2, _unit_position select 3, _callsign, _unit_position select 5, _unit_position select 6];
|
||||||
|
|
||||||
"armatak" callExtension ["tcp_socket:send_marker_cot", [_marker_cot]];
|
"armatak" callExtension ["tcp_socket:cot:marker", [_marker_cot]];
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
params["_unit"];
|
params["_unit"];
|
||||||
|
|
||||||
|
_group = group _unit;
|
||||||
_group_roles = ["Team Member", "Team Lead", "HQ", "Sniper", "Medic", "Forward Observer", "RTO", "K9"];
|
_group_roles = ["Team Member", "Team Lead", "HQ", "Sniper", "Medic", "Forward Observer", "RTO", "K9"];
|
||||||
_group_role = "Team Member";
|
_group_role = "Team Member";
|
||||||
|
|
||||||
if (["SpecialOperative", (configFile >> "CfgVehicles" >> typeOf _unit >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) then {
|
if (["SpecialOperative", (configOf _unit >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) then {
|
||||||
_group_role = _group_roles select 5;
|
_group_role = _group_roles select 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ if (((backpack _unit) isKindOf "TFAR_Bag_Base") or (["radio", typeOf _unit, fals
|
|||||||
_group_role = _group_roles select 6;
|
_group_role = _group_roles select 6;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((["sniper", typeOf _unit, false] call BIS_fnc_inString) or (["marksman", (configFile >> "CfgVehicles" >> typeOf _unit >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) or (["sharpshooter", typeOf _unit, false] call BIS_fnc_inString)) then {
|
if ((["sniper", typeOf _unit, false] call BIS_fnc_inString) or (["marksman", (configOf _unit >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) or (["sharpshooter", typeOf _unit, false] call BIS_fnc_inString)) then {
|
||||||
_group_role = _group_roles select 3;
|
_group_role = _group_roles select 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ if (["officer", typeOf _unit, false] call BIS_fnc_inString) then {
|
|||||||
_pre_defined_role = _unit getVariable "_atak_group_role";
|
_pre_defined_role = _unit getVariable "_atak_group_role";
|
||||||
|
|
||||||
if (!isNil "_pre_defined_role") then {
|
if (!isNil "_pre_defined_role") then {
|
||||||
_callsign = _pre_defined_callsign;
|
_callsign = _pre_defined_role;
|
||||||
};
|
};
|
||||||
|
|
||||||
_group_role
|
_group_role
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ params["_unit"];
|
|||||||
private _callsign = "";
|
private _callsign = "";
|
||||||
|
|
||||||
if ((([_unit] call BIS_fnc_objectType) select 0) == "Vehicle") then {
|
if ((([_unit] call BIS_fnc_objectType) select 0) == "Vehicle") then {
|
||||||
_callsign = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayName");
|
_callsign = getText (configOf _unit >> "displayName");
|
||||||
|
|
||||||
if (!isNull driver _unit) then {
|
if (!isNull driver _unit) then {
|
||||||
_callsign = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayName") + " | " + ([name (driver _unit)] call armatak_fnc_shorten_name);
|
_callsign = getText (configOf _unit >> "displayName") + " | " + ([name (driver _unit)] call armatak_fnc_shorten_name);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (unitIsUAV _unit) then {
|
if (unitIsUAV _unit) then {
|
||||||
_callsign = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayName");
|
_callsign = getText (configOf _unit >> "displayName");
|
||||||
|
|
||||||
if (isUAVConnected _unit) then {
|
if (isUAVConnected _unit) then {
|
||||||
_callsign = (_callsign) + "[ON]";
|
_callsign = (_callsign) + "[ON]";
|
||||||
|
|||||||
@@ -7,8 +7,15 @@ params["_unit"];
|
|||||||
private _affiliation = "f";
|
private _affiliation = "f";
|
||||||
private _type = "G";
|
private _type = "G";
|
||||||
private _role = "a-f-G-U-C-I";
|
private _role = "a-f-G-U-C-I";
|
||||||
|
private _side = side _unit;
|
||||||
switch (str side _unit) do {
|
|
||||||
|
if (isNil {
|
||||||
|
_unit getVariable "armatak_current_side"
|
||||||
|
}) then {
|
||||||
|
_side = _unit getVariable "armatak_current_side";
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (str _side) do {
|
||||||
case "WEST": {
|
case "WEST": {
|
||||||
_affiliation = "f";
|
_affiliation = "f";
|
||||||
};
|
};
|
||||||
@@ -22,7 +29,7 @@ switch (str side _unit) do {
|
|||||||
_affiliation = "u";
|
_affiliation = "u";
|
||||||
};
|
};
|
||||||
default {
|
default {
|
||||||
_affiliation = "f";
|
_affiliation = "u";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,7 +117,6 @@ if ((typeOf (vehicle _unit) != typeOf _unit) or ((_unit_type select 0) == "Vehic
|
|||||||
|
|
||||||
_role = "a-" + _affiliation + "-" + _type;
|
_role = "a-" + _affiliation + "-" + _type;
|
||||||
|
|
||||||
|
|
||||||
armatak_attribute_marker_type = _unit getVariable "armatak_attribute_marker_type";
|
armatak_attribute_marker_type = _unit getVariable "armatak_attribute_marker_type";
|
||||||
|
|
||||||
if (!isNil "armatak_attribute_marker_type" or armatak_attribute_marker_type != '') then {
|
if (!isNil "armatak_attribute_marker_type" or armatak_attribute_marker_type != '') then {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
params["_unit"];
|
||||||
|
|
||||||
|
_target = getSensorTargets (_unit);
|
||||||
|
|
||||||
|
{
|
||||||
|
_unit = _x select 0;
|
||||||
|
_position = _x select 1;
|
||||||
|
_status = _x select 2;
|
||||||
|
|
||||||
|
if (isNil {
|
||||||
|
_unit getVariable "armatak_current_side"
|
||||||
|
}) then {
|
||||||
|
_unit setVariable ["armatak_current_side", side _unit];
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_status != "destroyed" && !(_unit in armatak_server_syncedUnits)) then {
|
||||||
|
_unit_position = _unit call armatak_client_fnc_extractClientPosition;
|
||||||
|
|
||||||
|
_uuid = _unit call armatak_fnc_extract_uuid;
|
||||||
|
_type = _unit call armatak_fnc_extract_role;
|
||||||
|
_callsign = getText (configOf _unit >> "displayName");
|
||||||
|
|
||||||
|
_marker_cot = [_uuid, _type, _unit_position select 1, _unit_position select 2, _unit_position select 3, _callsign, _unit_position select 5, _unit_position select 6];
|
||||||
|
|
||||||
|
"armatak" callExtension ["tcp_socket:cot:marker", [_marker_cot]];
|
||||||
|
};
|
||||||
|
} forEach _target;
|
||||||
@@ -12,10 +12,14 @@ if (roleDescription _unit != "") then {
|
|||||||
_callsign = name _unit;
|
_callsign = name _unit;
|
||||||
|
|
||||||
if (_callsign == "Error: No unit") then {
|
if (_callsign == "Error: No unit") then {
|
||||||
_callsign = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayName");
|
_callsign = getText (configOf _unit >> "displayName");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (side _unit == east) then {
|
||||||
|
_callsign = getText (configOf _unit >> "displayName");
|
||||||
|
};
|
||||||
|
|
||||||
armatak_attribute_unit_callsign = _unit getVariable "armatak_attribute_unit_callsign";
|
armatak_attribute_unit_callsign = _unit getVariable "armatak_attribute_unit_callsign";
|
||||||
|
|
||||||
if (!isNil "armatak_attribute_unit_callsign" or armatak_attribute_unit_callsign != '') then {
|
if (!isNil "armatak_attribute_unit_callsign" or armatak_attribute_unit_callsign != '') then {
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
params[_type, _message];
|
params["_type", "_message"];
|
||||||
|
|
||||||
"armatak" callExtension ["log", [_type, _message]]
|
"armatak" callExtension ["log", [_type, _message]]
|
||||||
|
|||||||
23
addons/main/functions/map/fn_convert_to_clafghan.sqf
Normal file
23
addons/main/functions/map/fn_convert_to_clafghan.sqf
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
params["_latitude", "_longitude", "_altitude"];
|
||||||
|
|
||||||
|
_playerPosition = [_latitude, _longitude, _altitude];
|
||||||
|
|
||||||
|
_playerLatitude = _playerPosition select 0;
|
||||||
|
_playerLongitude = _playerPosition select 1;
|
||||||
|
|
||||||
|
_playerMaxLatitude = 20480;
|
||||||
|
_playerMaxLongitude = 20480;
|
||||||
|
|
||||||
|
_MapMaxLongitude = 33.728772;
|
||||||
|
_MapMinLongitude = 33.542815;
|
||||||
|
|
||||||
|
_MapMaxLatitude = 63.169746;
|
||||||
|
_MapMinLatitude = 62.938820;
|
||||||
|
|
||||||
|
_LongitudeDifference = _MapMaxLongitude - _MapMinLongitude;
|
||||||
|
_LatitudeDifference = _MapMaxLatitude - _MapMinLatitude;
|
||||||
|
|
||||||
|
_RealLongitude = (_playerLongitude / _playerMaxLongitude) * _LongitudeDifference + _MapMinLongitude;
|
||||||
|
_RealLatitude = (_playerLatitude / _playerMaxLatitude) * _LatitudeDifference + _MapMinLatitude;
|
||||||
|
|
||||||
|
[_RealLongitude, _RealLatitude, _playerPosition select 2]
|
||||||
23
addons/main/functions/map/fn_convert_to_colombia.sqf
Normal file
23
addons/main/functions/map/fn_convert_to_colombia.sqf
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
params["_latitude", "_longitude", "_altitude"];
|
||||||
|
|
||||||
|
_playerPosition = [_latitude, _longitude, _altitude];
|
||||||
|
|
||||||
|
_playerLatitude = _playerPosition select 0;
|
||||||
|
_playerLongitude = _playerPosition select 1;
|
||||||
|
|
||||||
|
_playerMaxLatitude = 20480;
|
||||||
|
_playerMaxLongitude = 20480;
|
||||||
|
|
||||||
|
_MapMaxLatitude = -67.765153;
|
||||||
|
_MapMinLatitude = -68.223664;
|
||||||
|
|
||||||
|
_MapMaxLongitude = 10.593815;
|
||||||
|
_MapMinLongitude = 10.137466;
|
||||||
|
|
||||||
|
_LongitudeDifference = _MapMaxLongitude - _MapMinLongitude;
|
||||||
|
_LatitudeDifference = _MapMaxLatitude - _MapMinLatitude;
|
||||||
|
|
||||||
|
_RealLongitude = (_playerLongitude / _playerMaxLongitude) * _LongitudeDifference + _MapMinLongitude;
|
||||||
|
_RealLatitude = (_playerLatitude / _playerMaxLatitude) * _LatitudeDifference + _MapMinLatitude;
|
||||||
|
|
||||||
|
[_RealLongitude, _RealLatitude, _playerPosition select 2]
|
||||||
23
addons/main/functions/map/fn_convert_to_lawn.sqf
Normal file
23
addons/main/functions/map/fn_convert_to_lawn.sqf
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
params["_latitude", "_longitude", "_altitude"];
|
||||||
|
|
||||||
|
_playerPosition = [_latitude, _longitude, _altitude];
|
||||||
|
|
||||||
|
_playerLatitude = _playerPosition select 0;
|
||||||
|
_playerLongitude = _playerPosition select 1;
|
||||||
|
|
||||||
|
_playerMaxLongitude = 4992;
|
||||||
|
_playerMaxLatitude = 4992;
|
||||||
|
|
||||||
|
_MapMaxLongitude = -99.722665;
|
||||||
|
_MapMinLongitude = -99.775505;
|
||||||
|
|
||||||
|
_MapMaxLatitude = 32.159272;
|
||||||
|
_MapMinLatitude = 32.114011;
|
||||||
|
|
||||||
|
_LongitudeDifference = _MapMaxLongitude - _MapMinLongitude;
|
||||||
|
_LatitudeDifference = _MapMaxLatitude - _MapMinLatitude;
|
||||||
|
|
||||||
|
_RealLongitude = (_playerLongitude / _playerMaxLongitude) * _LongitudeDifference + _MapMinLongitude;
|
||||||
|
_RealLatitude = (_playerLatitude / _playerMaxLatitude) * _LatitudeDifference + _MapMinLatitude;
|
||||||
|
|
||||||
|
[_RealLongitude, _RealLatitude, _playerPosition select 2]
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
params ["_longitudeInGame", "_latitudeInGame", "_altitude"];
|
||||||
|
|
||||||
|
private _mapWidth = 11264;
|
||||||
|
private _mapHeight = 11264;
|
||||||
|
|
||||||
|
// SW corner (used as origin)
|
||||||
|
private _SW_lat = -51.736078;
|
||||||
|
private _SW_lon = -57.915032;
|
||||||
|
|
||||||
|
// SE corner
|
||||||
|
private _SE_lat = -51.736078;
|
||||||
|
private _SE_lon = -58.077879;
|
||||||
|
|
||||||
|
// NW corner
|
||||||
|
private _NW_lat = -51.634750;
|
||||||
|
private _NW_lon = -58.077879;
|
||||||
|
|
||||||
|
private _edgeSE_lat = _SE_lat - _SW_lat;
|
||||||
|
private _edgeSE_lon = _SE_lon - _SW_lon;
|
||||||
|
|
||||||
|
private _edgeNW_lat = _NW_lat - _SW_lat;
|
||||||
|
private _edgeNW_lon = _NW_lon - _SW_lon;
|
||||||
|
|
||||||
|
private _fx = _longitudeInGame / _mapWidth;
|
||||||
|
private _fy = _latitudeInGame / _mapHeight;
|
||||||
|
|
||||||
|
private _realLat = _SW_lat + (_fx * _edgeSE_lat) + (_fy * _edgeNW_lat);
|
||||||
|
private _realLon = _SW_lon + (_fx * _edgeSE_lon) + (_fy * _edgeNW_lon);
|
||||||
|
|
||||||
|
[_realLat, _realLon, _altitude]
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
params ["_longitudeInGame", "_latitudeInGame", "_altitude"];
|
||||||
|
|
||||||
|
private _mapWidth = 16384;
|
||||||
|
private _mapHeight = 16384;
|
||||||
|
|
||||||
|
// SW corner (used as origin)
|
||||||
|
private _SW_lat = -51.806546;
|
||||||
|
private _SW_lon = -57.939747;
|
||||||
|
|
||||||
|
// SE corner
|
||||||
|
private _SE_lat = -51.806546;
|
||||||
|
private _SE_lon = -57.701978;
|
||||||
|
|
||||||
|
// NW corner
|
||||||
|
private _NW_lat = -51.658913;
|
||||||
|
private _NW_lon = -57.939747;
|
||||||
|
|
||||||
|
private _edgeSE_lat = _SE_lat - _SW_lat;
|
||||||
|
private _edgeSE_lon = _SE_lon - _SW_lon;
|
||||||
|
|
||||||
|
private _edgeNW_lat = _NW_lat - _SW_lat;
|
||||||
|
private _edgeNW_lon = _NW_lon - _SW_lon;
|
||||||
|
|
||||||
|
private _fx = _longitudeInGame / _mapWidth;
|
||||||
|
private _fy = _latitudeInGame / _mapHeight;
|
||||||
|
|
||||||
|
private _realLat = _SW_lat + (_fx * _edgeSE_lat) + (_fy * _edgeNW_lat);
|
||||||
|
private _realLon = _SW_lon + (_fx * _edgeSE_lon) + (_fy * _edgeNW_lon);
|
||||||
|
|
||||||
|
[_realLat, _realLon, _altitude]
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
params ["_longitudeInGame", "_latitudeInGame", "_altitude"];
|
||||||
|
|
||||||
|
private _mapWidth = 10240;
|
||||||
|
private _mapHeight = 10240;
|
||||||
|
|
||||||
|
// SW corner (used as origin)
|
||||||
|
private _SW_lat = -51.863358;
|
||||||
|
private _SW_lon = -59.054585;
|
||||||
|
|
||||||
|
// SE corner
|
||||||
|
private _SE_lat = -51.863358;
|
||||||
|
private _SE_lon = -58.906155;
|
||||||
|
|
||||||
|
// NW corner
|
||||||
|
private _NW_lat = -51.771493;
|
||||||
|
private _NW_lon = -59.054585;
|
||||||
|
|
||||||
|
private _edgeSE_lat = _SE_lat - _SW_lat;
|
||||||
|
private _edgeSE_lon = _SE_lon - _SW_lon;
|
||||||
|
|
||||||
|
private _edgeNW_lat = _NW_lat - _SW_lat;
|
||||||
|
private _edgeNW_lon = _NW_lon - _SW_lon;
|
||||||
|
|
||||||
|
private _fx = _longitudeInGame / _mapWidth;
|
||||||
|
private _fy = _latitudeInGame / _mapHeight;
|
||||||
|
|
||||||
|
private _realLat = _SW_lat + (_fx * _edgeSE_lat) + (_fy * _edgeNW_lat);
|
||||||
|
private _realLon = _SW_lon + (_fx * _edgeSE_lon) + (_fy * _edgeNW_lon);
|
||||||
|
|
||||||
|
[_realLat, _realLon, _altitude]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
params["_latitude", "_longitude", "_altitude"];
|
||||||
|
|
||||||
|
_playerPosition = [_latitude, _longitude, _altitude];
|
||||||
|
|
||||||
|
_playerLatitude = _playerPosition select 0;
|
||||||
|
_playerLongitude = _playerPosition select 1;
|
||||||
|
|
||||||
|
_playerMaxLongitude = 5120;
|
||||||
|
_playerMaxLatitude = 5120;
|
||||||
|
|
||||||
|
_MapMaxLatitude = -51.619725;
|
||||||
|
_MapMinLatitude = -51.664223;
|
||||||
|
|
||||||
|
_MapMaxLongitude = -58.394630;
|
||||||
|
_MapMinLongitude = -58.469580;
|
||||||
|
|
||||||
|
_LongitudeDifference = _MapMaxLongitude - _MapMinLongitude;
|
||||||
|
_LatitudeDifference = _MapMaxLatitude - _MapMinLatitude;
|
||||||
|
|
||||||
|
_RealLongitude = (_playerLongitude / _playerMaxLongitude) * _LongitudeDifference + _MapMinLongitude;
|
||||||
|
_RealLatitude = (_playerLatitude / _playerMaxLatitude) * _LatitudeDifference + _MapMinLatitude;
|
||||||
|
|
||||||
|
[_RealLongitude, _RealLatitude, _playerPosition select 2]
|
||||||
23
addons/main/functions/map/fn_convert_to_rut_mandol.sqf
Normal file
23
addons/main/functions/map/fn_convert_to_rut_mandol.sqf
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
params["_latitude", "_longitude", "_altitude"];
|
||||||
|
|
||||||
|
_playerPosition = [_latitude, _longitude, _altitude];
|
||||||
|
|
||||||
|
_playerLatitude = _playerPosition select 0;
|
||||||
|
_playerLongitude = _playerPosition select 1;
|
||||||
|
|
||||||
|
_playerMaxLatitude = 32768;
|
||||||
|
_playerMaxLongitude = 32768;
|
||||||
|
|
||||||
|
_MapMaxLongitude = 35.285485;
|
||||||
|
_MapMinLongitude = 34.927617;
|
||||||
|
|
||||||
|
_MapMaxLatitude = 70.445404;
|
||||||
|
_MapMinLatitude = 70.016783;
|
||||||
|
|
||||||
|
_LongitudeDifference = _MapMaxLongitude - _MapMinLongitude;
|
||||||
|
_LatitudeDifference = _MapMaxLatitude - _MapMinLatitude;
|
||||||
|
|
||||||
|
_RealLongitude = (_playerLongitude / _playerMaxLongitude) * _LongitudeDifference + _MapMinLongitude;
|
||||||
|
_RealLatitude = (_playerLatitude / _playerMaxLatitude) * _LatitudeDifference + _MapMinLatitude;
|
||||||
|
|
||||||
|
[_RealLongitude, _RealLatitude, _playerPosition select 2]
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
params ["_longitudeInGame", "_latitudeInGame", "_altitude"];
|
params ["_longitudeInGame", "_latitudeInGame", "_altitude"];
|
||||||
|
|
||||||
private _mapWidth = 30720;
|
private _mapWidth = 8192;
|
||||||
private _mapHeight = 30720;
|
private _mapHeight = 8192;
|
||||||
|
|
||||||
// SW corner (used as origin)
|
// SW corner (used as origin)
|
||||||
private _SW_lat = 39.456910;
|
private _SW_lat = 39.458019;
|
||||||
private _SW_lon = 24.940792;
|
private _SW_lon = 24.939314;
|
||||||
|
|
||||||
// SE corner
|
// SE corner
|
||||||
private _SE_lat = 39.459151;
|
private _SE_lat = 39.458019;
|
||||||
private _SE_lon = 25.083440;
|
private _SE_lon = 25.081992;
|
||||||
|
|
||||||
// NW corner
|
// NW corner
|
||||||
private _NW_lat = 39.567714;
|
private _NW_lat = 39.568847;
|
||||||
private _NW_lon = 24.937866;
|
private _NW_lon = 24.939314;
|
||||||
|
|
||||||
private _edgeSE_lat = _SE_lat - _SW_lat;
|
private _edgeSE_lat = _SE_lat - _SW_lat;
|
||||||
private _edgeSE_lon = _SE_lon - _SW_lon;
|
private _edgeSE_lon = _SE_lon - _SW_lon;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
params ["_longitudeInGame", "_latitudeInGame", "_altitude"];
|
params ["_longitudeInGame", "_latitudeInGame", "_altitude"];
|
||||||
|
|
||||||
private _mapWidth = 30720;
|
private _mapWidth = 15360;
|
||||||
private _mapHeight = 30720;
|
private _mapHeight = 15360;
|
||||||
|
|
||||||
// SW corner (used as origin)
|
// SW corner (used as origin)
|
||||||
private _SW_lat = -19.086825;
|
private _SW_lat = -19.086803;
|
||||||
private _SW_lon = 176.812772;
|
private _SW_lon = 176.812619;
|
||||||
|
|
||||||
// SE corner
|
// SE corner
|
||||||
private _SE_lat = -19.086825;
|
private _SE_lat = -19.086803;
|
||||||
private _SE_lon = 178.687920;
|
private _SE_lon = 178.704583;
|
||||||
|
|
||||||
// NW corner
|
// NW corner
|
||||||
private _NW_lat = -17.196898;
|
private _NW_lat = -17.196900;
|
||||||
private _NW_lon = 176.812622;
|
private _NW_lon = 176.812619;
|
||||||
|
|
||||||
private _edgeSE_lat = _SE_lat - _SW_lat;
|
private _edgeSE_lat = _SE_lat - _SW_lat;
|
||||||
private _edgeSE_lon = _SE_lon - _SW_lon;
|
private _edgeSE_lon = _SE_lon - _SW_lon;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
params["_latitude", "_longitude", "_altitude"];
|
||||||
|
|
||||||
|
_playerPosition = [_latitude, _longitude, _altitude];
|
||||||
|
|
||||||
|
_playerLatitude = _playerPosition select 0;
|
||||||
|
_playerLongitude = _playerPosition select 1;
|
||||||
|
|
||||||
|
_playerMaxLongitude = 20480;
|
||||||
|
_playerMaxLatitude = 20480;
|
||||||
|
|
||||||
|
_MapMaxLongitude = 48.351216;
|
||||||
|
_MapMinLongitude = 48.097496;
|
||||||
|
|
||||||
|
_MapMaxLatitude = 38.345389;
|
||||||
|
_MapMinLatitude = 37.956754;
|
||||||
|
|
||||||
|
_LongitudeDifference = _MapMaxLongitude - _MapMinLongitude;
|
||||||
|
_LatitudeDifference = _MapMaxLatitude - _MapMinLatitude;
|
||||||
|
|
||||||
|
_RealLongitude = (_playerLongitude / _playerMaxLongitude) * _LongitudeDifference + _MapMinLongitude;
|
||||||
|
_RealLatitude = (_playerLatitude / _playerMaxLatitude) * _LatitudeDifference + _MapMinLatitude;
|
||||||
|
|
||||||
|
[_RealLongitude, _RealLatitude, _playerPosition select 2]
|
||||||
@@ -1,42 +1,28 @@
|
|||||||
class CfgVehicles {
|
class CfgVehicles {
|
||||||
class Logic;
|
class Logic;
|
||||||
class Module_F : Logic
|
class Module_F : Logic {
|
||||||
{
|
class AttributesBase {
|
||||||
class AttributesBase
|
|
||||||
{
|
|
||||||
class Default;
|
|
||||||
class Edit;
|
class Edit;
|
||||||
class Combo;
|
|
||||||
class Checkbox;
|
|
||||||
class CheckboxNumber;
|
|
||||||
class ModuleDescription;
|
class ModuleDescription;
|
||||||
class Units;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ModuleDescription
|
|
||||||
{
|
|
||||||
class AnyBrain;
|
|
||||||
};
|
};
|
||||||
|
class ModuleDescription;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GVAR(moduleBase): Module_F {
|
class GVAR(moduleBase): Module_F {
|
||||||
author = PROJECT_AUTHOR;
|
author = PROJECT_AUTHOR;
|
||||||
category = QEGVAR(main,moduleCategory);
|
category = QEGVAR(main,moduleCategory);
|
||||||
function = QUOTE({});
|
function = QUOTE({});
|
||||||
functionPriority = 1;
|
functionPriority = 1;
|
||||||
isGlobal = 1;
|
isGlobal = 1;
|
||||||
isTriggerActivated = 0;
|
isTriggerActivated = 0;
|
||||||
scope = 1;
|
scope = 1;
|
||||||
scopeCurator = 2;
|
scopeCurator = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GVAR(coreModule): GVAR(moduleBase) {
|
class GVAR(connectionModuleBase): GVAR(moduleBase) {
|
||||||
scope = 2;
|
|
||||||
scopeCurator = 0;
|
scopeCurator = 0;
|
||||||
displayname = "CoT Router";
|
|
||||||
icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa";
|
icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa";
|
||||||
category = QEGVAR(main,moduleCategory);
|
category = QEGVAR(main,moduleCategory);
|
||||||
function = QFUNC(3denCoreModuleConfig);
|
|
||||||
functionPriority = 1;
|
functionPriority = 1;
|
||||||
isGlobal = 0;
|
isGlobal = 0;
|
||||||
isTriggerActivated = 1;
|
isTriggerActivated = 1;
|
||||||
@@ -47,19 +33,25 @@ class CfgVehicles {
|
|||||||
canSetArea = 0;
|
canSetArea = 0;
|
||||||
canSetAreaShape = 0;
|
canSetAreaShape = 0;
|
||||||
canSetAreaHeight = 0;
|
canSetAreaHeight = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GVAR(tcpModule): GVAR(connectionModuleBase) {
|
||||||
|
scope = 2;
|
||||||
|
displayName = "CoT Router (TCP)";
|
||||||
|
function = QFUNC(3denTcpModuleConfig);
|
||||||
|
|
||||||
class Attributes: AttributesBase {
|
class Attributes: AttributesBase {
|
||||||
class GVAR(moduleInstanceAddress): Edit {
|
class GVAR(moduleInstanceAddress): Edit {
|
||||||
property = QGVAR(moduleInstanceAddress);
|
property = QGVAR(moduleInstanceAddress);
|
||||||
displayname = "TAK Server Address";
|
displayName = "TAK Server Address";
|
||||||
tooltip = "TAK Server Instance Address";
|
tooltip = "Hostname or IP address for the TAK or IronTAK server.";
|
||||||
typeName = "STRING";
|
typeName = "STRING";
|
||||||
defaultValue = "localhost";
|
defaultValue = "'localhost'";
|
||||||
};
|
};
|
||||||
class GVAR(moduleInstancePort): Edit {
|
class GVAR(moduleInstancePort): Edit {
|
||||||
property = QGVAR(moduleInstancePort);
|
property = QGVAR(moduleInstancePort);
|
||||||
displayname = "TAK Server TCP Port";
|
displayName = "TAK Server TCP Port";
|
||||||
tooltip = "TAK Server instance Port for TCP connection";
|
tooltip = "Port for the unauthenticated TCP socket.";
|
||||||
typeName = "NUMBER";
|
typeName = "NUMBER";
|
||||||
defaultValue = "8088";
|
defaultValue = "8088";
|
||||||
};
|
};
|
||||||
@@ -67,24 +59,75 @@ class CfgVehicles {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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"};
|
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;
|
scope = 1;
|
||||||
scopeCurator = 2;
|
scopeCurator = 2;
|
||||||
function = "";
|
function = "";
|
||||||
displayName = "CoT Router (Zeus)";
|
displayName = "CoT Router (TCP, Zeus)";
|
||||||
curatorInfoType = "armatak_zeus_core_module_dialog";
|
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) {
|
class GVAR(markEntity): GVAR(moduleBase) {
|
||||||
curatorCanAttach = 1;
|
curatorCanAttach = 1;
|
||||||
category = QEGVAR(main,moduleCategory);
|
category = QEGVAR(main,moduleCategory);
|
||||||
displayname = "Mark Entity";
|
displayname = "Mark Entity";
|
||||||
function = QFUNC(routerEntityAdd);
|
function = QFUNC(routerEntityAdd);
|
||||||
icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa";
|
icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
PREP(3denCoreModuleConfig);
|
PREP(3denEnrollModuleConfig);
|
||||||
|
PREP(3denTcpModuleConfig);
|
||||||
PREP(routerEntityAdd);
|
PREP(routerEntityAdd);
|
||||||
PREP(routerEntityRemove);
|
PREP(routerEntityRemove);
|
||||||
PREP(ZeusCoreModuleConfig);
|
PREP(startCotRouter);
|
||||||
|
PREP(ZeusEnrollModuleConfig);
|
||||||
|
PREP(ZeusTcpModuleConfig);
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ class CfgPatches {
|
|||||||
class ADDON {
|
class ADDON {
|
||||||
name = COMPONENT_NAME;
|
name = COMPONENT_NAME;
|
||||||
units[] = {
|
units[] = {
|
||||||
QGVAR(coreModule),
|
QGVAR(tcpModule),
|
||||||
QGVAR(coreModuleCurator),
|
QGVAR(tcpModuleCurator),
|
||||||
|
QGVAR(enrollModule),
|
||||||
|
QGVAR(enrollModuleCurator),
|
||||||
QGVAR(markEntity)
|
QGVAR(markEntity)
|
||||||
};
|
};
|
||||||
weapons[] = {};
|
weapons[] = {};
|
||||||
|
|||||||
@@ -3,69 +3,172 @@ class RscBackground;
|
|||||||
class RscButton;
|
class RscButton;
|
||||||
class RscEdit;
|
class RscEdit;
|
||||||
|
|
||||||
class armatak_zeus_core_module_dialog {
|
class armatak_zeus_tcp_module_dialog {
|
||||||
idd = 999991;
|
idd = 999991;
|
||||||
movingEnable = 0;
|
movingEnable = 0;
|
||||||
class ControlsBackground {
|
class ControlsBackground {
|
||||||
class armatak_gui_module_zeus_core_dialog_main_frame: RscBackground {
|
class main_frame: RscBackground {
|
||||||
idc = 1800;
|
idc = 1800;
|
||||||
x = "0.386562 * safezoneW + safezoneX";
|
x = "0.386562 * safezoneW + safezoneX";
|
||||||
y = "0.401 * safezoneH + safezoneY";
|
y = "0.29 * safezoneH + safezoneY";
|
||||||
w = "0.216563 * safezoneW";
|
w = "0.216563 * safezoneW";
|
||||||
h = "0.242 * safezoneH";
|
h = "0.32 * safezoneH";
|
||||||
colorBackground[]={0,0,0,0.45};
|
colorBackground[] = {0,0,0,0.45};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
class Controls {
|
class Controls {
|
||||||
class armatak_gui_module_zeus_core_dialog_address_edit: RscEdit {
|
class address_text: RscText {
|
||||||
idc = 14000;
|
|
||||||
text = "localhost";
|
|
||||||
x = "0.391719 * safezoneW + safezoneX";
|
|
||||||
y = "0.445 * 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.522 * safezoneH + safezoneY";
|
|
||||||
w = "0.20625 * safezoneW";
|
|
||||||
h = "0.044 * safezoneH";
|
|
||||||
colorBackground[]={0,0,0,0.5};
|
|
||||||
};
|
|
||||||
class armatak_gui_module_zeus_core_dialog_address_text: RscText {
|
|
||||||
idc = 1000;
|
idc = 1000;
|
||||||
text = "TAK Server Address";
|
text = "TAK Server Address";
|
||||||
x = "0.391719 * safezoneW + safezoneX";
|
x = "0.391719 * safezoneW + safezoneX";
|
||||||
y = "0.412 * safezoneH + safezoneY";
|
y = "0.332 * safezoneH + safezoneY";
|
||||||
w = "0.20625 * safezoneW";
|
w = "0.20625 * safezoneW";
|
||||||
h = "0.033 * safezoneH";
|
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;
|
idc = 1001;
|
||||||
text = "TAK Server Port";
|
text = "TAK Server Port";
|
||||||
x = "0.391719 * safezoneW + safezoneX";
|
x = "0.391719 * safezoneW + safezoneX";
|
||||||
y = "0.489 * safezoneH + safezoneY";
|
y = "0.425 * safezoneH + safezoneY";
|
||||||
w = "0.20625 * safezoneW";
|
w = "0.20625 * safezoneW";
|
||||||
h = "0.033 * safezoneH";
|
h = "0.033 * safezoneH";
|
||||||
};
|
};
|
||||||
class armatak_gui_module_zeus_core_dialog_address_button_cancel: RscButton {
|
class port_edit: RscEdit {
|
||||||
|
idc = 14001;
|
||||||
|
text = "8088";
|
||||||
|
x = "0.391719 * safezoneW + safezoneX";
|
||||||
|
y = "0.458 * safezoneH + safezoneY";
|
||||||
|
w = "0.20625 * safezoneW";
|
||||||
|
h = "0.044 * safezoneH";
|
||||||
|
colorBackground[] = {0,0,0,0.5};
|
||||||
|
};
|
||||||
|
class button_cancel: RscButton {
|
||||||
idc = 1601;
|
idc = 1601;
|
||||||
text = "Cancel";
|
text = "Cancel";
|
||||||
action = "closeDialog 2;";
|
action = "closeDialog 2;";
|
||||||
x = "0.551563 * safezoneW + safezoneX";
|
x = "0.551563 * safezoneW + safezoneX";
|
||||||
y = "0.577 * safezoneH + safezoneY";
|
y = "0.535 * safezoneH + safezoneY";
|
||||||
w = "0.0464063 * safezoneW";
|
w = "0.0464063 * safezoneW";
|
||||||
h = "0.055 * safezoneH";
|
h = "0.055 * safezoneH";
|
||||||
};
|
};
|
||||||
class armatak_gui_module_zeus_core_dialog_address_button_ok: RscButton {
|
class button_ok: RscButton {
|
||||||
idc = 1600;
|
idc = 1600;
|
||||||
text = "Ok";
|
text = "Ok";
|
||||||
action = QUOTE(call FUNC(zeusCoreModuleConfig));
|
action = QUOTE(call FUNC(ZeusTcpModuleConfig));
|
||||||
x = "0.5 * safezoneW + safezoneX";
|
x = "0.5 * safezoneW + safezoneX";
|
||||||
y = "0.577 * 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";
|
w = "0.0464063 * safezoneW";
|
||||||
h = "0.055 * safezoneH";
|
h = "0.055 * safezoneH";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,57 +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);
|
|
||||||
|
|
||||||
_tak_server_instance_address = _logic getVariable QGVAR(moduleInstanceAddress);
|
|
||||||
_tak_server_instance_port = _logic getVariable QGVAR(moduleInstancePort);
|
|
||||||
|
|
||||||
_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];
|
|
||||||
|
|
||||||
"armatak" callExtension ["tcp_socket:start", [_tak_server_fulladdress]];
|
|
||||||
|
|
||||||
_syncUnits = synchronizedObjects _logic;
|
|
||||||
|
|
||||||
missionNamespace setVariable ["armatak_marked_units", _syncUnits];
|
|
||||||
|
|
||||||
GVAR(syncedUnits) = missionNamespace getVariable "armatak_marked_units";
|
|
||||||
|
|
||||||
[{
|
|
||||||
GVAR(syncedUnits) = missionNamespace getVariable "armatak_marked_units";
|
|
||||||
|
|
||||||
{
|
|
||||||
_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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
if (unitIsUAV _x) then {
|
|
||||||
[_x] call armatak_fnc_send_drone_cot;
|
|
||||||
[_x] call armatak_fnc_send_digital_pointer_cot;
|
|
||||||
};
|
|
||||||
} forEach GVAR(syncedUnits);
|
|
||||||
}, 2, []] call CBA_fnc_addPerFrameHandler;
|
|
||||||
};
|
|
||||||
|
|
||||||
true;
|
|
||||||
37
addons/server/functions/fnc_3denEnrollModuleConfig.sqf
Normal file
37
addons/server/functions/fnc_3denEnrollModuleConfig.sqf
Normal file
@@ -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
|
||||||
26
addons/server/functions/fnc_3denTcpModuleConfig.sqf
Normal file
26
addons/server/functions/fnc_3denTcpModuleConfig.sqf
Normal file
@@ -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
|
||||||
@@ -1,60 +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);
|
|
||||||
|
|
||||||
_tak_server_instance_address = ctrlText 14000;
|
|
||||||
_tak_server_instance_port = ctrlText 14001;
|
|
||||||
|
|
||||||
_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];
|
|
||||||
|
|
||||||
"armatak" callExtension ["tcp_socket:start", [_tak_server_fulladdress]];
|
|
||||||
|
|
||||||
_syncUnits = [];
|
|
||||||
|
|
||||||
missionNamespace setVariable ["armatak_marked_units", _syncUnits];
|
|
||||||
|
|
||||||
GVAR(syncedUnits) = missionNamespace getVariable "armatak_marked_units";
|
|
||||||
|
|
||||||
[{
|
|
||||||
GVAR(syncedUnits) = missionNamespace getVariable "armatak_marked_units";
|
|
||||||
|
|
||||||
{
|
|
||||||
_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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
if (unitIsUAV _x) then {
|
|
||||||
[_x] call armatak_fnc_send_drone_cot;
|
|
||||||
[_x] call armatak_fnc_send_digital_pointer_cot;
|
|
||||||
};
|
|
||||||
} forEach GVAR(syncedUnits);
|
|
||||||
}, 2, []] call CBA_fnc_addPerFrameHandler;
|
|
||||||
deleteVehicle _logic;
|
|
||||||
closeDialog 1;
|
|
||||||
33
addons/server/functions/fnc_ZeusEnrollModuleConfig.sqf
Normal file
33
addons/server/functions/fnc_ZeusEnrollModuleConfig.sqf
Normal file
@@ -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;
|
||||||
22
addons/server/functions/fnc_ZeusTcpModuleConfig.sqf
Normal file
22
addons/server/functions/fnc_ZeusTcpModuleConfig.sqf
Normal file
@@ -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;
|
||||||
@@ -27,16 +27,16 @@ switch (false) do {
|
|||||||
deleteVehicle _logic;
|
deleteVehicle _logic;
|
||||||
};
|
};
|
||||||
default {
|
default {
|
||||||
if (_unit in (missionNamespace getVariable ["armatak_marked_units", []])) exitWith {
|
if (_unit in (missionNamespace getVariable ["armatak_server_syncedUnits", []])) exitWith {
|
||||||
["Unit already marked", "warning", "TCP Socket"] call EFUNC(main,notify);
|
["Unit already marked", "warning", "TCP Socket"] call EFUNC(main,notify);
|
||||||
deleteVehicle _logic;
|
deleteVehicle _logic;
|
||||||
};
|
};
|
||||||
|
|
||||||
GVAR(syncedUnits) = missionNamespace getVariable "armatak_marked_units";
|
GVAR(syncedUnits) = missionNamespace getVariable "armatak_server_syncedUnits";
|
||||||
|
|
||||||
GVAR(syncedUnits) pushBack _unit;
|
GVAR(syncedUnits) pushBack _unit;
|
||||||
|
|
||||||
missionNamespace setVariable ["armatak_marked_units", GVAR(syncedUnits)];
|
missionNamespace setVariable ["armatak_server_syncedUnits", GVAR(syncedUnits)];
|
||||||
SETVAR(_unit,GVAR(isRouting),true);
|
SETVAR(_unit,GVAR(isRouting),true);
|
||||||
|
|
||||||
deleteVehicle _logic;
|
deleteVehicle _logic;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ switch (false) do {
|
|||||||
};
|
};
|
||||||
} forEach GVAR(syncedUnits);
|
} forEach GVAR(syncedUnits);
|
||||||
|
|
||||||
missionNmaespace setVariable ["armatak_marked_units", GVAR(syncedUnits)];
|
missionNamespace setVariable ["armatak_server_syncedUnits", GVAR(syncedUnits)];
|
||||||
SETVAR(_unit,GVAR(isRouting),false);
|
SETVAR(_unit,GVAR(isRouting),false);
|
||||||
|
|
||||||
deleteVehicle _logic;
|
deleteVehicle _logic;
|
||||||
|
|||||||
47
addons/server/functions/fnc_startCotRouter.sqf
Normal file
47
addons/server/functions/fnc_startCotRouter.sqf
Normal file
@@ -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
|
||||||
@@ -4,7 +4,7 @@ class CfgPatches {
|
|||||||
class ADDON {
|
class ADDON {
|
||||||
name = COMPONENT_NAME;
|
name = COMPONENT_NAME;
|
||||||
units[] = {
|
units[] = {
|
||||||
QGVAR(videoModule)
|
//QGVAR(videoModule)
|
||||||
};
|
};
|
||||||
weapons[] = {};
|
weapons[] = {};
|
||||||
requiredAddons[] = {
|
requiredAddons[] = {
|
||||||
|
|||||||
BIN
media/delta_larp.jpg
Normal file
BIN
media/delta_larp.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 143 KiB |
BIN
media/picture.png
LFS
Normal file
BIN
media/picture.png
LFS
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
use uuid::Uuid;
|
|
||||||
use chrono::{Duration, SecondsFormat, Utc};
|
use chrono::{Duration, SecondsFormat, Utc};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub struct CursorOverTime {
|
pub struct CursorOverTime {
|
||||||
pub uuid: Option<String>,
|
pub uuid: Option<String>,
|
||||||
|
|||||||
@@ -1,45 +1,45 @@
|
|||||||
use arma_rs::{FromArma, FromArmaError};
|
|
||||||
use super::cot::CursorOverTime;
|
use super::cot::CursorOverTime;
|
||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
|
||||||
pub struct DigitalPointerPayload {
|
pub struct DigitalPointerPayload {
|
||||||
pub link_uid: String,
|
pub link_uid: String,
|
||||||
pub contact_callsign: String,
|
pub contact_callsign: String,
|
||||||
pub point_lat: f64,
|
pub point_lat: f64,
|
||||||
pub point_lon: f64,
|
pub point_lon: f64,
|
||||||
pub point_hae: f32,
|
pub point_hae: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromArma for DigitalPointerPayload {
|
impl FromArma for DigitalPointerPayload {
|
||||||
fn from_arma(data: String) -> Result<DigitalPointerPayload, FromArmaError> {
|
fn from_arma(data: String) -> Result<DigitalPointerPayload, FromArmaError> {
|
||||||
let (link_uid, contact_callsign, point_lat, point_lon, point_hae) =
|
let (link_uid, contact_callsign, point_lat, point_lon, point_hae) =
|
||||||
<(String, String, f64, f64, f32)>::from_arma(data)?;
|
<(String, String, f64, f64, f32)>::from_arma(data)?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
link_uid,
|
link_uid,
|
||||||
contact_callsign,
|
contact_callsign,
|
||||||
point_lat,
|
point_lat,
|
||||||
point_lon,
|
point_lon,
|
||||||
point_hae,
|
point_hae,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DigitalPointerPayload {
|
impl DigitalPointerPayload {
|
||||||
pub fn to_cot(&self) -> CursorOverTime {
|
pub fn to_cot(&self) -> CursorOverTime {
|
||||||
CursorOverTime {
|
CursorOverTime {
|
||||||
uuid: Some(format!("{}{}", self.link_uid.clone(), ".SPI1")),
|
uuid: Some(format!("{}{}", self.link_uid.clone(), ".SPI1")),
|
||||||
r#type: Some("b-m-p-s-p-i".to_string()),
|
r#type: Some("b-m-p-s-p-i".to_string()),
|
||||||
point_lat: self.point_lat,
|
point_lat: self.point_lat,
|
||||||
point_lon: self.point_lon,
|
point_lon: self.point_lon,
|
||||||
point_hae: self.point_hae,
|
point_hae: self.point_hae,
|
||||||
point_ce: None,
|
point_ce: None,
|
||||||
point_le: None,
|
point_le: None,
|
||||||
contact_callsign: self.contact_callsign.clone(),
|
contact_callsign: self.contact_callsign.clone(),
|
||||||
group_name: None,
|
group_name: None,
|
||||||
group_role: None,
|
group_role: None,
|
||||||
track_course: None,
|
track_course: None,
|
||||||
track_speed: None,
|
track_speed: None,
|
||||||
link_uid: Some(self.link_uid.clone()),
|
link_uid: Some(self.link_uid.clone()),
|
||||||
remarker: None,
|
remarker: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
126
src/cot/draws/circle.rs
Normal file
126
src/cot/draws/circle.rs
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
|
||||||
|
pub struct CircleCoTPayload {
|
||||||
|
pub uuid: String,
|
||||||
|
pub center_lat: f64,
|
||||||
|
pub center_lon: f64,
|
||||||
|
pub center_hae: f32,
|
||||||
|
pub major: f64,
|
||||||
|
pub minor: f64,
|
||||||
|
pub angle: f32,
|
||||||
|
pub callsign: String,
|
||||||
|
pub creator_uid: String,
|
||||||
|
pub creator_callsign: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromArma for CircleCoTPayload {
|
||||||
|
fn from_arma(data: String) -> Result<Self, FromArmaError> {
|
||||||
|
let (
|
||||||
|
uuid,
|
||||||
|
center_lat,
|
||||||
|
center_lon,
|
||||||
|
center_hae,
|
||||||
|
major,
|
||||||
|
minor,
|
||||||
|
angle,
|
||||||
|
callsign,
|
||||||
|
creator_uid,
|
||||||
|
creator_callsign,
|
||||||
|
) = <(String, f64, f64, f32, f64, f64, f32, String, String, String)>::from_arma(data)?;
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
uuid,
|
||||||
|
center_lat,
|
||||||
|
center_lon,
|
||||||
|
center_hae,
|
||||||
|
major,
|
||||||
|
minor,
|
||||||
|
angle,
|
||||||
|
callsign,
|
||||||
|
creator_uid,
|
||||||
|
creator_callsign,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ShapeCircleCoT {
|
||||||
|
pub uid: String,
|
||||||
|
pub lat: f64,
|
||||||
|
pub lon: f64,
|
||||||
|
pub hae: f32,
|
||||||
|
pub major: f64,
|
||||||
|
pub minor: f64,
|
||||||
|
pub angle: f32,
|
||||||
|
pub callsign: String,
|
||||||
|
pub creator_uid: String,
|
||||||
|
pub creator_callsign: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CircleCoTPayload {
|
||||||
|
pub fn to_cot(&self) -> ShapeCircleCoT {
|
||||||
|
ShapeCircleCoT {
|
||||||
|
uid: self.uuid.clone(),
|
||||||
|
lat: self.center_lat,
|
||||||
|
lon: self.center_lon,
|
||||||
|
hae: self.center_hae,
|
||||||
|
major: self.major,
|
||||||
|
minor: self.minor,
|
||||||
|
angle: self.angle,
|
||||||
|
callsign: self.callsign.clone(),
|
||||||
|
creator_uid: self.creator_uid.clone(),
|
||||||
|
creator_callsign: self.creator_callsign.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ShapeCircleCoT {
|
||||||
|
pub fn to_xml(&self, now: &str, stale: &str) -> String {
|
||||||
|
format!(
|
||||||
|
r#"<event version="2.0" uid="{uid}" type="u-d-c-c"
|
||||||
|
time="{t}" start="{t}" stale="{stale}"
|
||||||
|
how="h-e" access="Undefined">
|
||||||
|
<point lat="{lat}" lon="{lon}" hae="{hae}" ce="10.9" le="9999999.0" />
|
||||||
|
<detail>
|
||||||
|
<shape>
|
||||||
|
<ellipse major="{major}" minor="{minor}" angle="{angle}" />
|
||||||
|
<link uid="{uid}.Style" type="b-x-KmlStyle" relation="p-c">
|
||||||
|
<Style>
|
||||||
|
<LineStyle>
|
||||||
|
<color>ffffffff</color>
|
||||||
|
<width>3.0</width>
|
||||||
|
</LineStyle>
|
||||||
|
<PolyStyle>
|
||||||
|
<color>96ffffff</color>
|
||||||
|
</PolyStyle>
|
||||||
|
</Style>
|
||||||
|
</link>
|
||||||
|
<link uid="{creator_uid}" type="self" relation="p-p-CenterAnchor" />
|
||||||
|
</shape>
|
||||||
|
<__shapeExtras cpvis="true" editable="true" />
|
||||||
|
<remarks />
|
||||||
|
<contact callsign="{callsign}" />
|
||||||
|
<creator uid="{creator_uid}" callsign="{creator_callsign}" time="{t}" type="a-f-G-U-C" />
|
||||||
|
<archive />
|
||||||
|
<labels_on value="true" />
|
||||||
|
<strokeColor value="-1" />
|
||||||
|
<strokeWeight value="3.0" />
|
||||||
|
<strokeStyle value="solid" />
|
||||||
|
<fillColor value="-1761607681" />
|
||||||
|
<precisionlocation altsrc="GPS" geopointsrc="GPS" />
|
||||||
|
</detail>
|
||||||
|
</event>"#,
|
||||||
|
uid = self.uid,
|
||||||
|
t = now,
|
||||||
|
stale = stale,
|
||||||
|
lat = self.lat,
|
||||||
|
lon = self.lon,
|
||||||
|
hae = self.hae,
|
||||||
|
major = self.major,
|
||||||
|
minor = self.minor,
|
||||||
|
angle = self.angle,
|
||||||
|
callsign = self.callsign,
|
||||||
|
creator_uid = self.creator_uid,
|
||||||
|
creator_callsign = self.creator_callsign
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/cot/draws/mod.rs
Normal file
1
src/cot/draws/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod circle;
|
||||||
104
src/cot/eud.rs
104
src/cot/eud.rs
@@ -1,62 +1,62 @@
|
|||||||
use arma_rs::{FromArma, FromArmaError};
|
|
||||||
use super::cot::CursorOverTime;
|
use super::cot::CursorOverTime;
|
||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
|
||||||
pub struct EudCoTPayload {
|
pub struct EudCoTPayload {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
pub point_lat: f64,
|
pub point_lat: f64,
|
||||||
pub point_lon: f64,
|
pub point_lon: f64,
|
||||||
pub point_hae: f32,
|
pub point_hae: f32,
|
||||||
pub contact_callsign: String,
|
pub contact_callsign: String,
|
||||||
pub group_name: String,
|
pub group_name: String,
|
||||||
pub group_role: String,
|
pub group_role: String,
|
||||||
pub track_course: i32,
|
pub track_course: i32,
|
||||||
pub track_speed: f32,
|
pub track_speed: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromArma for EudCoTPayload {
|
impl FromArma for EudCoTPayload {
|
||||||
fn from_arma(data: String) -> Result<EudCoTPayload, FromArmaError> {
|
fn from_arma(data: String) -> Result<EudCoTPayload, FromArmaError> {
|
||||||
let (
|
let (
|
||||||
uuid,
|
uuid,
|
||||||
point_lat,
|
point_lat,
|
||||||
point_lon,
|
point_lon,
|
||||||
point_hae,
|
point_hae,
|
||||||
contact_callsign,
|
contact_callsign,
|
||||||
group_name,
|
group_name,
|
||||||
group_role,
|
group_role,
|
||||||
track_course,
|
track_course,
|
||||||
track_speed,
|
track_speed,
|
||||||
) = <(String, f64, f64, f32, String, String, String, i32, f32)>::from_arma(data)?;
|
) = <(String, f64, f64, f32, String, String, String, i32, f32)>::from_arma(data)?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
uuid,
|
uuid,
|
||||||
point_lat,
|
point_lat,
|
||||||
point_lon,
|
point_lon,
|
||||||
point_hae,
|
point_hae,
|
||||||
contact_callsign,
|
contact_callsign,
|
||||||
group_name,
|
group_name,
|
||||||
group_role,
|
group_role,
|
||||||
track_course,
|
track_course,
|
||||||
track_speed,
|
track_speed,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EudCoTPayload {
|
impl EudCoTPayload {
|
||||||
pub fn to_cot(&self) -> CursorOverTime {
|
pub fn to_cot(&self) -> CursorOverTime {
|
||||||
CursorOverTime {
|
CursorOverTime {
|
||||||
uuid: Some(self.uuid.clone()),
|
uuid: Some(self.uuid.clone()),
|
||||||
r#type: None,
|
r#type: None,
|
||||||
point_lat: self.point_lat,
|
point_lat: self.point_lat,
|
||||||
point_lon: self.point_lon,
|
point_lon: self.point_lon,
|
||||||
point_hae: self.point_hae,
|
point_hae: self.point_hae,
|
||||||
point_ce: None,
|
point_ce: None,
|
||||||
point_le: None,
|
point_le: None,
|
||||||
contact_callsign: self.contact_callsign.clone(),
|
contact_callsign: self.contact_callsign.clone(),
|
||||||
group_name: Some(self.group_name.clone()),
|
group_name: Some(self.group_name.clone()),
|
||||||
group_role: Some(self.group_role.clone()),
|
group_role: Some(self.group_role.clone()),
|
||||||
track_course: Some(self.track_course),
|
track_course: Some(self.track_course),
|
||||||
track_speed: Some(self.track_speed),
|
track_speed: Some(self.track_speed),
|
||||||
link_uid: None,
|
link_uid: None,
|
||||||
remarker: None,
|
remarker: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use arma_rs::{FromArma, FromArmaError};
|
|
||||||
use super::cot::CursorOverTime;
|
use super::cot::CursorOverTime;
|
||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
|
||||||
pub struct ExternalPositionPayload {
|
pub struct ExternalPositionPayload {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
@@ -13,47 +13,47 @@ pub struct ExternalPositionPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FromArma for ExternalPositionPayload {
|
impl FromArma for ExternalPositionPayload {
|
||||||
fn from_arma(data: String) -> Result<ExternalPositionPayload, FromArmaError> {
|
fn from_arma(data: String) -> Result<ExternalPositionPayload, FromArmaError> {
|
||||||
let (
|
let (
|
||||||
uuid,
|
uuid,
|
||||||
point_lat,
|
point_lat,
|
||||||
point_lon,
|
point_lon,
|
||||||
point_hae,
|
point_hae,
|
||||||
contact_callsign,
|
contact_callsign,
|
||||||
track_course,
|
track_course,
|
||||||
track_speed,
|
track_speed,
|
||||||
remarker,
|
remarker,
|
||||||
) = <(String, f64, f64, f32, String, i32, f32, String)>::from_arma(data)?;
|
) = <(String, f64, f64, f32, String, i32, f32, String)>::from_arma(data)?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
uuid,
|
uuid,
|
||||||
point_lat,
|
point_lat,
|
||||||
point_lon,
|
point_lon,
|
||||||
point_hae,
|
point_hae,
|
||||||
contact_callsign,
|
contact_callsign,
|
||||||
track_course,
|
track_course,
|
||||||
track_speed,
|
track_speed,
|
||||||
remarker,
|
remarker,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExternalPositionPayload {
|
impl ExternalPositionPayload {
|
||||||
pub fn to_cot(&self) -> CursorOverTime {
|
pub fn to_cot(&self) -> CursorOverTime {
|
||||||
CursorOverTime {
|
CursorOverTime {
|
||||||
uuid: Some(self.uuid.clone()),
|
uuid: Some(self.uuid.clone()),
|
||||||
r#type: None,
|
r#type: None,
|
||||||
point_lat: self.point_lat,
|
point_lat: self.point_lat,
|
||||||
point_lon: self.point_lon,
|
point_lon: self.point_lon,
|
||||||
point_hae: self.point_hae,
|
point_hae: self.point_hae,
|
||||||
point_ce: None,
|
point_ce: None,
|
||||||
point_le: None,
|
point_le: None,
|
||||||
contact_callsign: self.contact_callsign.clone(),
|
contact_callsign: self.contact_callsign.clone(),
|
||||||
group_name: None,
|
group_name: None,
|
||||||
group_role: None,
|
group_role: None,
|
||||||
track_course: Some(self.track_course),
|
track_course: Some(self.track_course),
|
||||||
track_speed: Some(self.track_speed),
|
track_speed: Some(self.track_speed),
|
||||||
link_uid: None,
|
link_uid: None,
|
||||||
remarker: Some(self.remarker.clone()),
|
remarker: Some(self.remarker.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
147
src/cot/message.rs
Normal file
147
src/cot/message.rs
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
use arma_rs::{FromArma, FromArmaError};
|
||||||
|
use chrono::{Duration, SecondsFormat, Utc};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub struct MessagePayload {
|
||||||
|
pub sender_callsign: String,
|
||||||
|
pub chatroom: String,
|
||||||
|
pub message_text: String,
|
||||||
|
pub point_lat: f64,
|
||||||
|
pub point_lon: f64,
|
||||||
|
pub point_hae: f32,
|
||||||
|
pub sender_uid: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromArma for MessagePayload {
|
||||||
|
fn from_arma(data: String) -> Result<Self, FromArmaError> {
|
||||||
|
let (sender_callsign, chatroom, message_text, point_lat, point_lon, point_hae, sender_uid) =
|
||||||
|
<(String, String, String, f64, f64, f32, String)>::from_arma(data)?;
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
sender_callsign,
|
||||||
|
chatroom,
|
||||||
|
message_text,
|
||||||
|
point_lat,
|
||||||
|
point_lon,
|
||||||
|
point_hae,
|
||||||
|
sender_uid,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MessageCot {
|
||||||
|
pub sender_callsign: String,
|
||||||
|
pub chatroom: String,
|
||||||
|
pub message_text: String,
|
||||||
|
pub point_lat: f64,
|
||||||
|
pub point_lon: f64,
|
||||||
|
pub point_hae: f32,
|
||||||
|
pub sender_uid: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MessageCot {
|
||||||
|
pub fn from_payload(p: MessagePayload) -> Self {
|
||||||
|
Self {
|
||||||
|
sender_callsign: p.sender_callsign,
|
||||||
|
chatroom: p.chatroom,
|
||||||
|
message_text: p.message_text,
|
||||||
|
point_lat: p.point_lat,
|
||||||
|
point_lon: p.point_lon,
|
||||||
|
point_hae: p.point_hae,
|
||||||
|
sender_uid: p.sender_uid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_xml(&self) -> String {
|
||||||
|
let created_time = Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||||
|
let stale_time =
|
||||||
|
(Utc::now() + Duration::days(1)).to_rfc3339_opts(SecondsFormat::Millis, true);
|
||||||
|
|
||||||
|
// MESSAGE ID (random UUID)
|
||||||
|
let message_uuid = Uuid::new_v4().to_string();
|
||||||
|
|
||||||
|
// FULL EVENT UID
|
||||||
|
// format: GeoChat.{sender}.{chatroom}.{uuid}
|
||||||
|
let event_uid = format!(
|
||||||
|
"GeoChat.{}.{}.{}",
|
||||||
|
self.sender_uid,
|
||||||
|
self.chatroom.replace(" ", "_"),
|
||||||
|
message_uuid,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut xml = String::new();
|
||||||
|
|
||||||
|
xml.push_str("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
|
|
||||||
|
xml.push_str(
|
||||||
|
format!(
|
||||||
|
"<event version=\"2.0\" uid=\"{}\" type=\"b-t-f\" time=\"{}\" start=\"{}\" stale=\"{}\" how=\"h-g-i-g-o\" access=\"Undefined\">",
|
||||||
|
event_uid, created_time, created_time, stale_time
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
xml.push_str(
|
||||||
|
format!(
|
||||||
|
"<point lat=\"{}\" lon=\"{}\" hae=\"{}\" ce=\"10.3\" le=\"9999999.0\"/>",
|
||||||
|
self.point_lat, self.point_lon, self.point_hae
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
xml.push_str("<detail>");
|
||||||
|
|
||||||
|
// ========== CHAT OBJECT ==========
|
||||||
|
|
||||||
|
xml.push_str(
|
||||||
|
format!(
|
||||||
|
"<__chat parent=\"RootContactGroup\" groupOwner=\"false\" \
|
||||||
|
messageId=\"{}\" chatroom=\"{}\" id=\"{}\" senderCallsign=\"{}\">",
|
||||||
|
message_uuid, self.chatroom, self.chatroom, self.sender_callsign,
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
xml.push_str(
|
||||||
|
format!(
|
||||||
|
"<chatgrp uid0=\"{}\" uid1=\"{}\" id=\"{}\" />",
|
||||||
|
self.sender_uid, self.chatroom, self.chatroom
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
xml.push_str("</__chat>");
|
||||||
|
|
||||||
|
// ========== LINK ELEMENT ==========
|
||||||
|
xml.push_str(
|
||||||
|
format!(
|
||||||
|
"<link uid=\"{}\" type=\"a-f-G-U-C\" relation=\"p-p\" />",
|
||||||
|
self.sender_uid
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// ========== SERVER DEST ==========
|
||||||
|
// This is optional — you may remove or customize it
|
||||||
|
xml.push_str(
|
||||||
|
format!(
|
||||||
|
"<__serverdestination destinations=\"0.0.0.0:0:tcp:{}\" />",
|
||||||
|
self.sender_uid
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// ========== MESSAGE REMARKS ==========
|
||||||
|
xml.push_str(
|
||||||
|
format!(
|
||||||
|
"<remarks source=\"ARMATAK.{}\" to=\"{}\" time=\"{}\">{}</remarks>",
|
||||||
|
self.sender_uid, self.chatroom, created_time, self.message_text
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
xml.push_str("</detail></event>");
|
||||||
|
|
||||||
|
xml
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
pub mod cot;
|
pub mod cot;
|
||||||
pub mod digital_pointer;
|
pub mod digital_pointer;
|
||||||
|
pub mod draws;
|
||||||
pub mod eud;
|
pub mod eud;
|
||||||
pub mod gps;
|
pub mod gps;
|
||||||
pub mod nato;
|
pub mod message;
|
||||||
|
pub mod nato;
|
||||||
|
|||||||
41
src/lib.rs
41
src/lib.rs
@@ -1,8 +1,9 @@
|
|||||||
use arma_rs::{arma, Extension, Group};
|
use arma_rs::{arma, Extension, Group};
|
||||||
|
use rustls::crypto::aws_lc_rs;
|
||||||
mod structs;
|
mod structs;
|
||||||
|
mod tcp;
|
||||||
mod tests;
|
mod tests;
|
||||||
mod udp_socket;
|
mod udp_socket;
|
||||||
mod tcp_socket;
|
|
||||||
mod video_stream;
|
mod video_stream;
|
||||||
|
|
||||||
mod cot;
|
mod cot;
|
||||||
@@ -31,32 +32,52 @@ pub fn init() -> Extension {
|
|||||||
|
|
||||||
log4rs::init_config(config).unwrap();
|
log4rs::init_config(config).unwrap();
|
||||||
|
|
||||||
|
let _ = aws_lc_rs::default_provider().install_default();
|
||||||
|
log::info!("Initialized rustls aws-lc crypto provider.");
|
||||||
|
|
||||||
Extension::build()
|
Extension::build()
|
||||||
.command("local_ip", utils::address::get_local_address)
|
.command("local_ip", utils::address::get_local_address)
|
||||||
.command("uuid", utils::uuid::get_uuid)
|
.command("uuid", utils::uuid::get_uuid)
|
||||||
.command("log", utils::log::log_info)
|
.command("log", utils::log::log_info)
|
||||||
.group("udp_socket",
|
.group(
|
||||||
|
"udp_socket",
|
||||||
Group::new()
|
Group::new()
|
||||||
.command("start", udp_socket::start)
|
.command("start", udp_socket::start)
|
||||||
.command("send_payload", udp_socket::send_payload)
|
.command("send_payload", udp_socket::send_payload)
|
||||||
.command("send_gps_cot", udp_socket::send_gps_cot)
|
.command("send_gps_cot", udp_socket::send_gps_cot)
|
||||||
.command("stop", udp_socket::stop)
|
.command("stop", udp_socket::stop),
|
||||||
)
|
)
|
||||||
.group(
|
.group(
|
||||||
"tcp_socket",
|
"tcp_socket",
|
||||||
Group::new()
|
Group::new()
|
||||||
.command("start", tcp_socket::start)
|
.command("start", tcp::start)
|
||||||
.command("send_payload", tcp_socket::send_payload)
|
.command("start_mtls", tcp::start_mtls)
|
||||||
.command("send_eud_cot", tcp_socket::send_eud_cot)
|
.command("start_enroll_mtls", tcp::start_enroll_mtls)
|
||||||
.command("send_marker_cot", tcp_socket::send_marker_cot)
|
.command("stop", tcp::stop)
|
||||||
.command("send_digital_pointer_cot", tcp_socket::send_digital_pointer_cot)
|
.command("send_payload", tcp::send_payload)
|
||||||
.command("stop", tcp_socket::stop)
|
.group(
|
||||||
|
"cot",
|
||||||
|
Group::new()
|
||||||
|
.command("eud", tcp::cot::send_eud_cot)
|
||||||
|
.command("marker", tcp::cot::send_marker_cot)
|
||||||
|
.command("digital_pointer", tcp::cot::send_digital_pointer_cot)
|
||||||
|
.command("chat", tcp::cot::send_message_cot),
|
||||||
|
)
|
||||||
|
.group(
|
||||||
|
"draw",
|
||||||
|
Group::new()
|
||||||
|
.command("circle", tcp::draw::send_circle_cot)
|
||||||
|
.command("ellipse", tcp::draw::send_ellipse_cot)
|
||||||
|
.command("rectangle", tcp::draw::send_rectangle_cot)
|
||||||
|
.command("free", tcp::draw::send_freedraw_cot)
|
||||||
|
.command("vector", tcp::draw::send_vectordraw_cot),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.group(
|
.group(
|
||||||
"video_stream",
|
"video_stream",
|
||||||
Group::new()
|
Group::new()
|
||||||
.command("start", video_stream::start_stream)
|
.command("start", video_stream::start_stream)
|
||||||
.command("stop", video_stream::stop_stream)
|
.command("stop", video_stream::stop_stream),
|
||||||
)
|
)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ pub struct LogPayload {
|
|||||||
impl FromArma for LogPayload {
|
impl FromArma for LogPayload {
|
||||||
fn from_arma(data: String) -> Result<LogPayload, FromArmaError> {
|
fn from_arma(data: String) -> Result<LogPayload, FromArmaError> {
|
||||||
let (status, message) = <(String, String)>::from_arma(data)?;
|
let (status, message) = <(String, String)>::from_arma(data)?;
|
||||||
Ok(Self {
|
Ok(Self { status, message })
|
||||||
status,
|
|
||||||
message
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
280
src/tcp/client.rs
Normal file
280
src/tcp/client.rs
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
use arma_rs::Context;
|
||||||
|
use log::{info, warn};
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
use std::panic::{self, AssertUnwindSafe};
|
||||||
|
use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender, TryRecvError};
|
||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use super::config::ConnectionConfig;
|
||||||
|
use super::transport::{connect_stream, TransportStream};
|
||||||
|
use super::TCP_CLIENT;
|
||||||
|
|
||||||
|
const CONNECT_POLL_INTERVAL: Duration = Duration::from_millis(200);
|
||||||
|
const MAX_PENDING_MESSAGES: usize = 128;
|
||||||
|
|
||||||
|
pub enum TcpCommand {
|
||||||
|
SendMessage(String, Context),
|
||||||
|
Stop,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TcpClient {
|
||||||
|
pub(crate) tx: Sender<TcpCommand>,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ConnectionState {
|
||||||
|
Connecting,
|
||||||
|
Connected,
|
||||||
|
Failed(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ConnectEvent {
|
||||||
|
Connected(TransportStream),
|
||||||
|
Failed(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
fn describe_panic_payload(payload: Box<dyn std::any::Any + Send>) -> String {
|
||||||
|
if let Some(message) = payload.downcast_ref::<&str>() {
|
||||||
|
(*message).to_string()
|
||||||
|
} else if let Some(message) = payload.downcast_ref::<String>() {
|
||||||
|
message.clone()
|
||||||
|
} else {
|
||||||
|
"unknown panic payload".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log_message_preview(message: &str) -> String {
|
||||||
|
message.chars().take(96).collect::<String>()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_over_stream(
|
||||||
|
stream: &mut TransportStream,
|
||||||
|
context: &Context,
|
||||||
|
message: String,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let message_len = message.len();
|
||||||
|
info!("Sending TCP payload ({} bytes)", message_len);
|
||||||
|
stream
|
||||||
|
.write_message(message.as_bytes())
|
||||||
|
.map_err(|e| {
|
||||||
|
let message = e.to_string();
|
||||||
|
let _ = context.callback_data(
|
||||||
|
"TCP SOCKET ERROR",
|
||||||
|
"TAK Socket disconnected",
|
||||||
|
message.clone(),
|
||||||
|
);
|
||||||
|
message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flush_pending_messages(
|
||||||
|
connection: &mut Option<TransportStream>,
|
||||||
|
pending_messages: &mut VecDeque<(String, Context)>,
|
||||||
|
state: &mut ConnectionState,
|
||||||
|
) {
|
||||||
|
if pending_messages.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(stream) = connection.as_mut() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Flushing {} queued TCP payload(s) after connection became active",
|
||||||
|
pending_messages.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
while let Some((message, context)) = pending_messages.pop_front() {
|
||||||
|
if let Err(error) = send_over_stream(stream, &context, message) {
|
||||||
|
info!("Failed to send queued message: {}", error);
|
||||||
|
*state = ConnectionState::Failed(error);
|
||||||
|
*connection = None;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn poll_connect_event(
|
||||||
|
connect_rx: &Receiver<ConnectEvent>,
|
||||||
|
connection: &mut Option<TransportStream>,
|
||||||
|
state: &mut ConnectionState,
|
||||||
|
pending_messages: &mut VecDeque<(String, Context)>,
|
||||||
|
ctx: &Context,
|
||||||
|
connection_message: &str,
|
||||||
|
target: &str,
|
||||||
|
) {
|
||||||
|
loop {
|
||||||
|
match connect_rx.try_recv() {
|
||||||
|
Ok(ConnectEvent::Connected(stream)) => {
|
||||||
|
info!("TCP connection established successfully: {}", target);
|
||||||
|
let _ = ctx.callback_data("TCP SOCKET", connection_message, target.to_string());
|
||||||
|
*connection = Some(stream);
|
||||||
|
*state = ConnectionState::Connected;
|
||||||
|
flush_pending_messages(connection, pending_messages, state);
|
||||||
|
}
|
||||||
|
Ok(ConnectEvent::Failed(error)) => {
|
||||||
|
info!("Failed to connect to TCP server: {}", error);
|
||||||
|
let _ = ctx.callback_data(
|
||||||
|
"TCP SOCKET ERROR",
|
||||||
|
"TAK Socket connection failed",
|
||||||
|
error.clone(),
|
||||||
|
);
|
||||||
|
*state = ConnectionState::Failed(error);
|
||||||
|
}
|
||||||
|
Err(TryRecvError::Empty) => break,
|
||||||
|
Err(TryRecvError::Disconnected) => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TcpClient {
|
||||||
|
pub fn start(&self, config: ConnectionConfig, rx: Receiver<TcpCommand>, ctx: Context) {
|
||||||
|
if let Some(ref client) = *TCP_CLIENT.lock().unwrap() {
|
||||||
|
info!("Existing TCP client detected; stopping previous instance before restart.");
|
||||||
|
client.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
thread::spawn(move || {
|
||||||
|
let mut running = true;
|
||||||
|
let connection_message = config.connected_message();
|
||||||
|
let config_description = config.describe();
|
||||||
|
let target = config.target();
|
||||||
|
let mut state = ConnectionState::Connecting;
|
||||||
|
let mut connection: Option<TransportStream> = None;
|
||||||
|
let mut pending_messages: VecDeque<(String, Context)> = VecDeque::new();
|
||||||
|
let (connect_tx, connect_rx) = mpsc::channel();
|
||||||
|
|
||||||
|
info!("TCP worker thread started with config: {}", config_description);
|
||||||
|
|
||||||
|
let tcp_thread = thread::spawn(move || {
|
||||||
|
let connect_result = panic::catch_unwind(AssertUnwindSafe(|| connect_stream(&config)));
|
||||||
|
|
||||||
|
match connect_result {
|
||||||
|
Ok(Ok(stream)) => {
|
||||||
|
let _ = connect_tx.send(ConnectEvent::Connected(stream));
|
||||||
|
}
|
||||||
|
Ok(Err(error)) => {
|
||||||
|
let _ = connect_tx.send(ConnectEvent::Failed(error));
|
||||||
|
}
|
||||||
|
Err(payload) => {
|
||||||
|
let message = format!(
|
||||||
|
"TCP connection worker panicked: {}",
|
||||||
|
describe_panic_payload(payload)
|
||||||
|
);
|
||||||
|
let _ = connect_tx.send(ConnectEvent::Failed(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
while running {
|
||||||
|
poll_connect_event(
|
||||||
|
&connect_rx,
|
||||||
|
&mut connection,
|
||||||
|
&mut state,
|
||||||
|
&mut pending_messages,
|
||||||
|
&ctx,
|
||||||
|
connection_message,
|
||||||
|
&target,
|
||||||
|
);
|
||||||
|
|
||||||
|
match rx.recv_timeout(CONNECT_POLL_INTERVAL) {
|
||||||
|
Ok(TcpCommand::SendMessage(message, context)) => {
|
||||||
|
let message_len = message.len();
|
||||||
|
match &mut state {
|
||||||
|
ConnectionState::Connected => {
|
||||||
|
if let Some(stream) = connection.as_mut() {
|
||||||
|
if let Err(error) = send_over_stream(stream, &context, message) {
|
||||||
|
info!("Failed to send message: {}", error);
|
||||||
|
state = ConnectionState::Failed(error);
|
||||||
|
connection = None;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
"Connection state said connected, but no socket was present; queuing payload."
|
||||||
|
);
|
||||||
|
pending_messages.push_back((message, context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConnectionState::Connecting => {
|
||||||
|
if pending_messages.len() >= MAX_PENDING_MESSAGES {
|
||||||
|
let preview = log_message_preview(&message);
|
||||||
|
warn!(
|
||||||
|
"Dropping TCP payload because connection is still pending and queue is full ({} bytes, preview={:?})",
|
||||||
|
message_len, preview
|
||||||
|
);
|
||||||
|
let _ = context.callback_data(
|
||||||
|
"TCP SOCKET ERROR",
|
||||||
|
"TAK Socket is still connecting",
|
||||||
|
format!(
|
||||||
|
"queue full while connecting; dropped payload ({} bytes, preview={:?})",
|
||||||
|
message_len, preview
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
info!(
|
||||||
|
"Queueing TCP payload while connection is pending ({} bytes, queued={})",
|
||||||
|
message_len,
|
||||||
|
pending_messages.len() + 1
|
||||||
|
);
|
||||||
|
pending_messages.push_back((message, context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConnectionState::Failed(error) => {
|
||||||
|
let preview = log_message_preview(&message);
|
||||||
|
warn!(
|
||||||
|
"Dropping TCP payload because connection is in failed state ({} bytes, preview={:?}, error={})",
|
||||||
|
message_len, preview, error
|
||||||
|
);
|
||||||
|
let _ = context.callback_data(
|
||||||
|
"TCP SOCKET ERROR",
|
||||||
|
"TAK Socket is not connected",
|
||||||
|
error.clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(TcpCommand::Stop) => {
|
||||||
|
running = false;
|
||||||
|
info!("Stopping TCP client.");
|
||||||
|
}
|
||||||
|
Err(RecvTimeoutError::Timeout) => {}
|
||||||
|
Err(RecvTimeoutError::Disconnected) => {
|
||||||
|
warn!("TCP command channel disconnected.");
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("Waiting for TCP connection thread to finish.");
|
||||||
|
match tcp_thread.join() {
|
||||||
|
Ok(()) => info!("TCP connection thread joined successfully."),
|
||||||
|
Err(payload) => warn!(
|
||||||
|
"TCP connection thread join reported a panic: {}",
|
||||||
|
describe_panic_payload(payload)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
info!("TCP worker thread finished.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_payload(&self, context: Context, payload: String) {
|
||||||
|
let tx = self.tx.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
info!("Dispatching queued TCP payload command.");
|
||||||
|
if let Err(error) = tx.send(TcpCommand::SendMessage(payload, context)) {
|
||||||
|
warn!("Failed to dispatch TCP payload command: {}", error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stop(&self) {
|
||||||
|
let tx = self.tx.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
info!("Dispatching TCP stop command.");
|
||||||
|
if let Err(error) = tx.send(TcpCommand::Stop) {
|
||||||
|
warn!("Failed to dispatch TCP stop command: {}", error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
64
src/tcp/config.rs
Normal file
64
src/tcp/config.rs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
pub enum ConnectionConfig {
|
||||||
|
Plain {
|
||||||
|
address: String,
|
||||||
|
},
|
||||||
|
Mtls {
|
||||||
|
address: String,
|
||||||
|
server_name: String,
|
||||||
|
ca_cert_path: String,
|
||||||
|
client_cert_path: String,
|
||||||
|
client_key_path: String,
|
||||||
|
},
|
||||||
|
EnrollMtls {
|
||||||
|
host: String,
|
||||||
|
server_name: String,
|
||||||
|
enroll_port: String,
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
client_uid: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ConnectionConfig {
|
||||||
|
pub fn connected_message(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::Plain { .. } => "Connected to TCP Server",
|
||||||
|
Self::Mtls { .. } => "Connected to TAK Server via mTLS",
|
||||||
|
Self::EnrollMtls { .. } => "Connected to TAK Server via enrolled mTLS certificate",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn target(&self) -> String {
|
||||||
|
match self {
|
||||||
|
Self::Plain { address } | Self::Mtls { address, .. } => address.clone(),
|
||||||
|
Self::EnrollMtls { host, .. } => host.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn describe(&self) -> String {
|
||||||
|
match self {
|
||||||
|
Self::Plain { address } => format!("plain tcp -> {}", address),
|
||||||
|
Self::Mtls {
|
||||||
|
address,
|
||||||
|
server_name,
|
||||||
|
ca_cert_path,
|
||||||
|
client_cert_path,
|
||||||
|
client_key_path,
|
||||||
|
} => format!(
|
||||||
|
"manual mtls -> {} (server_name={}, ca={}, cert={}, key={})",
|
||||||
|
address, server_name, ca_cert_path, client_cert_path, client_key_path
|
||||||
|
),
|
||||||
|
Self::EnrollMtls {
|
||||||
|
host,
|
||||||
|
server_name,
|
||||||
|
enroll_port,
|
||||||
|
username,
|
||||||
|
client_uid,
|
||||||
|
..
|
||||||
|
} => format!(
|
||||||
|
"enroll mtls -> host={} enroll_port={} server_name={} username={} client_uid={}",
|
||||||
|
host, enroll_port, server_name, username, client_uid
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/tcp/cot.rs
Normal file
41
src/tcp/cot.rs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
use arma_rs::Context;
|
||||||
|
|
||||||
|
use crate::{cot, tcp::send_payload};
|
||||||
|
|
||||||
|
pub fn send_eud_cot(ctx: Context, cursor_over_time: cot::eud::EudCoTPayload) -> &'static str {
|
||||||
|
let payload = cursor_over_time.to_cot().convert_to_xml();
|
||||||
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
|
"Sending End User Device Cursor Over Time to TCP server"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_marker_cot(
|
||||||
|
ctx: Context,
|
||||||
|
cursor_over_time: cot::nato::MarkerCoTPayload,
|
||||||
|
) -> &'static str {
|
||||||
|
let payload = cursor_over_time.to_cot().convert_to_xml();
|
||||||
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
|
"Sending Marker Cursor Over Time to TCP server"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_digital_pointer_cot(
|
||||||
|
ctx: Context,
|
||||||
|
cursor_over_time: cot::digital_pointer::DigitalPointerPayload,
|
||||||
|
) -> &'static str {
|
||||||
|
let payload = cursor_over_time.to_cot().convert_to_xml();
|
||||||
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
|
"Sending Digital Pointer Cursor Over Time to TCP server"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_message_cot(
|
||||||
|
ctx: Context,
|
||||||
|
message_payload: cot::message::MessagePayload,
|
||||||
|
) -> &'static str {
|
||||||
|
let message_cot = cot::message::MessageCot::from_payload(message_payload);
|
||||||
|
let payload = message_cot.to_xml();
|
||||||
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
|
"Sending Message CoT to TCP server"
|
||||||
|
}
|
||||||
37
src/tcp/draw.rs
Normal file
37
src/tcp/draw.rs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
use arma_rs::Context;
|
||||||
|
|
||||||
|
use crate::{cot, tcp::send_payload};
|
||||||
|
|
||||||
|
pub fn send_circle_cot(
|
||||||
|
ctx: Context,
|
||||||
|
circle_payload: cot::draws::circle::CircleCoTPayload,
|
||||||
|
) -> &'static str {
|
||||||
|
let shape_circle_cot = circle_payload.to_cot();
|
||||||
|
let now = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
|
||||||
|
let stale = (chrono::Utc::now() + chrono::Duration::days(1))
|
||||||
|
.to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
|
||||||
|
let payload = shape_circle_cot.to_xml(&now, &stale);
|
||||||
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
|
"Sending Circle CoT to TCP server"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_ellipse_cot(ctx: Context) -> &'static str {
|
||||||
|
let _ = ctx;
|
||||||
|
"Not implemented: send_ellipse_cot"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_rectangle_cot(ctx: Context) -> &'static str {
|
||||||
|
let _ = ctx;
|
||||||
|
"Not implemented: send_ellipse_cot"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_freedraw_cot(ctx: Context) -> &'static str {
|
||||||
|
let _ = ctx;
|
||||||
|
"Not implemented: send_ellipse_cot"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_vectordraw_cot(ctx: Context) -> &'static str {
|
||||||
|
let _ = ctx;
|
||||||
|
"Not implemented: send_ellipse_cot"
|
||||||
|
}
|
||||||
107
src/tcp/mod.rs
Normal file
107
src/tcp/mod.rs
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
use arma_rs::Context;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use log::info;
|
||||||
|
use std::sync::mpsc::{self, Receiver, Sender};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
mod client;
|
||||||
|
mod config;
|
||||||
|
mod tls;
|
||||||
|
mod transport;
|
||||||
|
|
||||||
|
pub mod cot;
|
||||||
|
pub mod draw;
|
||||||
|
|
||||||
|
use client::{TcpClient, TcpCommand};
|
||||||
|
use config::ConnectionConfig;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref TCP_CLIENT: Arc<Mutex<Option<TcpClient>>> = Arc::new(Mutex::new(None));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn start_with_config(ctx: Context, config: ConnectionConfig) {
|
||||||
|
info!("Starting TCP client with config: {}", config.describe());
|
||||||
|
let (tx, rx): (Sender<TcpCommand>, Receiver<TcpCommand>) = mpsc::channel();
|
||||||
|
|
||||||
|
let client = TcpClient { tx };
|
||||||
|
client.start(config, rx, ctx);
|
||||||
|
|
||||||
|
let mut client_guard = TCP_CLIENT.lock().unwrap();
|
||||||
|
*client_guard = Some(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start(ctx: Context, address: String) -> &'static str {
|
||||||
|
start_with_config(ctx, ConnectionConfig::Plain { address });
|
||||||
|
|
||||||
|
"Starting TCP Client"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start_mtls(
|
||||||
|
ctx: Context,
|
||||||
|
address: String,
|
||||||
|
server_name: String,
|
||||||
|
ca_cert_path: String,
|
||||||
|
client_cert_path: String,
|
||||||
|
client_key_path: String,
|
||||||
|
) -> &'static str {
|
||||||
|
start_with_config(
|
||||||
|
ctx,
|
||||||
|
ConnectionConfig::Mtls {
|
||||||
|
address,
|
||||||
|
server_name,
|
||||||
|
ca_cert_path,
|
||||||
|
client_cert_path,
|
||||||
|
client_key_path,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
"Starting mTLS TCP Client"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start_enroll_mtls(
|
||||||
|
ctx: Context,
|
||||||
|
host: String,
|
||||||
|
server_name: String,
|
||||||
|
enroll_port: String,
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
client_uid: String,
|
||||||
|
) -> &'static str {
|
||||||
|
start_with_config(
|
||||||
|
ctx,
|
||||||
|
ConnectionConfig::EnrollMtls {
|
||||||
|
host,
|
||||||
|
server_name,
|
||||||
|
enroll_port,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
client_uid,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
"Starting enrolled mTLS TCP Client"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_payload(ctx: Context, payload: String) -> &'static str {
|
||||||
|
if let Some(ref client) = *TCP_CLIENT.lock().unwrap() {
|
||||||
|
info!("Queueing TCP payload ({} bytes)", payload.len());
|
||||||
|
client.send_payload(ctx, payload);
|
||||||
|
} else {
|
||||||
|
let _ = ctx.callback_null("TCP SOCKET ERROR", "TCP Client is not running");
|
||||||
|
info!("TCP client is not running.");
|
||||||
|
}
|
||||||
|
|
||||||
|
"Sending payload to TCP server"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stop(ctx: Context) -> &'static str {
|
||||||
|
if let Some(ref client) = *TCP_CLIENT.lock().unwrap() {
|
||||||
|
info!("Stopping TCP client via extension command.");
|
||||||
|
client.stop();
|
||||||
|
let _ = ctx.callback_null("TCP SOCKET", "TCP client stopped");
|
||||||
|
} else {
|
||||||
|
let _ = ctx.callback_null("TCP SOCKET ERROR", "TCP client is not running");
|
||||||
|
}
|
||||||
|
|
||||||
|
"Stopping TCP Client"
|
||||||
|
}
|
||||||
221
src/tcp/tls/connector.rs
Normal file
221
src/tcp/tls/connector.rs
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
use log::info;
|
||||||
|
use rustls::pki_types::{CertificateDer, PrivateKeyDer, ServerName};
|
||||||
|
use rustls::{ClientConfig, ClientConnection, RootCertStore, StreamOwned};
|
||||||
|
use rustls_pemfile::{certs, private_key};
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::BufReader;
|
||||||
|
use std::io::Cursor;
|
||||||
|
use std::net::{SocketAddr, TcpStream, ToSocketAddrs};
|
||||||
|
use std::time::Duration;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crate::tcp::transport::TransportStream;
|
||||||
|
|
||||||
|
const TCP_CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
const SOCKET_IO_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
|
||||||
|
fn load_certificates(path: &str) -> Result<Vec<CertificateDer<'static>>, String> {
|
||||||
|
let file = File::open(path).map_err(|e| format!("failed to open cert file {}: {}", path, e))?;
|
||||||
|
let mut reader = BufReader::new(file);
|
||||||
|
|
||||||
|
certs(&mut reader)
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
.map_err(|e| format!("failed to read certs from {}: {}", path, e))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_private_key(path: &str) -> Result<PrivateKeyDer<'static>, String> {
|
||||||
|
let file = File::open(path).map_err(|e| format!("failed to open key file {}: {}", path, e))?;
|
||||||
|
let mut reader = BufReader::new(file);
|
||||||
|
|
||||||
|
private_key(&mut reader)
|
||||||
|
.map_err(|e| format!("failed to read private key from {}: {}", path, e))?
|
||||||
|
.ok_or_else(|| format!("no supported private key found in {}", path))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_certificates_from_pem(pem: &str) -> Result<Vec<CertificateDer<'static>>, String> {
|
||||||
|
let mut reader = Cursor::new(pem.as_bytes());
|
||||||
|
|
||||||
|
certs(&mut reader)
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
.map_err(|e| format!("failed to read certs from PEM payload: {}", e))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_private_key_from_pem(pem: &str) -> Result<PrivateKeyDer<'static>, String> {
|
||||||
|
let mut reader = Cursor::new(pem.as_bytes());
|
||||||
|
|
||||||
|
private_key(&mut reader)
|
||||||
|
.map_err(|e| format!("failed to read private key from PEM payload: {}", e))?
|
||||||
|
.ok_or_else(|| "no supported private key found in PEM payload".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn infer_server_name(address: &str) -> &str {
|
||||||
|
address
|
||||||
|
.trim()
|
||||||
|
.trim_start_matches('[')
|
||||||
|
.split(']')
|
||||||
|
.next()
|
||||||
|
.unwrap_or(address)
|
||||||
|
.split(':')
|
||||||
|
.next()
|
||||||
|
.unwrap_or(address)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_address(address: &str) -> Result<SocketAddr, String> {
|
||||||
|
address
|
||||||
|
.to_socket_addrs()
|
||||||
|
.map_err(|e| format!("failed to resolve {}: {}", address, e))?
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| format!("failed to resolve {}: no socket addresses returned", address))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn connect_tcp(address: &str) -> Result<TcpStream, String> {
|
||||||
|
let socket_addr = resolve_address(address)?;
|
||||||
|
info!(
|
||||||
|
"Opening TCP connection to {} (resolved={}) with timeout {:?}",
|
||||||
|
address, socket_addr, TCP_CONNECT_TIMEOUT
|
||||||
|
);
|
||||||
|
|
||||||
|
let tcp_stream = TcpStream::connect_timeout(&socket_addr, TCP_CONNECT_TIMEOUT)
|
||||||
|
.map_err(|e| format!("failed to connect to {}: {}", address, e))?;
|
||||||
|
|
||||||
|
tcp_stream
|
||||||
|
.set_read_timeout(Some(SOCKET_IO_TIMEOUT))
|
||||||
|
.map_err(|e| format!("failed to set read timeout on {}: {}", address, e))?;
|
||||||
|
tcp_stream
|
||||||
|
.set_write_timeout(Some(SOCKET_IO_TIMEOUT))
|
||||||
|
.map_err(|e| format!("failed to set write timeout on {}: {}", address, e))?;
|
||||||
|
|
||||||
|
Ok(tcp_stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect_mtls(
|
||||||
|
address: &str,
|
||||||
|
server_name: &str,
|
||||||
|
ca_cert_path: &str,
|
||||||
|
client_cert_path: &str,
|
||||||
|
client_key_path: &str,
|
||||||
|
) -> Result<TransportStream, String> {
|
||||||
|
info!(
|
||||||
|
"Connecting mTLS from file paths to {} using server_name={}",
|
||||||
|
address, server_name
|
||||||
|
);
|
||||||
|
let mut root_store = RootCertStore::empty();
|
||||||
|
let ca_certificates = load_certificates(ca_cert_path)?;
|
||||||
|
info!(
|
||||||
|
"Loaded {} CA certificate(s) from {}",
|
||||||
|
ca_certificates.len(),
|
||||||
|
ca_cert_path
|
||||||
|
);
|
||||||
|
for certificate in ca_certificates {
|
||||||
|
root_store
|
||||||
|
.add(certificate)
|
||||||
|
.map_err(|e| format!("failed to add CA certificate from {}: {}", ca_cert_path, e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let client_certificates = load_certificates(client_cert_path)?;
|
||||||
|
info!(
|
||||||
|
"Loaded {} client certificate(s) from {}",
|
||||||
|
client_certificates.len(),
|
||||||
|
client_cert_path
|
||||||
|
);
|
||||||
|
let client_key = load_private_key(client_key_path)?;
|
||||||
|
info!("Loaded client private key from {}", client_key_path);
|
||||||
|
|
||||||
|
let tls_config = ClientConfig::builder()
|
||||||
|
.with_root_certificates(root_store)
|
||||||
|
.with_client_auth_cert(client_certificates, client_key)
|
||||||
|
.map_err(|e| format!("failed to configure mTLS client: {}", e))?;
|
||||||
|
info!("Constructed rustls client config for {}", address);
|
||||||
|
|
||||||
|
let tcp_stream = connect_tcp(address)?;
|
||||||
|
let resolved_server_name = if server_name.trim().is_empty() {
|
||||||
|
infer_server_name(address).to_string()
|
||||||
|
} else {
|
||||||
|
server_name.trim().to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
let server_name = ServerName::try_from(resolved_server_name.clone())
|
||||||
|
.map_err(|_| format!("invalid TLS server name: {}", resolved_server_name))?;
|
||||||
|
let mut tls_stream = StreamOwned::new(
|
||||||
|
ClientConnection::new(Arc::new(tls_config), server_name)
|
||||||
|
.map_err(|e| format!("failed to create TLS client: {}", e))?,
|
||||||
|
tcp_stream,
|
||||||
|
);
|
||||||
|
|
||||||
|
info!("Starting mTLS handshake for {}", address);
|
||||||
|
while tls_stream.conn.is_handshaking() {
|
||||||
|
tls_stream
|
||||||
|
.conn
|
||||||
|
.complete_io(&mut tls_stream.sock)
|
||||||
|
.map_err(|e| format!("TLS handshake failed: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("mTLS handshake completed successfully for {}", address);
|
||||||
|
|
||||||
|
Ok(TransportStream::Mtls(tls_stream))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect_mtls_from_pem(
|
||||||
|
address: &str,
|
||||||
|
server_name: &str,
|
||||||
|
ca_cert_pem: &str,
|
||||||
|
client_cert_pem: &str,
|
||||||
|
client_key_pem: &str,
|
||||||
|
) -> Result<TransportStream, String> {
|
||||||
|
info!(
|
||||||
|
"Connecting mTLS from in-memory PEM payloads to {} using server_name={}",
|
||||||
|
address, server_name
|
||||||
|
);
|
||||||
|
let mut root_store = RootCertStore::empty();
|
||||||
|
let ca_certificates = load_certificates_from_pem(ca_cert_pem)?;
|
||||||
|
info!(
|
||||||
|
"Loaded {} CA certificate(s) from enrollment payload",
|
||||||
|
ca_certificates.len()
|
||||||
|
);
|
||||||
|
for certificate in ca_certificates {
|
||||||
|
root_store
|
||||||
|
.add(certificate)
|
||||||
|
.map_err(|e| format!("failed to add CA certificate from PEM payload: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let client_certificates = load_certificates_from_pem(client_cert_pem)?;
|
||||||
|
info!(
|
||||||
|
"Loaded {} client certificate(s) from enrollment payload",
|
||||||
|
client_certificates.len()
|
||||||
|
);
|
||||||
|
let client_key = load_private_key_from_pem(client_key_pem)?;
|
||||||
|
info!("Loaded client private key from enrollment payload");
|
||||||
|
|
||||||
|
let tls_config = ClientConfig::builder()
|
||||||
|
.with_root_certificates(root_store)
|
||||||
|
.with_client_auth_cert(client_certificates, client_key)
|
||||||
|
.map_err(|e| format!("failed to configure mTLS client: {}", e))?;
|
||||||
|
info!("Constructed rustls client config for {}", address);
|
||||||
|
|
||||||
|
let tcp_stream = connect_tcp(address)?;
|
||||||
|
let resolved_server_name = if server_name.trim().is_empty() {
|
||||||
|
infer_server_name(address).to_string()
|
||||||
|
} else {
|
||||||
|
server_name.trim().to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
let server_name = ServerName::try_from(resolved_server_name.clone())
|
||||||
|
.map_err(|_| format!("invalid TLS server name: {}", resolved_server_name))?;
|
||||||
|
let mut tls_stream = StreamOwned::new(
|
||||||
|
ClientConnection::new(Arc::new(tls_config), server_name)
|
||||||
|
.map_err(|e| format!("failed to create TLS client: {}", e))?,
|
||||||
|
tcp_stream,
|
||||||
|
);
|
||||||
|
|
||||||
|
info!("Starting mTLS handshake for {}", address);
|
||||||
|
while tls_stream.conn.is_handshaking() {
|
||||||
|
tls_stream
|
||||||
|
.conn
|
||||||
|
.complete_io(&mut tls_stream.sock)
|
||||||
|
.map_err(|e| format!("TLS handshake failed: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("mTLS handshake completed successfully for {}", address);
|
||||||
|
|
||||||
|
Ok(TransportStream::Mtls(tls_stream))
|
||||||
|
}
|
||||||
228
src/tcp/tls/enrollment.rs
Normal file
228
src/tcp/tls/enrollment.rs
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
use rcgen::{CertificateParams, DistinguishedName, DnType, KeyPair, PKCS_RSA_SHA256};
|
||||||
|
use log::info;
|
||||||
|
use reqwest::blocking::Client;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::connector::connect_mtls_from_pem;
|
||||||
|
use crate::tcp::transport::TransportStream;
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct EnrollmentResponse {
|
||||||
|
#[serde(rename = "signedCert")]
|
||||||
|
signed_cert: String,
|
||||||
|
ca0: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EnrollmentConfig {
|
||||||
|
server_port: String,
|
||||||
|
enroll_path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extract_tag_value(xml: &str, tag_name: &str) -> Option<String> {
|
||||||
|
let open_tag = format!("<{}>", tag_name);
|
||||||
|
let close_tag = format!("</{}>", tag_name);
|
||||||
|
let start = xml.find(&open_tag)? + open_tag.len();
|
||||||
|
let end = xml[start..].find(&close_tag)? + start;
|
||||||
|
Some(xml[start..end].trim().to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wrap_pem_body(base64_body: &str, begin: &str, end: &str) -> String {
|
||||||
|
let mut wrapped = String::new();
|
||||||
|
let normalized = base64_body.trim().replace(['\r', '\n'], "");
|
||||||
|
|
||||||
|
wrapped.push_str(begin);
|
||||||
|
wrapped.push('\n');
|
||||||
|
for chunk in normalized.as_bytes().chunks(64) {
|
||||||
|
wrapped.push_str(std::str::from_utf8(chunk).unwrap_or_default());
|
||||||
|
wrapped.push('\n');
|
||||||
|
}
|
||||||
|
wrapped.push_str(end);
|
||||||
|
wrapped.push('\n');
|
||||||
|
wrapped
|
||||||
|
}
|
||||||
|
|
||||||
|
fn enrollment_http_client() -> Result<Client, String> {
|
||||||
|
Client::builder()
|
||||||
|
.danger_accept_invalid_certs(true)
|
||||||
|
.build()
|
||||||
|
.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<EnrollmentConfig, String> {
|
||||||
|
let url = format!(
|
||||||
|
"https://{}:{}/Marti/api/tls/config",
|
||||||
|
host.trim(),
|
||||||
|
enroll_port.trim()
|
||||||
|
);
|
||||||
|
info!("Fetching TAK enrollment config from {}", url);
|
||||||
|
|
||||||
|
let response = enrollment_http_client()?
|
||||||
|
.get(&url)
|
||||||
|
.send()
|
||||||
|
.map_err(|e| format!("failed to fetch {}: {}", url, e))?;
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
return Err(format!(
|
||||||
|
"failed to fetch {}: {}",
|
||||||
|
url,
|
||||||
|
response_error_details(response)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let response_text = response
|
||||||
|
.text()
|
||||||
|
.map_err(|e| format!("failed to read config response from {}: {}", url, e))?;
|
||||||
|
|
||||||
|
let server_port = extract_tag_value(&response_text, "serverPort")
|
||||||
|
.ok_or_else(|| "missing serverPort in /Marti/api/tls/config response".to_string())?;
|
||||||
|
let enroll_path = extract_tag_value(&response_text, "enrollPath")
|
||||||
|
.ok_or_else(|| "missing enrollPath in /Marti/api/tls/config response".to_string())?;
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Enrollment config received: server_port={} enroll_path={}",
|
||||||
|
server_port, enroll_path
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(EnrollmentConfig {
|
||||||
|
server_port,
|
||||||
|
enroll_path,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn enroll_client_certificate(
|
||||||
|
host: &str,
|
||||||
|
enroll_port: &str,
|
||||||
|
enroll_path: &str,
|
||||||
|
username: &str,
|
||||||
|
password: &str,
|
||||||
|
client_uid: &str,
|
||||||
|
) -> Result<(String, String, String), String> {
|
||||||
|
info!(
|
||||||
|
"Generating RSA client keypair and CSR for enrolled TAK client {}",
|
||||||
|
client_uid
|
||||||
|
);
|
||||||
|
let key_pair = KeyPair::generate_for(&PKCS_RSA_SHA256)
|
||||||
|
.map_err(|e| format!("failed to generate client keypair: {}", e))?;
|
||||||
|
|
||||||
|
let mut distinguished_name = DistinguishedName::new();
|
||||||
|
distinguished_name.push(DnType::CommonName, client_uid);
|
||||||
|
distinguished_name.push(DnType::OrganizationName, "ArmaTAK");
|
||||||
|
distinguished_name.push(DnType::OrganizationalUnitName, "ArmaTAK Session");
|
||||||
|
|
||||||
|
let mut params = CertificateParams::new(vec![])
|
||||||
|
.map_err(|e| format!("failed to create CSR params: {}", e))?;
|
||||||
|
params.distinguished_name = distinguished_name;
|
||||||
|
|
||||||
|
let csr = params
|
||||||
|
.serialize_request(&key_pair)
|
||||||
|
.map_err(|e| format!("failed to generate CSR: {}", e))?;
|
||||||
|
let csr_der = csr.der().as_ref().to_vec();
|
||||||
|
|
||||||
|
let url = format!(
|
||||||
|
"https://{}:{}{}?clientUid={}",
|
||||||
|
host.trim(),
|
||||||
|
enroll_port.trim(),
|
||||||
|
enroll_path.trim(),
|
||||||
|
client_uid.trim()
|
||||||
|
);
|
||||||
|
info!(
|
||||||
|
"Submitting client certificate enrollment request for {} to {}",
|
||||||
|
client_uid, url
|
||||||
|
);
|
||||||
|
|
||||||
|
let response = enrollment_http_client()?
|
||||||
|
.post(&url)
|
||||||
|
.basic_auth(username.trim(), Some(password.to_string()))
|
||||||
|
.header("Accept", "application/json")
|
||||||
|
.header("Content-Type", "application/pkcs10")
|
||||||
|
.body(csr_der)
|
||||||
|
.send()
|
||||||
|
.map_err(|e| format!("failed to enroll client certificate at {}: {}", url, e))?;
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
return Err(format!(
|
||||||
|
"failed to enroll client certificate at {}: {}",
|
||||||
|
url,
|
||||||
|
response_error_details(response)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let enrollment: EnrollmentResponse = response
|
||||||
|
.json()
|
||||||
|
.map_err(|e| format!("failed to parse enrollment response: {}", e))?;
|
||||||
|
info!(
|
||||||
|
"Enrollment response parsed successfully for {} (signed_cert_len={}, ca_len={})",
|
||||||
|
client_uid,
|
||||||
|
enrollment.signed_cert.len(),
|
||||||
|
enrollment.ca0.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
let cert_pem = wrap_pem_body(
|
||||||
|
&enrollment.signed_cert,
|
||||||
|
"-----BEGIN CERTIFICATE-----",
|
||||||
|
"-----END CERTIFICATE-----",
|
||||||
|
);
|
||||||
|
let key_pem = key_pair.serialize_pem();
|
||||||
|
|
||||||
|
Ok((enrollment.ca0, cert_pem, key_pem))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn enroll_and_connect(
|
||||||
|
host: &str,
|
||||||
|
server_name: &str,
|
||||||
|
enroll_port: &str,
|
||||||
|
username: &str,
|
||||||
|
password: &str,
|
||||||
|
client_uid: &str,
|
||||||
|
) -> Result<TransportStream, String> {
|
||||||
|
let normalized_client_uid = if client_uid.trim().is_empty() {
|
||||||
|
format!("armatak-{}", Uuid::new_v4())
|
||||||
|
} else {
|
||||||
|
client_uid.trim().to_string()
|
||||||
|
};
|
||||||
|
info!(
|
||||||
|
"Starting enroll_and_connect for host={} enroll_port={} server_name={} client_uid={}",
|
||||||
|
host,
|
||||||
|
enroll_port,
|
||||||
|
server_name,
|
||||||
|
normalized_client_uid
|
||||||
|
);
|
||||||
|
|
||||||
|
let enrollment_config = fetch_enrollment_config(host, enroll_port)?;
|
||||||
|
let (ca_cert_pem, client_cert_pem, client_key_pem) = enroll_client_certificate(
|
||||||
|
host,
|
||||||
|
enroll_port,
|
||||||
|
&enrollment_config.enroll_path,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
&normalized_client_uid,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
connect_mtls_from_pem(
|
||||||
|
&format!("{}:{}", host.trim(), enrollment_config.server_port.trim()),
|
||||||
|
if server_name.trim().is_empty() {
|
||||||
|
host.trim()
|
||||||
|
} else {
|
||||||
|
server_name.trim()
|
||||||
|
},
|
||||||
|
&ca_cert_pem,
|
||||||
|
&client_cert_pem,
|
||||||
|
&client_key_pem,
|
||||||
|
)
|
||||||
|
}
|
||||||
5
src/tcp/tls/mod.rs
Normal file
5
src/tcp/tls/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
mod connector;
|
||||||
|
mod enrollment;
|
||||||
|
|
||||||
|
pub use connector::connect_mtls;
|
||||||
|
pub use enrollment::enroll_and_connect;
|
||||||
90
src/tcp/transport.rs
Normal file
90
src/tcp/transport.rs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
use log::info;
|
||||||
|
use rustls::{ClientConnection, StreamOwned};
|
||||||
|
use std::io::Write;
|
||||||
|
use std::net::{SocketAddr, TcpStream, ToSocketAddrs};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use super::config::ConnectionConfig;
|
||||||
|
use super::tls::{connect_mtls, enroll_and_connect};
|
||||||
|
|
||||||
|
const TCP_CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
const SOCKET_IO_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
|
||||||
|
pub enum TransportStream {
|
||||||
|
Plain(TcpStream),
|
||||||
|
Mtls(StreamOwned<ClientConnection, TcpStream>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TransportStream {
|
||||||
|
pub fn write_message(&mut self, message: &[u8]) -> Result<(), std::io::Error> {
|
||||||
|
match self {
|
||||||
|
Self::Plain(stream) => {
|
||||||
|
stream.write_all(message)?;
|
||||||
|
stream.flush()
|
||||||
|
}
|
||||||
|
Self::Mtls(stream) => {
|
||||||
|
stream.write_all(message)?;
|
||||||
|
stream.flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn connect_plain(address: &str) -> Result<TransportStream, String> {
|
||||||
|
let socket_addr: SocketAddr = address
|
||||||
|
.to_socket_addrs()
|
||||||
|
.map_err(|e| format!("failed to resolve {}: {}", address, e))?
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| format!("failed to resolve {}: no socket addresses returned", address))?;
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Opening plain TCP connection to {} (resolved={}) with timeout {:?}",
|
||||||
|
address, socket_addr, TCP_CONNECT_TIMEOUT
|
||||||
|
);
|
||||||
|
|
||||||
|
let stream = TcpStream::connect_timeout(&socket_addr, TCP_CONNECT_TIMEOUT)
|
||||||
|
.map_err(|e| format!("failed to connect to {}: {}", address, e))?;
|
||||||
|
stream
|
||||||
|
.set_read_timeout(Some(SOCKET_IO_TIMEOUT))
|
||||||
|
.map_err(|e| format!("failed to set read timeout on {}: {}", address, e))?;
|
||||||
|
stream
|
||||||
|
.set_write_timeout(Some(SOCKET_IO_TIMEOUT))
|
||||||
|
.map_err(|e| format!("failed to set write timeout on {}: {}", address, e))?;
|
||||||
|
|
||||||
|
Ok(TransportStream::Plain(stream))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect_stream(config: &ConnectionConfig) -> Result<TransportStream, String> {
|
||||||
|
info!("connect_stream invoked for {}", config.describe());
|
||||||
|
match config {
|
||||||
|
ConnectionConfig::Plain { address } => connect_plain(address),
|
||||||
|
ConnectionConfig::Mtls {
|
||||||
|
address,
|
||||||
|
server_name,
|
||||||
|
ca_cert_path,
|
||||||
|
client_cert_path,
|
||||||
|
client_key_path,
|
||||||
|
} => connect_mtls(
|
||||||
|
address,
|
||||||
|
server_name,
|
||||||
|
ca_cert_path,
|
||||||
|
client_cert_path,
|
||||||
|
client_key_path,
|
||||||
|
),
|
||||||
|
ConnectionConfig::EnrollMtls {
|
||||||
|
host,
|
||||||
|
server_name,
|
||||||
|
enroll_port,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
client_uid,
|
||||||
|
} => enroll_and_connect(
|
||||||
|
host,
|
||||||
|
server_name,
|
||||||
|
enroll_port,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
client_uid,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
use arma_rs::Context;
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use log::info;
|
|
||||||
use std::io::Write;
|
|
||||||
use std::net::TcpStream;
|
|
||||||
use std::sync::mpsc::{self, Receiver, Sender};
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use std::thread;
|
|
||||||
|
|
||||||
use crate::cot;
|
|
||||||
|
|
||||||
pub enum TcpCommand {
|
|
||||||
SendMessage(String, Context),
|
|
||||||
Stop,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TcpClient {
|
|
||||||
pub(crate) tx: Sender<TcpCommand>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TcpClient {
|
|
||||||
pub fn start(&self, address: String, rx: Receiver<TcpCommand>, ctx: Context) {
|
|
||||||
if let Some(ref client) = *TCP_CLIENT.lock().unwrap() {
|
|
||||||
client.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
let connection = Arc::new(Mutex::new(None));
|
|
||||||
let connection_clone = Arc::clone(&connection);
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
let mut running = true;
|
|
||||||
|
|
||||||
let tcp_thread = thread::spawn(move || match TcpStream::connect(&address) {
|
|
||||||
Ok(stream) => {
|
|
||||||
let _ = ctx.callback_data("TCP SOCKET", "Connected to TCP Server", address);
|
|
||||||
*connection_clone.lock().unwrap() = Some(stream);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
let _ = ctx.callback_data(
|
|
||||||
"TCP SOCKET ERROR",
|
|
||||||
"TAK Socket connection failed",
|
|
||||||
e.to_string(),
|
|
||||||
);
|
|
||||||
info!("Failed to connect to TCP server: {}", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
while running {
|
|
||||||
match rx.recv() {
|
|
||||||
Ok(TcpCommand::SendMessage(message, context)) => {
|
|
||||||
if let Some(mut stream) = connection.lock().unwrap().as_ref() {
|
|
||||||
if let Err(e) = stream.write_all(message.as_bytes()) {
|
|
||||||
info!("Failed to send message: {}", e);
|
|
||||||
|
|
||||||
let _ = context.callback_data(
|
|
||||||
"TCP SOCKET ERROR",
|
|
||||||
"TAK Socket disconnected",
|
|
||||||
e.to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
running = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let _ = context.callback_null(
|
|
||||||
"TCP SOCKET ERROR",
|
|
||||||
"TAK Socket is not active",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(TcpCommand::Stop) => {
|
|
||||||
running = false;
|
|
||||||
info!("Stopping TCP client.");
|
|
||||||
}
|
|
||||||
Err(error) => {
|
|
||||||
info!("Error receiving command: {}", error.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tcp_thread.join().unwrap();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_payload(&self, context: Context, payload: String) {
|
|
||||||
let tx = self.tx.clone();
|
|
||||||
thread::spawn(move || {
|
|
||||||
tx.send(TcpCommand::SendMessage(payload, context)).unwrap();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn stop(&self) {
|
|
||||||
let tx = self.tx.clone();
|
|
||||||
thread::spawn(move || {
|
|
||||||
tx.send(TcpCommand::Stop).unwrap();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
static ref TCP_CLIENT: Arc<Mutex<Option<TcpClient>>> = Arc::new(Mutex::new(None));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn start(ctx: Context, address: String) -> &'static str {
|
|
||||||
let (tx, rx): (Sender<TcpCommand>, Receiver<TcpCommand>) = mpsc::channel();
|
|
||||||
|
|
||||||
let client = TcpClient { tx };
|
|
||||||
client.start(address, rx, ctx);
|
|
||||||
|
|
||||||
let mut client_guard = TCP_CLIENT.lock().unwrap();
|
|
||||||
*client_guard = Some(client);
|
|
||||||
|
|
||||||
"Starting TCP Client"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_payload(ctx: Context, payload: String) -> &'static str {
|
|
||||||
if let Some(ref client) = *TCP_CLIENT.lock().unwrap() {
|
|
||||||
client.send_payload(ctx, payload);
|
|
||||||
} else {
|
|
||||||
let _ = ctx.callback_null("TCP SOCKET ERROR", "TCP Client is not running");
|
|
||||||
info!("TCP client is not running.");
|
|
||||||
}
|
|
||||||
|
|
||||||
"Sending payload to TCP server"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_eud_cot(ctx: Context, cursor_over_time: cot::eud::EudCoTPayload) -> &'static str {
|
|
||||||
let payload = cursor_over_time.to_cot().convert_to_xml();
|
|
||||||
send_payload(ctx, payload);
|
|
||||||
|
|
||||||
"Sending End User Device Cursor Over Time to TCP server"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_marker_cot(ctx: Context, cursor_over_time: cot::nato::MarkerCoTPayload) -> &'static str {
|
|
||||||
let payload = cursor_over_time.to_cot().convert_to_xml();
|
|
||||||
send_payload(ctx, payload);
|
|
||||||
|
|
||||||
"Sending Marker Cursor Over Time to TCP server"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_digital_pointer_cot(ctx: Context, cursor_over_time: cot::digital_pointer::DigitalPointerPayload) -> &'static str {
|
|
||||||
let payload = cursor_over_time.to_cot().convert_to_xml();
|
|
||||||
send_payload(ctx, payload);
|
|
||||||
|
|
||||||
"Sending Digital Pointer Cursor Over Time to TCP server"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn stop(ctx: Context) -> &'static str {
|
|
||||||
if let Some(ref client) = *TCP_CLIENT.lock().unwrap() {
|
|
||||||
client.stop();
|
|
||||||
let _ = ctx.callback_null("TCP SOCKET", "TCP client stopped");
|
|
||||||
} else {
|
|
||||||
let _ = ctx.callback_null("TCP SOCKET ERROR", "TCP client is not running");
|
|
||||||
}
|
|
||||||
|
|
||||||
"Stopping TCP Client"
|
|
||||||
}
|
|
||||||
34
src/tests.rs
34
src/tests.rs
@@ -1,25 +1,25 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::init;
|
use crate::init;
|
||||||
use uuid::Uuid;
|
use std::vec;
|
||||||
use std::vec;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uuid_output_is_uuid4_identifier() {
|
fn uuid_output_is_uuid4_identifier() {
|
||||||
let extension = init().testing();
|
let extension = init().testing();
|
||||||
let (output, _) = extension.call("uuid", None);
|
let (output, _) = extension.call("uuid", None);
|
||||||
|
|
||||||
let validation = Uuid::parse_str(&output);
|
let validation = Uuid::parse_str(&output);
|
||||||
|
|
||||||
assert!(validation.is_ok())
|
assert!(validation.is_ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uuid_output_throws_if_passed_args() {
|
fn uuid_output_throws_if_passed_args() {
|
||||||
let extension = init().testing();
|
let extension = init().testing();
|
||||||
let args: Vec<String> = vec![1.to_string(),2.to_string()];
|
let args: Vec<String> = vec![1.to_string(), 2.to_string()];
|
||||||
let (output, _) = extension.call("uuid", Some(args));
|
let (output, _) = extension.call("uuid", Some(args));
|
||||||
|
|
||||||
assert_eq!(output,"")
|
assert_eq!(output, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,116 +9,119 @@ use std::thread;
|
|||||||
use crate::cot;
|
use crate::cot;
|
||||||
|
|
||||||
pub enum UdpCommand {
|
pub enum UdpCommand {
|
||||||
SendMessage(String, Context),
|
SendMessage(String, Context),
|
||||||
Stop,
|
Stop,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UdpClient {
|
pub struct UdpClient {
|
||||||
pub(crate) tx: Sender<UdpCommand>,
|
pub(crate) tx: Sender<UdpCommand>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UdpClient {
|
impl UdpClient {
|
||||||
pub fn start(&self, address: String, rx: Receiver<UdpCommand>, ctx: Context) {
|
pub fn start(&self, address: String, rx: Receiver<UdpCommand>, ctx: Context) {
|
||||||
if let Some(ref client) = *UDP_CLIENT.lock().unwrap() {
|
if let Some(ref client) = *UDP_CLIENT.lock().unwrap() {
|
||||||
client.stop();
|
client.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
thread::spawn(move || {
|
||||||
|
let socket = match UdpSocket::bind("0.0.0.0:0") {
|
||||||
|
Ok(s) => s,
|
||||||
|
Err(e) => {
|
||||||
|
let _ = ctx.callback_data(
|
||||||
|
"UDP SOCKET ERROR",
|
||||||
|
"Failed to bind UDP socket",
|
||||||
|
e.to_string(),
|
||||||
|
);
|
||||||
|
info!("Failed to bind UDP socket: {}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = ctx.callback_data("UDP SOCKET", "EUD Connected", address.clone());
|
||||||
|
|
||||||
|
let mut running = true;
|
||||||
|
while running {
|
||||||
|
match rx.recv() {
|
||||||
|
Ok(UdpCommand::SendMessage(message, context)) => {
|
||||||
|
if let Err(e) = socket.send_to(message.as_bytes(), &address) {
|
||||||
|
info!("Failed to send UDP message: {}", e);
|
||||||
|
let _ = context.callback_data(
|
||||||
|
"UDP SOCKET ERROR",
|
||||||
|
"Failed to send UDP message",
|
||||||
|
e.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(UdpCommand::Stop) => {
|
||||||
|
running = false;
|
||||||
|
info!("Stopping UDP client.");
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
info!("Error receiving command: {}", error.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
thread::spawn(move || {
|
pub fn send_payload(&self, context: Context, payload: String) {
|
||||||
let socket = match UdpSocket::bind("0.0.0.0:0") {
|
let tx = self.tx.clone();
|
||||||
Ok(s) => s,
|
thread::spawn(move || {
|
||||||
Err(e) => {
|
tx.send(UdpCommand::SendMessage(payload, context)).unwrap();
|
||||||
let _ = ctx.callback_data(
|
});
|
||||||
"UDP SOCKET ERROR",
|
}
|
||||||
"Failed to bind UDP socket",
|
|
||||||
e.to_string(),
|
|
||||||
);
|
|
||||||
info!("Failed to bind UDP socket: {}", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let _ = ctx.callback_data("UDP SOCKET", "EUD Connected", address.clone());
|
pub fn stop(&self) {
|
||||||
|
let tx = self.tx.clone();
|
||||||
let mut running = true;
|
thread::spawn(move || {
|
||||||
while running {
|
tx.send(UdpCommand::Stop).unwrap();
|
||||||
match rx.recv() {
|
});
|
||||||
Ok(UdpCommand::SendMessage(message, context)) => {
|
}
|
||||||
if let Err(e) = socket.send_to(message.as_bytes(), &address) {
|
|
||||||
info!("Failed to send UDP message: {}", e);
|
|
||||||
let _ = context.callback_data(
|
|
||||||
"UDP SOCKET ERROR",
|
|
||||||
"Failed to send UDP message",
|
|
||||||
e.to_string(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(UdpCommand::Stop) => {
|
|
||||||
running = false;
|
|
||||||
info!("Stopping UDP client.");
|
|
||||||
}
|
|
||||||
Err(error) => {
|
|
||||||
info!("Error receiving command: {}", error.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_payload(&self, context: Context, payload: String) {
|
|
||||||
let tx = self.tx.clone();
|
|
||||||
thread::spawn(move || {
|
|
||||||
tx.send(UdpCommand::SendMessage(payload, context)).unwrap();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn stop(&self) {
|
|
||||||
let tx = self.tx.clone();
|
|
||||||
thread::spawn(move || {
|
|
||||||
tx.send(UdpCommand::Stop).unwrap();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref UDP_CLIENT: Arc<Mutex<Option<UdpClient>>> = Arc::new(Mutex::new(None));
|
static ref UDP_CLIENT: Arc<Mutex<Option<UdpClient>>> = Arc::new(Mutex::new(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(ctx: Context, address: String) -> &'static str {
|
pub fn start(ctx: Context, address: String) -> &'static str {
|
||||||
let (tx, rx): (Sender<UdpCommand>, Receiver<UdpCommand>) = mpsc::channel();
|
let (tx, rx): (Sender<UdpCommand>, Receiver<UdpCommand>) = mpsc::channel();
|
||||||
|
|
||||||
let client = UdpClient { tx };
|
let client = UdpClient { tx };
|
||||||
client.start(address, rx, ctx);
|
client.start(address, rx, ctx);
|
||||||
|
|
||||||
let mut client_guard = UDP_CLIENT.lock().unwrap();
|
let mut client_guard = UDP_CLIENT.lock().unwrap();
|
||||||
*client_guard = Some(client);
|
*client_guard = Some(client);
|
||||||
|
|
||||||
"Starting UDP Client"
|
"Starting UDP Client"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_payload(ctx: Context, payload: String) -> &'static str {
|
pub fn send_payload(ctx: Context, payload: String) -> &'static str {
|
||||||
if let Some(ref client) = *UDP_CLIENT.lock().unwrap() {
|
if let Some(ref client) = *UDP_CLIENT.lock().unwrap() {
|
||||||
client.send_payload(ctx, payload);
|
client.send_payload(ctx, payload);
|
||||||
} else {
|
} else {
|
||||||
let _ = ctx.callback_null("UDP SOCKET ERROR", "UDP Socket is not running");
|
let _ = ctx.callback_null("UDP SOCKET ERROR", "UDP Socket is not running");
|
||||||
}
|
}
|
||||||
|
|
||||||
"Sending payload to UDP server"
|
"Sending payload to UDP server"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_gps_cot(ctx: Context, cursor_over_time: cot::gps::ExternalPositionPayload) -> &'static str {
|
pub fn send_gps_cot(
|
||||||
let payload = cursor_over_time.to_cot().convert_to_xml();
|
ctx: Context,
|
||||||
send_payload(ctx, payload);
|
cursor_over_time: cot::gps::ExternalPositionPayload,
|
||||||
|
) -> &'static str {
|
||||||
|
let payload = cursor_over_time.to_cot().convert_to_xml();
|
||||||
|
send_payload(ctx, payload);
|
||||||
|
|
||||||
"Sending GPS Cursor Over Time to UDP server"
|
"Sending GPS Cursor Over Time to UDP server"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop(ctx: Context) -> &'static str {
|
pub fn stop(ctx: Context) -> &'static str {
|
||||||
if let Some(ref client) = *UDP_CLIENT.lock().unwrap() {
|
if let Some(ref client) = *UDP_CLIENT.lock().unwrap() {
|
||||||
client.stop();
|
client.stop();
|
||||||
let _ = ctx.callback_null("UDP SOCKET", "EUD Disconnected");
|
let _ = ctx.callback_null("UDP SOCKET", "EUD Disconnected");
|
||||||
} else {
|
} else {
|
||||||
let _ = ctx.callback_null("UDP SOCKET ERROR", "UDP Socket is not running");
|
let _ = ctx.callback_null("UDP SOCKET ERROR", "UDP Socket is not running");
|
||||||
}
|
}
|
||||||
|
|
||||||
"Stopping UDP Client"
|
"Stopping UDP Client"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
use std::net::{IpAddr, UdpSocket};
|
use std::net::{IpAddr, UdpSocket};
|
||||||
|
|
||||||
pub fn get_local_address() -> String {
|
pub fn get_local_address() -> String {
|
||||||
fn get_local_ip() -> Result<IpAddr, String> {
|
fn get_local_ip() -> Result<IpAddr, String> {
|
||||||
let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| e.to_string())?;
|
let socket = UdpSocket::bind("0.0.0.0:0").map_err(|e| e.to_string())?;
|
||||||
socket.connect("8.8.8.8:80").map_err(|e| e.to_string())?;
|
socket.connect("8.8.8.8:80").map_err(|e| e.to_string())?;
|
||||||
socket
|
socket
|
||||||
.local_addr()
|
.local_addr()
|
||||||
.map(|addr| addr.ip())
|
.map(|addr| addr.ip())
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
let parsed_data = get_local_ip();
|
let parsed_data = get_local_ip();
|
||||||
|
|
||||||
match parsed_data {
|
match parsed_data {
|
||||||
Ok(ip) => {
|
Ok(ip) => {
|
||||||
return format!("ws://{}:4152", ip.to_string());
|
return format!("ws://{}:4152", ip.to_string());
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
return "not provided".to_string();
|
return "not provided".to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ use crate::structs::LogPayload;
|
|||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
|
|
||||||
pub fn log_info(data: LogPayload) -> String {
|
pub fn log_info(data: LogPayload) -> String {
|
||||||
match data.status.as_str() {
|
match data.status.as_str() {
|
||||||
"info" => info!("{}", data.message),
|
"info" => info!("{}", data.message),
|
||||||
"warn" => warn!("{}", data.message),
|
"warn" => warn!("{}", data.message),
|
||||||
"error" => error!("{}", data.message),
|
"error" => error!("{}", data.message),
|
||||||
_ => error!("{}", "Wrong log call"),
|
_ => error!("{}", "Wrong log call"),
|
||||||
}
|
}
|
||||||
"logged".to_string()
|
"logged".to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
pub mod uuid;
|
|
||||||
pub mod address;
|
pub mod address;
|
||||||
pub mod log;
|
pub mod log;
|
||||||
|
pub mod uuid;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
pub fn get_uuid() -> String {
|
pub fn get_uuid() -> String {
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
let id = Uuid::new_v4().to_string();
|
let id = Uuid::new_v4().to_string();
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,13 @@ lazy_static! {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
|
||||||
fn build_rtsp_url(address: &str, port: &str, stream_path: &str, username: &str, password: &str) -> String {
|
fn build_rtsp_url(
|
||||||
|
address: &str,
|
||||||
|
port: &str,
|
||||||
|
stream_path: &str,
|
||||||
|
username: &str,
|
||||||
|
password: &str,
|
||||||
|
) -> String {
|
||||||
if username.is_empty() || password.is_empty() {
|
if username.is_empty() || password.is_empty() {
|
||||||
format!("rtsp://{}:{}/{}", address, port, stream_path)
|
format!("rtsp://{}:{}/{}", address, port, stream_path)
|
||||||
} else {
|
} else {
|
||||||
@@ -28,20 +34,22 @@ fn build_rtsp_url(address: &str, port: &str, stream_path: &str, username: &str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||||
fn spawn_ffmpeg(
|
fn spawn_ffmpeg(rtsp_url: String, stop_rx: Receiver<()>, status_tx: Sender<Result<(), String>>) {
|
||||||
rtsp_url: String,
|
|
||||||
stop_rx: Receiver<()>,
|
|
||||||
status_tx: Sender<Result<(), String>>,
|
|
||||||
) {
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut cmd = Command::new("ffmpeg");
|
let mut cmd = Command::new("ffmpeg");
|
||||||
cmd.args(&[
|
cmd.args(&[
|
||||||
"-f","x11grab",
|
"-f",
|
||||||
"-framerate","30",
|
"x11grab",
|
||||||
"-video_size","1920x1080",
|
"-framerate",
|
||||||
"-i" ,":0",
|
"30",
|
||||||
"-f","rtsp",
|
"-video_size",
|
||||||
"-rtsp_transport","tcp",
|
"1920x1080",
|
||||||
|
"-i",
|
||||||
|
":0",
|
||||||
|
"-f",
|
||||||
|
"rtsp",
|
||||||
|
"-rtsp_transport",
|
||||||
|
"tcp",
|
||||||
&rtsp_url,
|
&rtsp_url,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user