user = find_user(of, 1);
/* Find user based on user name in the from header */
- if (user && ast_apply_ha(user->ha, sin)) {
+ if (user && !ast_apply_ha(user->ha, sin)) {
+ if (!authpeer && debug)
+ ast_verbose("Found user '%s', but fails host access\n", user->name);
+ ASTOBJ_UNREF(user,sip_destroy_user);
+ user = NULL;
+ }
+ if (user) {
ast_copy_flags(&p->flags[0], &user->flags[0], SIP_FLAGS_TO_COPY);
ast_copy_flags(&p->flags[1], &user->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
/* copy channel vars */
}
if (debug)
ast_verbose("Found user '%s'\n", user->name);
- } else {
- if (user) {
- if (!authpeer && debug)
- ast_verbose("Found user '%s', but fails host access\n", user->name);
- ASTOBJ_UNREF(user,sip_destroy_user);
- }
- user = NULL;
+ ASTOBJ_UNREF(user, sip_destroy_user);
+ return res;
}
- if (!user) {
+ /* XXX need to reindent the next block */
+
/* If we didn't find a user match, check for peers */
if (sipmethod == SIP_SUBSCRIBE)
/* For subscribes, match on peer name only */
}
}
- }
-
- if (user)
- ASTOBJ_UNREF(user, sip_destroy_user);
return res;
}