- } else if (withport && cmpsaddrwop(remote, p->remote) == 0) {
- // for withport: save the pointer for the best-effort search
- p_withport_besteffort = p;
- }
+ }
+ if (p->remote_prefix == 0) {
+ if ((!withport && cmpsaddrwop(remote, p->remote) == 0)
+ || (withport && cmpsaddrstrict(remote, p->remote) == 0)) {
+ plog(ASL_LEVEL_DEBUG, "configuration found for %s.\n", buf);
+ return p;
+ } else if (withport && cmpsaddrwop(remote, p->remote) == 0) {
+ // for withport: save the pointer for the best-effort search
+ p_withport_besteffort = p;
+ }
+ } else {
+ if ((!withport && cmpsaddrwop_withprefix(remote, p->remote, p->remote_prefix) == 0)
+ || (withport && cmpsaddrstrict_withprefix(remote, p->remote, p->remote_prefix) == 0)) {
+ if (p->remote_prefix >= last_prefix) {
+ p_with_prefix = p;
+ last_prefix = p->remote_prefix;
+ }
+ } else if (withport && cmpsaddrwop_withprefix(remote, p->remote, p->remote_prefix) == 0) {
+ if (p->remote_prefix >= last_prefix) {
+ p_with_prefix_besteffort = p;
+ last_prefix = p->remote_prefix;
+ }
+ }
+ }