comparison src/context.cpp @ 144:31ff00ea6bfb stable-5-24

allow parent/child to share a fully qualified env_to address
author carl
date Sun, 15 Oct 2006 12:23:17 -0700
parents ecb40aa3eaa5
children 9b9bab1d3c21
comparison
equal deleted inserted replaced
143:ecb40aa3eaa5 144:31ff00ea6bfb
462 return default_context; 462 return default_context;
463 } 463 }
464 464
465 465
466 void CONFIG::dump() { 466 void CONFIG::dump() {
467 if (default_context) default_context->dump(); 467 if (default_context) default_context->dump(true);
468 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) { 468 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) {
469 CONTEXTP c = *i; 469 CONTEXTP c = *i;
470 CONTEXTP p = c->get_parent(); 470 CONTEXTP p = c->get_parent();
471 if (!p && (c != default_context)) c->dump(); 471 if (!p && (c != default_context)) c->dump(false);
472 } 472 }
473 char buf[maxlen]; 473 char buf[maxlen];
474 for (context_map::iterator i=env_to.begin(); i!=env_to.end(); i++) { 474 for (context_map::iterator i=env_to.begin(); i!=env_to.end(); i++) {
475 char *to = (*i).first; 475 char *to = (*i).first;
476 CONTEXTP con = (*i).second; 476 CONTEXTP con = (*i).second;
525 bool CONTEXT::cover_env_to(char *to) { 525 bool CONTEXT::cover_env_to(char *to) {
526 char buffer[maxlen]; 526 char buffer[maxlen];
527 char *x = strchr(to, '@'); 527 char *x = strchr(to, '@');
528 if (x) x++; 528 if (x) x++;
529 else x = to; 529 else x = to;
530 if (*x == '\0') return true; // always allow covering addresses with no domain name, eg abuse@ 530 if (*x == '\0') return true; // always allow covering addresses with no domain name, eg abuse@
531 if (!parent && env_to.empty()) return true; // empty env_to at global level covers everything 531 if (!parent && env_to.empty()) return true; // empty env_to at global level covers everything
532 string_set::iterator i = env_to.find(x); 532 string_set::iterator i = env_to.find(x);
533 if (i != env_to.end()) return true; 533 if (i != env_to.end()) return true; // we cover the entire domain
534 if (x != to) {
535 i = env_to.find(to);
536 if (i != env_to.end()) return true; // we cover the specific email address
537 }
534 return false; 538 return false;
535 } 539 }
536 540
537 541
538 VERIFYP CONTEXT::find_verify(char *to) { 542 VERIFYP CONTEXT::find_verify(char *to) {
684 } 688 }
685 return true; 689 return true;
686 } 690 }
687 691
688 692
689 void CONTEXT::dump(int level) { 693 void CONTEXT::dump(bool isdefault, int level) {
690 char indent[maxlen]; 694 char indent[maxlen];
691 int i = min(maxlen-1, level*4); 695 int i = min(maxlen-1, level*4);
692 memset(indent, ' ', i); 696 memset(indent, ' ', i);
693 indent[i] = '\0'; 697 indent[i] = '\0';
694 char buf[maxlen]; 698 char buf[maxlen];
780 printf("%s verify %s; \n", indent, verify_host); 784 printf("%s verify %s; \n", indent, verify_host);
781 } 785 }
782 786
783 for (context_map::iterator i=children.begin(); i!=children.end(); i++) { 787 for (context_map::iterator i=children.begin(); i!=children.end(); i++) {
784 CONTEXTP c = (*i).second; 788 CONTEXTP c = (*i).second;
785 c->dump(level+1); 789 c->dump(false, level+1);
786 } 790 }
787 791
788 printf("%s env_from %s { \t// %s\n", indent, env_from_default, fullname); 792 printf("%s env_from %s { \t// %s\n", indent, env_from_default, fullname);
789 if (!env_from.empty()) { 793 if (!env_from.empty()) {
790 printf("%s // white/black/unknown \n", indent); 794 printf("%s // white/black/unknown \n", indent);
802 printf("%s %s \t%s; \n", indent, f, t->name); 806 printf("%s %s \t%s; \n", indent, f, t->name);
803 } 807 }
804 } 808 }
805 printf("%s }; \n", indent); 809 printf("%s }; \n", indent);
806 810
807 printf("%s rate_limit %d { \n", indent, default_rcpt_rate); 811 if (isdefault) {
808 for (rcpt_rates::iterator j=rcpt_per_hour.begin(); j!=rcpt_per_hour.end(); j++) { 812 printf("%s rate_limit %d { \n", indent, default_rcpt_rate);
809 char *u = (*j).first; 813 for (rcpt_rates::iterator j=rcpt_per_hour.begin(); j!=rcpt_per_hour.end(); j++) {
810 int l = (*j).second; 814 char *u = (*j).first;
811 printf("%s \"%s\" \t%d; \n", indent, u, l); 815 int l = (*j).second;
812 } 816 printf("%s \"%s\" \t%d; \n", indent, u, l);
813 printf("%s }; \n", indent); 817 }
818 printf("%s }; \n", indent);
819 }
814 820
815 printf("%s }; \n", indent); 821 printf("%s }; \n", indent);
816 } 822 }
817 823
818 824