mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-17 09:46:08 +01:00
WIP: Moved DMARC plugin back to core repo
This commit is contained in:
@@ -13,6 +13,12 @@ export default {
|
||||
getDomainDNSDetail (domainId) {
|
||||
return repository.get(`/${domainResource}/${domainId}/dns_detail/`)
|
||||
},
|
||||
getDomainDmarcAligment (domainId, period) {
|
||||
return repository.get(
|
||||
`${domainResource}/${domainId}/dmarc/alignment_stats/`,
|
||||
{ params: { period } }
|
||||
)
|
||||
},
|
||||
getDomainAliases (domain) {
|
||||
let url = `/${domainAliasResource}/`
|
||||
if (domain !== undefined) {
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-card>
|
||||
<v-toolbar dense elevation="0" class="mr-2">
|
||||
<v-toolbar-title><translate>Aligment</translate></v-toolbar-title>
|
||||
<v-spacer />
|
||||
<v-btn
|
||||
icon
|
||||
x-small
|
||||
@click="previousWeek"
|
||||
>
|
||||
<v-icon>mdi-arrow-left</v-icon>
|
||||
</v-btn>
|
||||
<span class="mx-2">{{ weekStart.toLocaleString() }} - {{ weekEnd.toLocaleString() }}</span>
|
||||
<v-btn
|
||||
icon
|
||||
x-small
|
||||
@click="nextWeek"
|
||||
>
|
||||
<v-icon>mdi-arrow-right</v-icon>
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
<v-card-text>
|
||||
<v-row>
|
||||
<v-col cols="5">
|
||||
<apexchart
|
||||
v-if="series"
|
||||
type="pie"
|
||||
height="350"
|
||||
:options="options"
|
||||
:series="series"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-row>
|
||||
<v-col
|
||||
v-for="box in boxes"
|
||||
:key="box.key"
|
||||
cols="6"
|
||||
>
|
||||
<v-sheet
|
||||
outlined
|
||||
:color="box.color"
|
||||
rounded
|
||||
>
|
||||
<v-card
|
||||
outlined
|
||||
class="pa-10 text-center"
|
||||
>
|
||||
<span :class="'text-h4 ' + getTextColors(box.color)">{{ stats[box.key] }}</span><br>
|
||||
<span class="text-subtitle-1">{{ box.label }}</span>
|
||||
</v-card>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-expansion-panels
|
||||
v-model="panel"
|
||||
class="mt-2"
|
||||
>
|
||||
<v-expansion-panel>
|
||||
<v-expansion-panel-header>
|
||||
<translate>Detail</translate>
|
||||
</v-expansion-panel-header>
|
||||
<v-expansion-panel-content>
|
||||
<dmarc-source-table
|
||||
:title="'Trusted sources'|translate"
|
||||
color="green"
|
||||
:total="stats.aligned"
|
||||
:sources="alignments.aligned"
|
||||
/>
|
||||
<dmarc-source-table
|
||||
:title="'Partially trusted sources / Forwarders'|translate"
|
||||
color="orange"
|
||||
:total="stats.trusted"
|
||||
:sources="alignments.trusted"
|
||||
class="mt-4"
|
||||
/>
|
||||
<dmarc-source-table
|
||||
:title="'Forwarders with ARC'|translate"
|
||||
color="blue"
|
||||
:total="stats.forwarded"
|
||||
:sources="alignments.forwarded"
|
||||
class="mt-4"
|
||||
/>
|
||||
<dmarc-source-table
|
||||
:title="'Unknown sources / Threats'|translate"
|
||||
color="red"
|
||||
:total="stats.failed"
|
||||
:sources="alignments.failed"
|
||||
class="mt-4"
|
||||
/>
|
||||
</v-expansion-panel-content>
|
||||
</v-expansion-panel>
|
||||
</v-expansion-panels>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import colors from 'vuetify/lib/util/colors'
|
||||
import DmarcSourceTable from './DmarcSourceTable'
|
||||
import domainsApi from '@/api/domains'
|
||||
import { DateTime } from 'luxon'
|
||||
import VueApexCharts from 'vue-apexcharts'
|
||||
|
||||
const order = ['aligned', 'trusted', 'forwarded', 'failed']
|
||||
|
||||
export default {
|
||||
components: {
|
||||
apexchart: VueApexCharts,
|
||||
DmarcSourceTable
|
||||
},
|
||||
props: {
|
||||
domain: Object
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
options: {
|
||||
colors: [colors.green.lighten2, colors.orange.lighten2, colors.blue.lighten2, colors.red.lighten2],
|
||||
labels: [
|
||||
this.$gettext('Fully aligned'),
|
||||
this.$gettext('Partially aligned'),
|
||||
this.$gettext('Forwarded'),
|
||||
this.$gettext('Failed')
|
||||
],
|
||||
legend: {
|
||||
position: 'bottom'
|
||||
}
|
||||
},
|
||||
alignments: {},
|
||||
boxes: [
|
||||
{ key: 'total', label: this.$gettext('Total'), color: 'primary lighten-2' },
|
||||
{ key: 'aligned', label: this.$gettext('Fully aligned'), color: 'green lighten-2' },
|
||||
{ key: 'trusted', label: this.$gettext('Partially aligned'), color: 'orange lighten-2' },
|
||||
{ key: 'forwarded', label: this.$gettext('Forwarded'), color: 'blue lighten-2' },
|
||||
{ key: 'failed', label: this.$gettext('Failed'), color: 'red lighten-2' }
|
||||
],
|
||||
currentWeek: 0,
|
||||
currentYear: 0,
|
||||
loading: false,
|
||||
panel: null,
|
||||
series: [],
|
||||
stats: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
weekStart () {
|
||||
const dt = DateTime.fromObject({
|
||||
weekYear: this.currentYear,
|
||||
weekNumber: this.currentWeek
|
||||
})
|
||||
return dt.startOf('week')
|
||||
},
|
||||
weekEnd () {
|
||||
const dt = DateTime.fromObject({
|
||||
weekYear: this.currentYear,
|
||||
weekNumber: this.currentWeek
|
||||
})
|
||||
return dt.endOf('week')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getTextColors (value) {
|
||||
let result = ''
|
||||
for (const color of value.split(' ')) {
|
||||
if (result !== '') {
|
||||
result += ' '
|
||||
}
|
||||
if (color.startsWith('lighten')) {
|
||||
result += 'text--' + color
|
||||
} else {
|
||||
result += color + '--text'
|
||||
}
|
||||
}
|
||||
return result
|
||||
},
|
||||
nextWeek () {
|
||||
if (this.currentWeek === 52) {
|
||||
this.currentYear += 1
|
||||
this.currentWeek = 1
|
||||
} else {
|
||||
this.currentWeek += 1
|
||||
}
|
||||
},
|
||||
previousWeek () {
|
||||
if (this.currentWeek === 1) {
|
||||
this.currentYear -= 1
|
||||
this.currentWeek = 52
|
||||
} else {
|
||||
this.currentWeek -= 1
|
||||
}
|
||||
},
|
||||
fetchAligmentStats () {
|
||||
if (this.loading) {
|
||||
return
|
||||
}
|
||||
const period = `${this.currentYear}-${this.currentWeek}`
|
||||
this.loading = true
|
||||
domainsApi.getDomainDmarcAligment(this.domain.pk, period).then(resp => {
|
||||
this.stats = { total: 0 }
|
||||
this.alignments = resp.data
|
||||
this.series = []
|
||||
for (const key of order) {
|
||||
let total = 0
|
||||
for (const name in resp.data[key]) {
|
||||
for (const ip in resp.data[key][name]) {
|
||||
total += resp.data[key][name][ip].total
|
||||
}
|
||||
}
|
||||
this.stats.total += total
|
||||
this.stats[key] = total
|
||||
this.series.push(total)
|
||||
}
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
created () {
|
||||
const now = DateTime.now()
|
||||
this.currentYear = now.year
|
||||
this.currentWeek = now.weekNumber
|
||||
},
|
||||
mounted () {
|
||||
this.fetchAligmentStats()
|
||||
},
|
||||
watch: {
|
||||
currentWeek () {
|
||||
this.fetchAligmentStats()
|
||||
},
|
||||
currentYear () {
|
||||
this.fetchAligmentStats()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="text-h6">{{ title }} <span :class="`${color}--text text--lighten-2`">{{ total }}</span></div>
|
||||
<v-simple-table>
|
||||
<tbody>
|
||||
<template v-for="(source, name) in sources">
|
||||
<tr :key="name">
|
||||
<th width="40%">{{ name }}</th>
|
||||
<th><translate>Total</translate></th>
|
||||
<th>SPF</th>
|
||||
<th>DKIM</th>
|
||||
</tr>
|
||||
<tr v-for="(counters, ip) in source" :key="ip">
|
||||
<td>{{ ip }}</td>
|
||||
<td>{{ counters.total }}</td>
|
||||
<td>
|
||||
<v-avatar
|
||||
color="green lighten-2"
|
||||
size="24"
|
||||
>
|
||||
<span class="white--text">{{ counters.spf.success }}</span>
|
||||
</v-avatar>
|
||||
<v-avatar
|
||||
color="red lighten-2 ml-1"
|
||||
size="24"
|
||||
>
|
||||
<span class="white--text">{{ counters.spf.failure }}</span>
|
||||
</v-avatar>
|
||||
</td>
|
||||
<td>
|
||||
<v-avatar
|
||||
color="green lighten-2"
|
||||
size="24"
|
||||
>
|
||||
<span class="white--text">{{ counters.dkim.success }}</span>
|
||||
</v-avatar>
|
||||
<v-avatar
|
||||
color="red lighten-2 ml-1"
|
||||
size="24"
|
||||
>
|
||||
<span class="white--text">{{ counters.dkim.failure }}</span>
|
||||
</v-avatar>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</v-simple-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: String,
|
||||
color: String,
|
||||
total: Number,
|
||||
sources: Object
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -6,49 +6,77 @@
|
||||
<v-icon>mdi-circle-edit-outline</v-icon>
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
<v-layout>
|
||||
<v-row>
|
||||
<v-col cols="6">
|
||||
<domain-summary :domain="domain" />
|
||||
<div class="mt-4" />
|
||||
<administrator-list
|
||||
|
||||
<v-tabs
|
||||
v-model="tab"
|
||||
>
|
||||
<v-tab>
|
||||
<translate>General</translate>
|
||||
</v-tab>
|
||||
<v-tab>
|
||||
<translate>Statistics</translate>
|
||||
</v-tab>
|
||||
<v-tab>
|
||||
<translate>DMARC</translate>
|
||||
</v-tab>
|
||||
<v-tabs-items
|
||||
v-model="tab"
|
||||
>
|
||||
<v-tab-item>
|
||||
<v-layout class="pa-2">
|
||||
<v-row>
|
||||
<v-col cols="6">
|
||||
<domain-summary :domain="domain" />
|
||||
<div class="mt-4" />
|
||||
<administrator-list
|
||||
:domain="domain"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="6">
|
||||
<dns-detail v-model="domain" />
|
||||
<div class="mt-4" />
|
||||
<resources
|
||||
v-if="limitsConfig.params && limitsConfig.params.enable_domain_limits && domain.resources && domain.resources.length"
|
||||
:resources="domain.resources"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-layout>
|
||||
</v-tab-item>
|
||||
<v-tab-item>
|
||||
<v-layout class="pa-2">
|
||||
<v-row class="mt-2">
|
||||
<v-col cols="12">
|
||||
<time-serie-chart
|
||||
v-if="domain.name"
|
||||
:domain="domain"
|
||||
graphic-set="mailtraffic"
|
||||
graphic-name="averagetraffic"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<time-serie-chart
|
||||
v-if="domain.name"
|
||||
:domain="domain"
|
||||
graphic-set="mailtraffic"
|
||||
graphic-name="averagetrafficsize"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-layout>
|
||||
</v-tab-item>
|
||||
<v-tab-item>
|
||||
<dmarc-aligment-chart
|
||||
:domain="domain"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="6">
|
||||
<dns-detail v-model="domain" />
|
||||
<div class="mt-4" />
|
||||
<resources
|
||||
v-if="limitsConfig.params && limitsConfig.params.enable_domain_limits && domain.resources && domain.resources.length"
|
||||
:resources="domain.resources"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-layout>
|
||||
<v-layout>
|
||||
<v-row class="mt-2">
|
||||
<v-col cols="12">
|
||||
<time-serie-chart
|
||||
v-if="domain.name"
|
||||
:domain="domain"
|
||||
graphic-set="mailtraffic"
|
||||
graphic-name="averagetraffic"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<time-serie-chart
|
||||
v-if="domain.name"
|
||||
:domain="domain"
|
||||
graphic-set="mailtraffic"
|
||||
graphic-name="averagetrafficsize"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-layout>
|
||||
<v-dialog v-model="showEditForm"
|
||||
persistent
|
||||
max-width="800px"
|
||||
>
|
||||
</v-tab-item>
|
||||
</v-tabs-items>
|
||||
</v-tabs>
|
||||
<v-dialog
|
||||
v-model="showEditForm"
|
||||
persistent
|
||||
max-width="800px"
|
||||
>
|
||||
<domain-form :domain="domain" @close="showEditForm = false" />
|
||||
</v-dialog>
|
||||
</div>
|
||||
@@ -57,6 +85,7 @@
|
||||
<script>
|
||||
import domains from '@/api/domains'
|
||||
import AdministratorList from '@/components/domains/AdministratorList'
|
||||
import DmarcAligmentChart from '@/components/dmarc/DmarcAligmentChart'
|
||||
import DNSDetail from '@/components/domains/DNSDetail'
|
||||
import DomainForm from '@/components/domains/DomainForm'
|
||||
import DomainSummary from '@/components/domains/DomainSummary'
|
||||
@@ -68,6 +97,7 @@ export default {
|
||||
components: {
|
||||
AdministratorList,
|
||||
'dns-detail': DNSDetail,
|
||||
DmarcAligmentChart,
|
||||
DomainForm,
|
||||
DomainSummary,
|
||||
Resources,
|
||||
@@ -78,7 +108,8 @@ export default {
|
||||
domain: { pk: this.$route.params.id },
|
||||
limitsConfig: {},
|
||||
showEditForm: false,
|
||||
showAdminList: false
|
||||
showAdminList: false,
|
||||
tab: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -98,4 +129,7 @@ export default {
|
||||
.v-toolbar {
|
||||
background-color: #f7f8fa !important;
|
||||
}
|
||||
.v-tabs-items {
|
||||
background-color: #f7f8fa !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user