| 523 | } |
| 524 | |
| 525 | static int match_host_pattern(const char *pattern, const char *hostname) |
| 526 | { |
| 527 | int len_p, len_h; |
| 528 | if (!strcmp(pattern, "*")) |
| 529 | return 1; |
| 530 | // Skip a possible *. at the start of the pattern |
| 531 | if (pattern[0] == '*') |
| 532 | pattern++; |
| 533 | if (pattern[0] == '.') |
| 534 | pattern++; |
| 535 | len_p = strlen(pattern); |
| 536 | len_h = strlen(hostname); |
| 537 | if (len_p > len_h) |
| 538 | return 0; |
| 539 | // Simply check if the end of hostname is equal to 'pattern' |
| 540 | if (!strcmp(pattern, &hostname[len_h - len_p])) { |
| 541 | if (len_h == len_p) |
| 542 | return 1; // Exact match |
| 543 | if (hostname[len_h - len_p - 1] == '.') |
| 544 | return 1; // The matched substring is a domain and not just a substring of a domain |
| 545 | } |
| 546 | return 0; |
| 547 | } |
| 548 | |
| 549 | int ff_http_match_no_proxy(const char *no_proxy, const char *hostname) |
| 550 | { |
no outgoing calls
no test coverage detected