6 #include <glog/logging.h>
8 // forward stuff from <spf2/spf.h>
9 typedef struct SPF_server_struct SPF_server_t
;
10 typedef struct SPF_request_struct SPF_request_t
;
11 typedef struct SPF_response_struct SPF_response_t
;
18 Result(int value
); // int for SPF_result_t
32 static constexpr auto INVALID
= value_t::INVALID
;
33 static constexpr auto NEUTRAL
= value_t::NEUTRAL
;
34 static constexpr auto PASS
= value_t::PASS
;
35 static constexpr auto FAIL
= value_t::FAIL
;
36 static constexpr auto SOFTFAIL
= value_t::SOFTFAIL
;
37 static constexpr auto NONE
= value_t::NONE
;
38 static constexpr auto TEMPERROR
= value_t::TEMPERROR
;
39 static constexpr auto PERMERROR
= value_t::PERMERROR
;
42 static char const* c_str(value_t value
);
44 char const* c_str() const { return c_str(value_
); }
46 operator value_t() const { return value_
; }
47 explicit operator char const*() const { return c_str(); }
50 value_t value_
{INVALID
};
53 std::ostream
& operator<<(std::ostream
& os
, Result result
);
54 std::ostream
& operator<<(std::ostream
& os
, Result::value_t result
);
58 Server(Server
const&) = delete;
59 Server
& operator=(Server
const&) = delete;
61 explicit Server(char const* fqdn
);
64 static class initializer
{
70 SPF_server_t
* srv_
{nullptr};
72 // We map libspf2's levels of error, warning, info and debug to our
73 // own fatal, error, warning and info log levels.
74 static void log_error_(const char* file
, int line
, char const* errmsg
)
75 __attribute__((noreturn
))
77 LOG(FATAL
) << file
<< ":" << line
<< " " << errmsg
;
79 static void log_warning_(const char* file
, int line
, char const* errmsg
)
81 LOG(WARNING
) << file
<< ":" << line
<< " " << errmsg
;
83 static void log_info_(const char* file
, int line
, char const* errmsg
)
85 LOG(INFO
) << file
<< ":" << line
<< " " << errmsg
;
93 Request(Request
const&) = delete;
94 Request
& operator=(Request
const&) = delete;
100 explicit Request(Server
const& srv
);
103 void set_ip_str(char const* ip
);
104 void set_ipv4_str(char const* ipv4
);
105 void set_ipv6_str(char const* ipv6
);
106 void set_helo_dom(char const* dom
);
107 void set_env_from(char const* frm
);
108 char const* get_sender_dom() const;
111 SPF_request_t
* req_
{nullptr};
113 friend class Response
;
118 Response(Response
const&) = delete;
119 Response
& operator=(Response
const&) = delete;
122 explicit Response(Request
const& req
);
125 Result
result() const;
126 char const* smtp_comment() const;
127 char const* header_comment() const;
128 char const* received_spf() const;
131 SPF_response_t
* res_
{nullptr};
136 #endif // SPF_DOT_HPP