-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOpenDMARC.hpp
96 lines (76 loc) · 2.06 KB
/
OpenDMARC.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef OPENDMARC_DOT_HPP
#define OPENDMARC_DOT_HPP
#include "IP6.hpp"
#include <opendmarc/dmarc.h>
#include <glog/logging.h>
namespace OpenDMARC {
enum class advice;
constexpr char const* advice_to_string(advice adv);
class lib {
// no copy
lib(lib const&) = delete;
lib& operator=(lib const&) = delete;
public:
// move
lib(lib&&) = default;
lib& operator=(lib&&) = default;
lib();
~lib();
private:
OPENDMARC_LIB_T lib_;
};
class policy {
// no copy
policy(policy const&) = delete;
policy& operator=(policy const&) = delete;
public:
policy() = default;
// move
policy(policy&&) = default;
policy& operator=(policy&&) = default;
~policy();
void connect(char const* ip);
bool store_from_domain(char const* from_domain);
bool store_dkim(char const* d_equal_domain,
char const* d_selector,
int dkim_result,
char const* human_result);
bool store_spf(char const* domain,
int result,
int origin,
char const* human_readable);
bool query_dmarc(char const* domain);
advice get_advice();
private:
DMARC_POLICY_T* pctx_{nullptr};
};
enum class advice {
ACCEPT,
REJECT,
QUARANTINE,
NONE,
};
constexpr char const* advice_to_string(advice adv)
{
switch (adv) {
case advice::ACCEPT: return "accept";
case advice::REJECT: return "reject";
case advice::QUARANTINE: return "quarantine";
case advice::NONE: break;
}
return "none";
}
constexpr char const* policy_spf_to_string(int pol)
{
switch (pol) {
case DMARC_POLICY_SPF_OUTCOME_NONE: return "SPF_OUTCOME_NONE";
case DMARC_POLICY_SPF_OUTCOME_PASS: return "SPF_OUTCOME_PASS";
case DMARC_POLICY_SPF_OUTCOME_FAIL: return "SPF_OUTCOME_FAIL";
case DMARC_POLICY_SPF_OUTCOME_TMPFAIL: return "SPF_OUTCOME_TMPFAIL";
case DMARC_POLICY_SPF_ALIGNMENT_PASS: return "SPF_ALIGNMENT_PASS";
case DMARC_POLICY_SPF_ALIGNMENT_FAIL: return "SPF_ALIGNMENT_FAIL";
}
return "none";
}
} // namespace OpenDMARC
#endif // OPENDMARC_DOT_HPP