mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-26 18:56:38 +00:00
update
This commit is contained in:
parent
0a99be6103
commit
9fe307b7e7
|
@ -58,57 +58,43 @@ class CloudflareApi extends ApiMap {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> createMultipleDnsRecords({
|
||||
Future<void> removeSimilarRecords({
|
||||
String ip4,
|
||||
CloudFlareDomain cloudFlareDomain,
|
||||
}) async {
|
||||
var domainName = cloudFlareDomain.domainName;
|
||||
var domainZoneId = cloudFlareDomain.zoneId;
|
||||
|
||||
var domainA = DnsRecords(type: 'A', name: domainName, content: ip4);
|
||||
var apiA = DnsRecords(type: 'A', name: 'api', content: ip4);
|
||||
var cloudA = DnsRecords(type: 'A', name: 'cloud', content: ip4);
|
||||
var gitA = DnsRecords(type: 'A', name: 'git', content: ip4);
|
||||
var meetA = DnsRecords(type: 'A', name: 'meet', content: ip4);
|
||||
var passwordA = DnsRecords(type: 'A', name: 'password', content: ip4);
|
||||
var socialA = DnsRecords(type: 'A', name: 'social', content: ip4);
|
||||
var mx = DnsRecords(type: 'MX', name: '@', content: domainName);
|
||||
var vpn = DnsRecords(type: 'A', name: 'vpn', content: ip4);
|
||||
var url = '$rootAddress/zones/$domainZoneId/dns_records';
|
||||
|
||||
var txt1 = DnsRecords(
|
||||
type: 'TXT',
|
||||
name: '_dmarc',
|
||||
content: 'v=DMARC1; p=none',
|
||||
ttl: 18000,
|
||||
);
|
||||
var response = await loggedClient.get(url);
|
||||
List records = response.data['result'] ?? [];
|
||||
var allDeleteFutures = <Future>[];
|
||||
|
||||
var txt2 = DnsRecords(
|
||||
type: 'TXT',
|
||||
name: cloudFlareDomain.domainName,
|
||||
content: 'v=spf1 a mx ip4:$ip4 -all',
|
||||
ttl: 18000,
|
||||
);
|
||||
for (var record in records) {
|
||||
if (record['zone_name'] == domainName) {
|
||||
allDeleteFutures.add(
|
||||
loggedClient.delete('$url/${record["id"]}'),
|
||||
);
|
||||
}
|
||||
}
|
||||
await Future.wait(allDeleteFutures);
|
||||
}
|
||||
|
||||
var listDnsRecords = <DnsRecords>[
|
||||
domainA,
|
||||
apiA,
|
||||
cloudA,
|
||||
gitA,
|
||||
meetA,
|
||||
passwordA,
|
||||
socialA,
|
||||
mx,
|
||||
txt1,
|
||||
txt2,
|
||||
vpn
|
||||
];
|
||||
Future<void> createMultipleDnsRecords({
|
||||
String ip4,
|
||||
CloudFlareDomain cloudFlareDomain,
|
||||
}) async {
|
||||
var domainName = cloudFlareDomain.domainName;
|
||||
var domainZoneId = cloudFlareDomain.zoneId;
|
||||
var listDnsRecords = projectDnsRecords(domainName, ip4);
|
||||
|
||||
var allFutures = <Future>[];
|
||||
var url = '$rootAddress/zones/$domainZoneId/dns_records';
|
||||
|
||||
var allCreateFutures = <Future>[];
|
||||
|
||||
for (var record in listDnsRecords) {
|
||||
var url = '$rootAddress/zones/$domainZoneId/dns_records';
|
||||
|
||||
allFutures.add(
|
||||
allCreateFutures.add(
|
||||
loggedClient.post(
|
||||
url,
|
||||
data: record.toJson(),
|
||||
|
@ -116,7 +102,7 @@ class CloudflareApi extends ApiMap {
|
|||
);
|
||||
}
|
||||
|
||||
await Future.wait(allFutures);
|
||||
await Future.wait(allCreateFutures);
|
||||
}
|
||||
|
||||
setDkim(String dkimRecordString, String domainZoneId) {
|
||||
|
@ -133,4 +119,45 @@ class CloudflareApi extends ApiMap {
|
|||
data: txt3.toJson(),
|
||||
);
|
||||
}
|
||||
|
||||
List<DnsRecords> projectDnsRecords(String domainName, String ip4) {
|
||||
var domainA = DnsRecords(type: 'A', name: domainName, content: ip4);
|
||||
|
||||
var mx = DnsRecords(type: 'MX', name: '@', content: domainName);
|
||||
var apiA = DnsRecords(type: 'A', name: 'api', content: ip4);
|
||||
var cloudA = DnsRecords(type: 'A', name: 'cloud', content: ip4);
|
||||
var gitA = DnsRecords(type: 'A', name: 'git', content: ip4);
|
||||
var meetA = DnsRecords(type: 'A', name: 'meet', content: ip4);
|
||||
var passwordA = DnsRecords(type: 'A', name: 'password', content: ip4);
|
||||
var socialA = DnsRecords(type: 'A', name: 'social', content: ip4);
|
||||
var vpn = DnsRecords(type: 'A', name: 'vpn', content: ip4);
|
||||
|
||||
var txt1 = DnsRecords(
|
||||
type: 'TXT',
|
||||
name: '_dmarc',
|
||||
content: 'v=DMARC1; p=none',
|
||||
ttl: 18000,
|
||||
);
|
||||
|
||||
var txt2 = DnsRecords(
|
||||
type: 'TXT',
|
||||
name: domainName,
|
||||
content: 'v=spf1 a mx ip4:$ip4 -all',
|
||||
ttl: 18000,
|
||||
);
|
||||
|
||||
return <DnsRecords>[
|
||||
domainA,
|
||||
apiA,
|
||||
cloudA,
|
||||
gitA,
|
||||
meetA,
|
||||
passwordA,
|
||||
socialA,
|
||||
mx,
|
||||
txt1,
|
||||
txt2,
|
||||
vpn
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ class AppConfigRepository {
|
|||
}
|
||||
|
||||
Future<bool> isDnsAddressesMatch(String domainName, String ip4) async {
|
||||
print(domainName);
|
||||
var addresses = <String>[
|
||||
'$domainName',
|
||||
'api.$domainName',
|
||||
|
@ -88,10 +89,12 @@ class AppConfigRepository {
|
|||
getIt.get<ConsoleModel>().addMessage(
|
||||
Message(
|
||||
text:
|
||||
'DnsLookup: ${lookupRecordRes.isEmpty ? (lookupRecordRes[0].data != ip4 ? 'wrong ip4' : 'right ip4') : 'empty'}',
|
||||
'DnsLookup: ${lookupRecordRes == null ? 'empty' : (lookupRecordRes[0].data != ip4 ? 'wrong ip4' : 'right ip4')}',
|
||||
),
|
||||
);
|
||||
if (lookupRecordRes.isEmpty || lookupRecordRes[0].data != ip4) {
|
||||
if (lookupRecordRes == null ||
|
||||
lookupRecordRes.isEmpty ||
|
||||
lookupRecordRes[0].data != ip4) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +128,11 @@ class AppConfigRepository {
|
|||
) async {
|
||||
var cloudflareApi = CloudflareApi(cloudFlareKey);
|
||||
|
||||
await cloudflareApi.removeSimilarRecords(
|
||||
ip4: ip4,
|
||||
cloudFlareDomain: cloudFlareDomain,
|
||||
);
|
||||
|
||||
await cloudflareApi.createMultipleDnsRecords(
|
||||
ip4: ip4,
|
||||
cloudFlareDomain: cloudFlareDomain,
|
||||
|
@ -136,7 +144,6 @@ class AppConfigRepository {
|
|||
Future<bool> isHttpServerWorking(String domainName) async {
|
||||
var api = ServerApi(domainName);
|
||||
var isHttpServerWorking = await api.isHttpServerWorking();
|
||||
print('isHttpServerWorking: $isHttpServerWorking');
|
||||
api.close();
|
||||
return isHttpServerWorking;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:cubit_form/cubit_form.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:selfprivacy/config/brand_colors.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/config/text_themes.dart';
|
||||
import 'package:selfprivacy/logic/cubit/forms/initializing/cloudflare_form_cubit.dart';
|
||||
|
@ -349,6 +350,8 @@ class _HowHetzner extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return BrandModalSheet(
|
||||
child: Padding(
|
||||
padding: brandPagePadding2,
|
||||
|
@ -362,7 +365,9 @@ class _HowHetzner extends StatelessWidget {
|
|||
children: [
|
||||
TextSpan(
|
||||
text: '1 Переходим по ссылке ',
|
||||
style: body1Style,
|
||||
style: body1Style.copyWith(
|
||||
color: isDark ? BrandColors.white : BrandColors.black,
|
||||
),
|
||||
),
|
||||
BrandSpanButton.link(
|
||||
text: 'hetzner.com/sdfsdfsdfsdf',
|
||||
|
@ -382,7 +387,9 @@ class _HowHetzner extends StatelessWidget {
|
|||
6 В поле Description, даём нашему токену название (это может быть любое название, которые вам нравиться. Сути оно не меняет.
|
||||
|
||||
''',
|
||||
style: body1Style,
|
||||
style: body1Style.copyWith(
|
||||
color: isDark ? BrandColors.white : BrandColors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -58,6 +58,10 @@ class _Card extends StatelessWidget {
|
|||
String title;
|
||||
String message;
|
||||
String stableText;
|
||||
var appConfig = context.watch<AppConfigCubit>().state;
|
||||
|
||||
var domainName =
|
||||
appConfig.isDomainFilled ? appConfig.cloudFlareDomain.domainName : '';
|
||||
|
||||
switch (provider.type) {
|
||||
case ProviderType.server:
|
||||
|
@ -66,11 +70,11 @@ class _Card extends StatelessWidget {
|
|||
break;
|
||||
case ProviderType.domain:
|
||||
title = 'Домен';
|
||||
message = 'example.com';
|
||||
message = domainName;
|
||||
stableText = 'Домен настроен';
|
||||
break;
|
||||
case ProviderType.backup:
|
||||
message = '22 янв 2021 14:30';
|
||||
// message = '22 янв 2021 14:30';
|
||||
title = 'Резервное копирование';
|
||||
stableText = 'В норме';
|
||||
break;
|
||||
|
|
|
@ -63,7 +63,7 @@ class _Card extends StatelessWidget {
|
|||
iconData = BrandIcons.messanger;
|
||||
title = 'Мессенджер';
|
||||
description =
|
||||
'Delta Chat срфеТекст-текст описание. Если бы мне надо было обсудить что-то от чего зависит жизнь. Я бы выбрал Delta.Chat + свой почтовый сервер.';
|
||||
'Delta Chat. Если бы мне надо было обсудить что-то от чего зависит жизнь. Я бы выбрал Delta.Chat + свой почтовый сервер.';
|
||||
break;
|
||||
case ServiceTypes.mail:
|
||||
iconData = BrandIcons.envelope;
|
||||
|
|
Loading…
Reference in a new issue