Skip to content

Commit 96f2fa6

Browse files
committed
Merge branch 'subdomain_alias' of github.com:purecloudlabs/opensips into purecloudlabs-subdomain_alias
2 parents a44a00c + e983263 commit 96f2fa6

File tree

13 files changed

+214
-83
lines changed

13 files changed

+214
-83
lines changed

cfg.lex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ CR \n
342342
343343
ANY "any"
344344
ANYCAST ("anycast"|"ANYCAST")
345+
ACCEPT_SUBDOMAIN ("accept_subdomain"|"ACCEPT_SUBDOMAIN")
345346
FRAG ("frag"|"FRAG")
346347
REUSE_PORT ("reuse_port"|"REUSE_PORT")
347348
@@ -617,6 +618,7 @@ SPACE [ ]
617618
<INITIAL>{CR} { count();/* return CR;*/ }
618619
<INITIAL>{ANY} { count(); return ANY; }
619620
<INITIAL>{ANYCAST} { count(); return ANYCAST; }
621+
<INITIAL>{ACCEPT_SUBDOMAIN} { count(); return ACCEPT_SUBDOMAIN; }
620622
<INITIAL>{REUSE_PORT} { count(); return REUSE_PORT; }
621623
<INITIAL>{FRAG} { count(); return FRAG; }
622624
<INITIAL>{SLASH} { count(); return SLASH; }

cfg.y

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static struct multi_str *tmp_mod;
206206
#define get_cfg_file_name \
207207
((finame) ? finame : cfg_file ? cfg_file : "default")
208208

209-
209+
#define si_subdomain_to_alias_flag(_flags) (int) _flags & SI_ACCEPT_SUBDOMAIN_ALIAS
210210

211211
#define mk_action_(_res, _type, _no, _elems) \
212212
do { \
@@ -468,6 +468,7 @@ extern int cfg_parse_only_routes;
468468
%token COLON
469469
%token ANY
470470
%token ANYCAST
471+
%token ACCEPT_SUBDOMAIN
471472
%token FRAG
472473
%token REUSE_PORT
473474
%token SCRIPTVARERR
@@ -493,6 +494,7 @@ extern int cfg_parse_only_routes;
493494
%type <sockid> socket_def
494495
%type <sockid> id_lst
495496
%type <sockid> alias_def
497+
%type <sockid> any_alias
496498
%type <sockid> listen_id_def
497499
%type <sockid> phostport phostportrange
498500
%type <intval> proto port any_proto
@@ -696,7 +698,7 @@ phostportrange: proto COLON MULT { IFOR();
696698
}
697699
;
698700

699-
alias_def: listen_id { IFOR();
701+
any_alias: listen_id { IFOR();
700702
$$=mk_listen_id($1, PROTO_NONE, 0); }
701703
| ANY COLON listen_id { IFOR();
702704
$$=mk_listen_id($3, PROTO_NONE, 0); }
@@ -709,6 +711,13 @@ alias_def: listen_id { IFOR();
709711
| phostport
710712
;
711713

714+
alias_def: any_alias { $$=$1; }
715+
| any_alias ACCEPT_SUBDOMAIN {
716+
$$=$1;
717+
$$->flags |= SI_ACCEPT_SUBDOMAIN_ALIAS;
718+
}
719+
;
720+
712721
id_lst: alias_def { IFOR(); $$=$1 ; }
713722
| alias_def id_lst { IFOR(); $$=$1; $$->next=$2; }
714723
;
@@ -732,6 +741,9 @@ socket_def_param: ANYCAST { IFOR();
732741
| REUSE_PORT { IFOR();
733742
p_tmp.flags |= SI_REUSEPORT;
734743
}
744+
| ACCEPT_SUBDOMAIN { IFOR();
745+
p_tmp.flags |= SI_ACCEPT_SUBDOMAIN_ALIAS;
746+
}
735747
| USE_WORKERS NUMBER { IFOR();
736748
p_tmp.workers=$2;
737749
}
@@ -1489,7 +1501,7 @@ assign_stm: LOGLEVEL EQUAL snumber { IFOR();
14891501
| ALIAS EQUAL id_lst { IFOR();
14901502
for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
14911503
add_alias(lst_tmp->name, strlen(lst_tmp->name),
1492-
lst_tmp->port, lst_tmp->proto);
1504+
lst_tmp->port, lst_tmp->proto, si_subdomain_to_alias_flag(lst_tmp->flags));
14931505
}
14941506
| ALIAS EQUAL error { yyerror("hostname expected (use quotes"
14951507
" if the hostname includes config keywords)"); }

db/schema/domain.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
<null/>
4545
</column>
4646

47+
<column id="accept_subdomain">
48+
<name>accept_subdomain</name>
49+
<type>unsigned int</type>
50+
<size>11</size>
51+
<default>0</default>
52+
<description>Accept subdomain</description>
53+
</column>
4754

4855
<column>
4956
<name>last_modified</name>

ip_addr.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ union sockaddr_union{
8989

9090

9191
enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4,
92-
SI_IS_ANYCAST=8, SI_FRAG=16, SI_REUSEPORT=32, SI_INTERNAL=64 };
92+
SI_IS_ANYCAST=8, SI_FRAG=16, SI_REUSEPORT=32, SI_INTERNAL=64, SI_ACCEPT_SUBDOMAIN_ALIAS=128 };
9393

9494
struct receive_info {
9595
struct ip_addr src_ip;
@@ -127,8 +127,6 @@ struct socket_id {
127127
struct socket_id* next;
128128
};
129129

130-
131-
132130
/* len of the sockaddr */
133131
#ifdef HAVE_SOCKADDR_SA_LEN
134132
#define sockaddru_len(su) ((su).s.sa_len)

modules/domain/README

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ domain Module
1414
1.3.3. domain_table (string)
1515
1.3.4. domain_col (string)
1616
1.3.5. attrs_col (string)
17+
1.3.6. accept_subdomain_col (string)
1718

1819
1.4. Exported Functions
1920

@@ -57,9 +58,10 @@ domain Module
5758
1.3. Setting domain_table parameter
5859
1.4. Setting domain_col parameter
5960
1.5. Setting attrs_col parameter
60-
1.6. is_from_local usage
61-
1.7. is_uri_host_local usage
62-
1.8. is_domain_local usage
61+
1.6. Setting accept_subdomain_col parameter
62+
1.7. is_from_local usage
63+
1.8. is_uri_host_local usage
64+
1.9. is_domain_local usage
6365

6466
Chapter 1. Admin Guide
6567

@@ -139,6 +141,15 @@ modparam("domain", "domain_col", "domain_name")
139141
Example 1.5. Setting attrs_col parameter
140142
modparam("domain", "attrs_col", "attributes")
141143

144+
1.3.6. accept_subdomain_col (string)
145+
146+
Name of column containing accept_subdomain value in domain table.
147+
148+
Default value is “accept_subdomain”.
149+
150+
Example 1.6. Setting accept_subdomain_col parameter
151+
modparam("domain", "accept_subdomain_col", "accept_subdomain")
152+
142153
1.4. Exported Functions
143154

144155
1.4.1. is_from_local([attrs_var])
@@ -151,7 +162,7 @@ modparam("domain", "attrs_col", "attributes")
151162

152163
This function can be used from REQUEST_ROUTE.
153164

154-
Example 1.6. is_from_local usage
165+
Example 1.7. is_from_local usage
155166
...
156167
if (is_from_local()) {
157168
...
@@ -177,7 +188,7 @@ if (is_from_local($var(attrs))) {
177188
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
178189
BRANCH_ROUTE.
179190

180-
Example 1.7. is_uri_host_local usage
191+
Example 1.8. is_uri_host_local usage
181192
...
182193
if (is_uri_host_local()) {
183194
...
@@ -209,7 +220,7 @@ if (is_uri_host_local($var(attrs))) {
209220
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
210221
BRANCH_ROUTE.
211222

212-
Example 1.8. is_domain_local usage
223+
Example 1.9. is_domain_local usage
213224
...
214225
if (is_domain_local($rd)) {
215226
...

0 commit comments

Comments
 (0)