Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 121 lines (96 sloc) 2.863 kB
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4 *
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 *
920e20b @alobbs Happy new year!
alobbs authored
8 * Copyright (C) 2001-2011 Alvaro Lopez Ortega
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
23 */
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
24
25 #include "common-internal.h"
26 #include "rule_from.h"
27
28 #include "server-protected.h"
29 #include "connection-protected.h"
30 #include "util.h"
31
32 #define ENTRIES "rule,from"
33
34 PLUGIN_INFO_RULE_EASIEST_INIT(from);
35
36
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
37 static ret_t
38 match (cherokee_rule_from_t *rule,
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
39 cherokee_connection_t *conn,
40 cherokee_config_entry_t *ret_conf)
41 {
42 ret_t ret;
43
44 UNUSED(ret_conf);
45
46 ret = cherokee_access_ip_match (&rule->access, &conn->socket);
47 if (ret != ret_ok) {
48 TRACE(ENTRIES, "Rule from did %s match any\n", "not");
49 return ret_not_found;
50 }
51
52 TRACE(ENTRIES, "Rule from matched %s", "\n");
53 return ret_ok;
54 }
55
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
56 static ret_t
57 configure (cherokee_rule_from_t *rule,
58 cherokee_config_node_t *conf,
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
59 cherokee_virtual_server_t *vsrv)
60 {
61 ret_t ret;
62 cherokee_list_t *i;
63 cherokee_config_node_t *subconf;
64
65 UNUSED(vsrv);
66
67 ret = cherokee_config_node_get (conf, "from", &subconf);
68 if (ret != ret_ok) {
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
69 LOG_CRITICAL (CHEROKEE_ERROR_RULE_NO_PROPERTY,
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
70 RULE(rule)->priority, "from");
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
71 return ret_error;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
72 }
73
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
74 cherokee_config_node_foreach (i, subconf) {
75 cherokee_config_node_t *subconf2 = CONFIG_NODE(i);
76
77 ret = cherokee_access_add (&rule->access, subconf2->val.buf);
78 if (ret != ret_ok) {
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
79 LOG_ERROR (CHEROKEE_ERROR_RULE_FROM_ENTRY, subconf2->val.buf);
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
80 return ret_error;
81 }
82 }
83
84 return ret_ok;
85 }
86
87 static ret_t
88 _free (void *p)
89 {
90 cherokee_rule_from_t *rule = RULE_FROM(p);
91
92 cherokee_access_mrproper (&rule->access);
93 return ret_ok;
94 }
95
96
97 ret_t
98 cherokee_rule_from_new (cherokee_rule_from_t **rule)
99 {
100 ret_t ret;
101 CHEROKEE_NEW_STRUCT (n, rule_from);
102
103 /* Parent class constructor
104 */
105 cherokee_rule_init_base (RULE(n), PLUGIN_INFO_PTR(from));
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
106
00dbf15 @alobbs Fixes a typo: s/methos/methods/g
alobbs authored
107 /* Virtual methods
013fbda @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3341 5dc97367-9…
alobbs authored
108 */
109 RULE(n)->match = (rule_func_match_t) match;
110 RULE(n)->configure = (rule_func_configure_t) configure;
111 MODULE(n)->free = (module_func_free_t) _free;
112
113 /* Properties
114 */
115 ret = cherokee_access_init (&n->access);
116 if (ret != ret_ok) return ret;
117
118 *rule = n;
119 return ret_ok;
120 }
Something went wrong with that request. Please try again.