#data #multicast #publisher #key #stream #tak-server #cot

cot_publisher

Cursor On Target (COT) Publisher,用于组播或TakServer数据流

1次发布 (0个不稳定版)

1.0.0-rc.12023年5月29日

#10#publisher

MIT 许可证

21KB
417

用于组播和流数据接口(TakServer)的Cursor-On-Target生成器。

TakServer设置

添加一个新的流数据字段,转到 配置 -> 输入和数据馈送 -> 添加流数据馈送

为接口命名,并选择 安全流 TCP (TLS) CoT或Protobuf 作为协议。选择一个端口并选择 保存

在TakServer UI中创建一个用户,然后在takserver控制台中使用makeCert脚本

cd /opt/tak/certs
sh -c "source ./makeCert.sh client [username]"

(将[username]替换为刚刚创建的用户)

用户的关键和证书将位于 /opt/tag/cert/files 目录中。

TakServer生成的用户密钥受 atakatak 密码保护,可以使用以下方法删除

openssl rsa -in user.key -out user-nopass.key

示例 - 仅组播

let mut publisher = CotPublisher::new(
    "test-uid-1234",
    "a-f-G-U-C",
    Some("239.2.3.1:6969"),
    None,
);
publisher.publish();

示例 - 使用文件中的TLS凭证的TakServer流

let mut publisher = CotPublisher::new(
    "test-uid-1234",
    "a-f-G-U-C",
    None,
    Some(("192.168.0.2", 9000)),
);

let ca_file = "[path_to]/truststore-intermediate-CA.pem";
let client_cert = "[path_to]/user.pem";
let client_key = "[path_to]/user-nopass.key";

publisher.set_tak_server_tls_settings(Some(TakServerSettings {
    tls: true,
    client_key: PEM::File(client_key.into()),
    client_cert: PEM::File(client_cert.into()),
    root_cert: PEM::File(ca_file.into()),
    ignore_invalid: false,
    verify_hostname: false,
}));

publisher.connect();
publisher.publish();

// Required if `publisher` is dropped to ensure message is actually sent
//std::thread::sleep(std::time::Duration::from_millis(100));

示例 - 使用字符串中的TLS凭证的TakServer流

let mut publisher = CotPublisher::new(
    "test-uid-1234",
    "a-f-G-U-C",
    None,
    Some(("192.168.0.2", 9000)),
);

let ca_file = r#"
Bag Attributes
    friendlyName: intermediate-CA
subject=C = US, ST = STATE, L = CITY, O = TAK, OU = ORG_UNIT, CN = intermediate-CA
issuer=C = US, ST = STATE, L = CITY, O = TAK, OU = ORG_UNIT, CN = takserver-CA
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
        "#;

let key = r#"
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
"#;

let cert = r#"
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
"#;

publisher.set_tak_server_tls_settings(Some(TakServerSettings {
    tls: true,
    client_key: PEM::String(key.into()),
    client_cert: PEM::String(cert.into()),
    root_cert: PEM::String(ca_file_content.into()),
    ignore_invalid: false,
    verify_hostname: false,
}));

publisher.connect();
publisher.publish();

// Required if `publisher` is dropped to ensure message is actually sent
//std::thread::sleep(std::time::Duration::from_millis(100));

示例 - 设置位置


let mut publisher = CotPublisher::new(
    "test-uid-1234",
    "a-f-G-U-C",
    Some("239.2.3.1:6969"),
    None,
);

publisher.set_contact(Some("MYTHING"), None);
publisher.set_position(10.0, 10.0);
publisher.set_xml_detail(Some("<custom somekey='somevalue'/>"));
publisher.publish();

依赖项

~3.5–6.5MB
~115K SLoC