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