spf2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/ext/spf2/spf2.c +47 -75
- data/lib/spf2/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWQ2ZTFmZTdkYzRmMGZmNzdlODVmODFlMWQ1YTdiMzdhYTRmZjZhZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTFhNTFjZjJmYzc1Y2ZjYWQ0MjE0OTI3NzFjMGY1Y2IzZjE5OWI3MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjgwZWYyNGI1M2I4NDc3YjgyZWJlNmU5ZDUyMDBmNTk1OGYzMzU3NjZjY2M4
|
10
|
+
NTQ0YWIxN2UzNjIwZDQ3ZTA1NTYwN2E3NGEwYTg3YjczMTFkZjBjZGE2Mzhk
|
11
|
+
YjNhNzVlMTE3NDEyNmM4MzM4MjA4MGQ1MTc4N2YzODZmZDZlMDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWZkODE0MDdlMDkzNWY2YTkzOTg3NzU1YmNjZTVlZTIxNjFjZjdkNjM5MDcz
|
14
|
+
NWY3NWY4NjQwNDYwZjA1OTlkNWEyOGYxOGIyOGJiNDY3NWViMTExMTY4NmVm
|
15
|
+
NTRkYTE4NTdjNDllYjk0YjdiZTkxOTNkODMyM2ZmZWFlM2M4OTY=
|
data/ext/spf2/spf2.c
CHANGED
@@ -2,105 +2,78 @@
|
|
2
2
|
#include <netinet/in.h>
|
3
3
|
#include <spf2/spf.h>
|
4
4
|
#include <spf2/spf_server.h>
|
5
|
-
/*
|
6
|
-
SPF_server_t *spf_server = SPF_server_new(SPF_DNS_CACHE, 0);
|
7
|
-
Create a request, and set the relevant fields in it. Each setter method returns an SPF_errcode_t, which will inform you of error conditions, such as out-of-memory or invalid argument.
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Now that we have built a query, we may execute it. It will use the SPF_server_t which was passed to the query constructor. As usual, the SPF_request_query_mailfrom method returns an error code, although much richer errors are returned inside the SPF_response_t - see spf_response.h for more details of that API.
|
6
|
+
static VALUE spf2_set_debug(VALUE self, VALUE bDebug)
|
7
|
+
{
|
8
|
+
SPF_server_t *spf_server;
|
13
9
|
|
14
|
-
SPF_response_t *spf_response = NULL;
|
15
|
-
SPF_request_query_mailfrom(spf_request, &spf_response);
|
16
|
-
printf("Result is %s\n",
|
17
|
-
SPF_strresult(SPF_response_result(spf_response)));
|
18
|
-
When we have finished with the response, we must free it and the request.
|
19
|
-
|
20
|
-
SPF_response_free(spf_response);
|
21
|
-
SPF_request_free(spf_request);
|
22
|
-
We can execute many requests in parallel threads on the same server, but before the program exits, we must free the server.
|
23
|
-
|
24
|
-
SPF_server_free(spf_server);
|
25
|
-
*/
|
26
|
-
|
27
|
-
/*
|
28
|
-
*/
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
static VALUE
|
33
|
-
spf2_set_debug(VALUE self, VALUE bDebug){
|
34
|
-
SPF_server_t *spf_server ;
|
35
|
-
|
36
10
|
Data_Get_Struct(self, SPF_server_t, spf_server);
|
37
|
-
|
11
|
+
spf_server->debug = RTEST(bDebug);
|
38
12
|
|
39
13
|
|
40
14
|
return self;
|
41
15
|
}
|
42
16
|
|
43
|
-
static VALUE
|
44
|
-
|
17
|
+
static VALUE spf2_query(VALUE self, VALUE ipfrom, VALUE domain)
|
18
|
+
{
|
45
19
|
|
46
|
-
|
47
|
-
|
48
|
-
|
20
|
+
SPF_server_t *spf_server = NULL;
|
21
|
+
SPF_response_t *spf_response = NULL;
|
22
|
+
SPF_request_t *spf_request = NULL;
|
49
23
|
|
50
|
-
|
24
|
+
VALUE ret, str_result, str_reason, str_error;
|
51
25
|
|
52
|
-
|
26
|
+
Data_Get_Struct(self, SPF_server_t, spf_server);
|
27
|
+
|
28
|
+
spf_request = SPF_request_new(spf_server);
|
53
29
|
|
54
|
-
|
30
|
+
SPF_request_set_ipv4_str(spf_request, StringValueCStr(ipfrom));
|
31
|
+
SPF_request_set_env_from(spf_request, StringValueCStr(domain));
|
32
|
+
SPF_request_query_mailfrom(spf_request, &spf_response);
|
55
33
|
|
56
|
-
|
57
|
-
|
58
|
-
|
34
|
+
str_result =
|
35
|
+
rb_str_new2(SPF_strresult(SPF_response_result(spf_response)));
|
36
|
+
str_reason =
|
37
|
+
rb_str_new2(SPF_strreason(SPF_response_reason(spf_response)));
|
38
|
+
str_error =
|
39
|
+
rb_str_new2(SPF_strerror(SPF_response_errcode(spf_response)));
|
40
|
+
ret = rb_ary_new2(4);
|
41
|
+
rb_ary_push(ret, str_result);
|
42
|
+
rb_ary_push(ret, str_reason);
|
43
|
+
rb_ary_push(ret, str_error);
|
59
44
|
|
60
|
-
str_result = rb_str_new2(SPF_strresult(SPF_response_result(spf_response)));
|
61
|
-
str_reason = rb_str_new2(SPF_strreason(SPF_response_reason(spf_response)));
|
62
|
-
str_error = rb_str_new2(SPF_strerror(SPF_response_errcode(spf_response)));
|
63
|
-
ret = rb_ary_new2(4);
|
64
|
-
rb_ary_push(ret, str_result);
|
65
|
-
rb_ary_push(ret, str_reason);
|
66
|
-
rb_ary_push(ret, str_error);
|
67
45
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
return ret;
|
46
|
+
SPF_response_free(spf_response);
|
47
|
+
SPF_request_free(spf_request);
|
48
|
+
return ret;
|
72
49
|
}
|
73
50
|
|
74
51
|
|
75
|
-
static void spf2_free(void *
|
76
|
-
|
52
|
+
static void spf2_free(void *p)
|
53
|
+
{
|
54
|
+
SPF_server_free(p);
|
77
55
|
}
|
78
56
|
|
79
|
-
static VALUE
|
80
|
-
|
81
|
-
|
82
|
-
|
57
|
+
static VALUE spf2_init(VALUE self, VALUE bDebug)
|
58
|
+
{
|
59
|
+
spf2_set_debug(self, bDebug);
|
60
|
+
return self;
|
83
61
|
}
|
84
62
|
|
85
63
|
|
86
64
|
|
87
|
-
|
88
|
-
|
89
|
-
*
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
SPF_server_t *spf_server = NULL;
|
96
|
-
VALUE obj;
|
97
|
-
spf_server = SPF_server_new(SPF_DNS_CACHE,0);
|
98
|
-
obj = Data_Wrap_Struct(klass, 0, spf2_free, spf_server);
|
99
|
-
return obj;
|
100
|
-
|
65
|
+
static VALUE spf2_alloc(VALUE klass)
|
66
|
+
{
|
67
|
+
SPF_server_t *spf_server = NULL;
|
68
|
+
VALUE obj;
|
69
|
+
spf_server = SPF_server_new(SPF_DNS_CACHE, 0);
|
70
|
+
obj = Data_Wrap_Struct(klass, 0, spf2_free, spf_server);
|
71
|
+
return obj;
|
72
|
+
|
101
73
|
}
|
102
|
-
|
103
|
-
Init_spf2(void)
|
74
|
+
|
75
|
+
void Init_spf2(void)
|
76
|
+
{
|
104
77
|
VALUE cSpf2;
|
105
78
|
|
106
79
|
cSpf2 = rb_const_get(rb_cObject, rb_intern("Spf2"));
|
@@ -110,4 +83,3 @@ Init_spf2(void) {
|
|
110
83
|
rb_define_method(cSpf2, "debug=", spf2_set_debug, 1);
|
111
84
|
rb_define_method(cSpf2, "query", spf2_query, 2);
|
112
85
|
}
|
113
|
-
|
data/lib/spf2/version.rb
CHANGED