mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-11-07 06:39:10 +08:00
[refactor] adopt MiniRtc API naming across clients
This commit is contained in:
@@ -287,7 +287,7 @@ Session* From(jlong handle) { return reinterpret_cast<Session*>(handle); }
|
||||
|
||||
extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* java_vm, void*) {
|
||||
vm = java_vm;
|
||||
if (SetMiniRtcAndroidJavaVm(java_vm) != 0) return JNI_ERR;
|
||||
if (MiniRtcSetAndroidJavaVm(java_vm) != 0) return JNI_ERR;
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
#define JNI_METHOD(name) Java_cn_crossdesk_mobile_NativeSession_##name
|
||||
@@ -341,7 +341,7 @@ extern "C" JNIEXPORT jlong JNICALL JNI_METHOD(nCreate)(
|
||||
throw std::runtime_error("Unable to configure Android trust bundle");
|
||||
// MiniRTC's diagnostic log includes login identities. Keep credentials
|
||||
// solely in Keystore-backed storage; do not persist its session logging.
|
||||
if (ConfigureMiniRtcLogging(MiniRtcLogOff, nullptr, nullptr) != 0)
|
||||
if (MiniRtcConfigureLogging(MiniRtcLogOff, nullptr, nullptr) != 0)
|
||||
throw std::runtime_error("Unable to configure MiniRTC logging");
|
||||
auto params = Parameters(s.get(), false);
|
||||
s->identity = CreatePeer(¶ms);
|
||||
|
||||
@@ -350,7 +350,7 @@ int ConfigCenter::SetForceRelay(bool force_relay) {
|
||||
|
||||
int ConfigCenter::SetServerHost(const std::string& host) {
|
||||
MiniRtcSignalServerAddress address{};
|
||||
if (ParseMiniRtcSignalServerAddress(host.data(), host.size(), &address) != 0) return -1;
|
||||
if (MiniRtcParseSignalServerAddress(host.data(), host.size(), &address) != 0) return -1;
|
||||
if (address.port) return SetServerEndpoint(host, address.port);
|
||||
const auto normalized = std::string(address.host) + address.target;
|
||||
if (StoreValues({{"signal_server_host", normalized}}) != 0) return -1;
|
||||
@@ -360,7 +360,7 @@ int ConfigCenter::SetServerHost(const std::string& host) {
|
||||
|
||||
int ConfigCenter::SetServerEndpoint(const std::string& host, int port) {
|
||||
MiniRtcSignalServerAddress address{};
|
||||
if (ParseMiniRtcSignalServerAddress(host.data(), host.size(), &address) != 0) return -1;
|
||||
if (MiniRtcParseSignalServerAddress(host.data(), host.size(), &address) != 0) return -1;
|
||||
if (address.port) port = address.port;
|
||||
if (port < 1 || port > 65535) return -1;
|
||||
const auto normalized = std::string(address.host) + address.target;
|
||||
|
||||
@@ -4784,7 +4784,7 @@ bool GuiApplication::ValidateSelfHostedSettingsFromUi(bool gallery_window) {
|
||||
auto& main = ui_->Window(gallery_window);
|
||||
const auto input = std::string(main->get_server_host());
|
||||
MiniRtcSignalServerAddress address{};
|
||||
if (ParseMiniRtcSignalServerAddress(input.data(), input.size(), &address) != 0) {
|
||||
if (MiniRtcParseSignalServerAddress(input.data(), input.size(), &address) != 0) {
|
||||
main->set_self_host_settings_error(UiText(
|
||||
localization::self_hosted_address_invalid[localization_language_index_]));
|
||||
return false;
|
||||
|
||||
@@ -54,7 +54,7 @@ void AnnouncementInbox::Configure(std::string host, int port,
|
||||
if (directory_.empty() || host.empty() || port <= 0 || device_id.empty())
|
||||
return;
|
||||
MiniRtcSignalServerAddress address{};
|
||||
if (ParseMiniRtcSignalServerAddress(host.data(), host.size(), &address) != 0) return;
|
||||
if (MiniRtcParseSignalServerAddress(host.data(), host.size(), &address) != 0) return;
|
||||
std::string normalized_host(address.host);
|
||||
for (auto& ch : normalized_host)
|
||||
if (ch >= 'A' && ch <= 'Z') ch += 'a' - 'A';
|
||||
|
||||
@@ -36,7 +36,7 @@ class ConnectionAuthState {
|
||||
void Rejected(const nlohmann::json& reply,
|
||||
Clock::time_point now = Clock::now()) {
|
||||
const auto message = reply.dump();
|
||||
const auto failure = ParseMiniRtcJoinFailure(message.data(), message.size());
|
||||
const auto failure = MiniRtcParseJoinFailure(message.data(), message.size());
|
||||
std::lock_guard lock(mutex_);
|
||||
state_ = {};
|
||||
state_.error = failure.kind;
|
||||
|
||||
@@ -213,11 +213,11 @@ unsigned ParsePort(const std::string& value) {
|
||||
}
|
||||
bool IsIpAddress(const std::string& value) {
|
||||
char normalized[129]{};
|
||||
return NormalizeMiniRtcDirectAddress(value.data(), value.size(), normalized, sizeof(normalized)) == 0;
|
||||
return MiniRtcNormalizeDirectAddress(value.data(), value.size(), normalized, sizeof(normalized)) == 0;
|
||||
}
|
||||
std::string NormalizeAddress(const std::string& value) {
|
||||
char normalized[129]{};
|
||||
Require(NormalizeMiniRtcDirectAddress(value.data(), value.size(), normalized, sizeof(normalized)) == 0,
|
||||
Require(MiniRtcNormalizeDirectAddress(value.data(), value.size(), normalized, sizeof(normalized)) == 0,
|
||||
"Invalid LAN endpoint");
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ struct Transport::Impl {
|
||||
c->local_address = SocketAddress(local.address());
|
||||
c->remote_address = SocketAddress(remote.address());
|
||||
const auto interfaces = LocalIpInterfaces();
|
||||
if (IsMiniRtcDirectAddressPair(c->local_address.data(), c->local_address.size(),
|
||||
if (MiniRtcIsDirectAddressPair(c->local_address.data(), c->local_address.size(),
|
||||
c->remote_address.data(), c->remote_address.size()) != 1 ||
|
||||
std::none_of(
|
||||
interfaces.begin(), interfaces.end(),
|
||||
|
||||
@@ -89,7 +89,7 @@ SettingResult ApplyConsoleSetting(ConfigCenter& config, const std::string& key,
|
||||
save = [&config, mode] { return config.SetTurnMode(static_cast<ConfigCenter::TURN_MODE>(mode)); };
|
||||
} else if (key == "server_host") {
|
||||
MiniRtcSignalServerAddress address{};
|
||||
if (ParseMiniRtcSignalServerAddress(input.data(), input.size(), &address) != 0) return result;
|
||||
if (MiniRtcParseSignalServerAddress(input.data(), input.size(), &address) != 0) return result;
|
||||
save = [&] { return config.SetServerHost(input); };
|
||||
} else if (key == "server_port") {
|
||||
int port = 0;
|
||||
|
||||
@@ -257,7 +257,7 @@ class MobileSession {
|
||||
if (server_.empty()||server_.size()>=256||server_.find('@')!=std::string::npos||port_<1||port_>65535||
|
||||
logs_.size()>=256||roots.empty()||directory_.empty()) throw std::runtime_error("Invalid configuration");
|
||||
setenv("SSL_CERT_DIR",roots.c_str(),1);
|
||||
if (ConfigureMiniRtcLogging(MiniRtcLogOff, nullptr, nullptr) != 0)
|
||||
if (MiniRtcConfigureLogging(MiniRtcLogOff, nullptr, nullptr) != 0)
|
||||
throw std::runtime_error("Unable to configure MiniRTC logging");
|
||||
identity_context_=std::make_unique<Context>(Context{this,false,session_});
|
||||
auto p=Parameters(false); identity_=CreatePeer(&p); signal_started_=Clock::now();
|
||||
|
||||
Vendored
+1
-1
Submodule deps/submodules/minirtc updated: 25ae240374...903d7a06cc
@@ -88,7 +88,7 @@ struct Diagnostics {
|
||||
std::shared_ptr<DiagnosticWriter> writer;
|
||||
~Diagnostics() {
|
||||
// Quiesce the callback before releasing its application-owned context.
|
||||
ConfigureMiniRtcLogging(MiniRtcLogOff, nullptr, nullptr);
|
||||
MiniRtcConfigureLogging(MiniRtcLogOff, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
Diagnostics &State() {
|
||||
@@ -101,7 +101,7 @@ void InitializeControllerDiagnostics(const std::string &directory) {
|
||||
auto &state = State();
|
||||
std::lock_guard initialize(state.initialization);
|
||||
auto writer = std::make_shared<DiagnosticWriter>(directory);
|
||||
if (ConfigureMiniRtcLogging(MiniRtcLogInfo, ReceiveLog, writer.get()) != 0)
|
||||
if (MiniRtcConfigureLogging(MiniRtcLogInfo, ReceiveLog, writer.get()) != 0)
|
||||
throw std::runtime_error("Unable to configure MiniRTC diagnostics");
|
||||
std::lock_guard lock(state.mutex);
|
||||
state.writer = std::move(writer);
|
||||
|
||||
Reference in New Issue
Block a user