Add support for subdomain checking in aliases and socket aliases#3458
Conversation
bogdan-iancu
left a comment
There was a problem hiding this comment.
The overall approach of the patch is good, great idea here! With a bit of changes, we could merge it, please see my comments.
What needs to be taken into consideration is the extension of the domain module (when aliases are provisioned via DB), to also support sub-domains - maybe something like an extra flag column. This will do a 100% coverage of the SIP-domains support in OpenSIPS
|
Hi Bogdan, thanks for the feedback I'll work on integrating the changes you requested in the coming week |
|
just a gentle ping here :) |
|
and one more gentle ping here :) |
|
@bogdan-iancu sorry I've been quite busy, the grammar changes and the fix suggested for ensuring we strictly match subdomains works. I also believe I have the domain changes working when you load the hash table into memory, the check for that is a lot easier as it can utilise the name_alias changes and provide the domain to check and the accept_subdomain parameter from the db instead of the socket aliases, still need to verify my changes work there but I think they should, just need to setup my env to add the new column. The main reason why I haven't pushed these changes yet is I'm having trouble with the domain module when you do not load the table into memory (ie. db mode == 0) the query for this is a strict One area would be to tokenise the domain so that we could potentially do multiple queries so domain Do you have any good example you can point me to achieve this If I could your thoughts I could have this finished quickly enough as I have the bulk of the changes just that scenario described and I need to test it |
|
@bogdan-iancu I got the feature added to the domain module, I don't think there's anyway around needing to iterate through the domain to check each one against the host and accepting the subdomain. I have tested it with both db mode on and off and with accept subdomain on and off and it works, also the new grammar you suggested is there too along with the fixes you mentioned. There was a failure checking the rtpio I'm not sure if what I did affected that, let me know your thoughts on the PR |
|
Just added in some comments to explain the algorithm @bogdan-iancu I understand this feature you have tagged for 3.6-dev which I presume means you would like it in before the conference on the 26th so let me know if you want to have a chat and we can try and fix any residual issues you may have with my PR or if you need clarification |
| * Check if domain is local and store attributes in a pvar | ||
| */ | ||
| int is_domain_local_pvar(struct sip_msg *msg, str* _host, pv_spec_t *pv) | ||
| int db_table_lookup(struct sip_msg *msg, str *lookup_domain, str *host, pv_spec_t *pv) |
There was a problem hiding this comment.
This is mostly just the existing is_domain_local_pvar refactored into a specific db lookup function with one minor change where it first gets the accept_subdomain column and does the match subdomain based on the supplied host rather than implictly trusting it matches based on getting a result back
|
|
||
| extern struct alias_function* alias_fcts; | ||
|
|
||
| static inline int match_domain(char* alias, int alias_len, char* host, int host_len, int accept_subdomain) { |
There was a problem hiding this comment.
Broke this functionality out into a separate function so it could be exposed to the domain module for use there, this file is part of the core OpenSIPs so the domain module will always have access to this file regardless of the Makefile definitions
bogdan-iancu
left a comment
There was a problem hiding this comment.
Thank you @davidtrihy-genesys , it looks good - what is missing is the increment on the table version for "domain" (as the schema changed), but as we are in a hurry for 3.6 release, I will take care of that after merging ;)
|
@bogdan-iancu thanks for reviewing and I'll see you in Amsterdam next Monday! |
Summary
Adds support for subdomains in aliases and socket aliases
Details
New feature related to this issue #1466
When defining sockets or aliases we can mark them with subdomain so that when check_self is called it will match when there the host to check is subdomain of the alias, definition of the socket and alias as so
If either are set up this way then when check_self is called for example in the TM topology_hiding then if the request domain is something like
resource.my.subdomain.comordifferent.resource.my.subdomain.comit will match the alias but also a deliberate design decision to allowmy.subdomain.comto match too.Solution
A flag is added, when the
subdomain|SUBDOMAINflag is on the socket or alias this allows it to match addresses that match that alias subdomain while preserving strict matching when the flag is not setCompatibility
The flag is a new flag so existing config where the subdomain flag is not on the alias or socket will behave like it already does without this change, it's backwards compatible
Closing issues
closes #1466