diff options
-rw-r--r-- | main.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -108,14 +108,13 @@ int allowed_toxid_cmp(allowed_toxid *a, allowed_toxid *b) | |||
108 | return memcmp(a->toxid, b->toxid, TOX_PUBLIC_KEY_SIZE); | 108 | return memcmp(a->toxid, b->toxid, TOX_PUBLIC_KEY_SIZE); |
109 | } | 109 | } |
110 | 110 | ||
111 | /* Comparison function for rule objects */ | 111 | /* Match rule r against candidate host, port. Returns 0 for match. */ |
112 | int rule_match(rule *a, rule *b) | 112 | int rule_match(rule *r, rule *candidate) |
113 | { | 113 | { |
114 | //log_printf(L_INFO, "Comparison result: %d %d\n", strcmp(a->host, b->host), (a->port == b->port)); | 114 | bool host_match = !strcmp(r->host, "*") || !strcmp(r->host, candidate->host); |
115 | if ((strcmp(a->host, b->host)==0) && (a->port == b->port)) | 115 | bool port_match = r->port == 0 || r->port == candidate->port; |
116 | return 0; | 116 | |
117 | else | 117 | return port_match && host_match ? 0 : -1; |
118 | return -1; | ||
119 | } | 118 | } |
120 | 119 | ||
121 | void update_select_nfds(int fd) | 120 | void update_select_nfds(int fd) |