feat: api2.oneme.ru с корнем Минцифры; kolibri с pub.dev вместо сабмодуля
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
abstract class ServerConfig {
|
||||
static const String defaultHost = 'api.oneme.ru';
|
||||
static const String defaultHost = 'api2.oneme.ru';
|
||||
static const int defaultPort = 443;
|
||||
static const bool defaultTrustMincifryCa = true;
|
||||
static const String prefHostKey = 'server_host_override';
|
||||
static const String prefPortKey = 'server_port_override';
|
||||
static const String prefTrustMincifryKey = 'server_trust_mincifry_ca';
|
||||
static const Duration pingInterval = Duration(seconds: 10);
|
||||
static const Duration requestTimeout = Duration(seconds: 30);
|
||||
static const int maxReconnectAttempts = 50;
|
||||
|
||||
static Future<({String host, int port})> loadEndpoint() async {
|
||||
static Future<({String host, int port, bool trustMincifryCa})>
|
||||
loadEndpoint() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final rawHost = prefs.getString(prefHostKey);
|
||||
final rawPort = prefs.getInt(prefPortKey);
|
||||
@@ -20,6 +23,11 @@ abstract class ServerConfig {
|
||||
if (rawPort != null && rawPort >= 1 && rawPort <= 65535) {
|
||||
port = rawPort;
|
||||
}
|
||||
return (host: host, port: port);
|
||||
return (
|
||||
host: host,
|
||||
port: port,
|
||||
trustMincifryCa:
|
||||
prefs.getBool(prefTrustMincifryKey) ?? defaultTrustMincifryCa,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../calls/ws2_signaling.dart';
|
||||
import '../protocol/opcode_map.dart';
|
||||
import '../storage/app_instance.dart';
|
||||
import '../storage/token_storage.dart';
|
||||
import '../transport/tls_config.dart';
|
||||
import '../utils/logger.dart';
|
||||
|
||||
const _channelId = 'komet_messages';
|
||||
@@ -56,6 +57,7 @@ Future<void> _handleCallDecline(String payloadJson) async {
|
||||
|
||||
// Фоновый изолят: инициализируем ядро перед vcp-декодом/сигналингом.
|
||||
await initKolibri();
|
||||
await TlsConfig.applyMincifryTrust();
|
||||
|
||||
final params = ConversationParams.decode(vcp);
|
||||
if (params == null) return;
|
||||
@@ -93,6 +95,7 @@ Future<void> _handleReply(String payloadJson, String text) async {
|
||||
SharedPreferences.setPrefix('flutter.${AppInstance.id}.');
|
||||
} catch (_) {}
|
||||
}
|
||||
await TlsConfig.applyMincifryTrust();
|
||||
|
||||
final plugin = FlutterLocalNotificationsPlugin();
|
||||
final notifId = chatId & 0x7fffffff;
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
import 'package:kolibri/kolibri.dart' show setTrustMincifryCa;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../config/config.dart';
|
||||
|
||||
abstract class TlsConfig {
|
||||
static const String prefKey = 'dev_tls_insecure';
|
||||
|
||||
static Future<void> applyMincifryTrust() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setTrustMincifryCa(
|
||||
enabled:
|
||||
prefs.getBool(ServerConfig.prefTrustMincifryKey) ??
|
||||
ServerConfig.defaultTrustMincifryCa,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<bool> isInsecureAllowed() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getBool(prefKey) ?? false;
|
||||
|
||||
Reference in New Issue
Block a user