Moved to new module init structure.
[citadel.git] / citadel / internet_addressing.c
index a456e3266d418ec1efb2484d481e10cbce0f53df..123b5280dcdf7ee519fcf3551647858568723380 100644 (file)
@@ -32,7 +32,6 @@
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include "serv_extensions.h"
 #include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
@@ -94,6 +93,10 @@ int CtdlHostAlias(char *fqdn) {
                   && (!strcasecmp(&fqdn[strlen(fqdn)-strlen(host)], host)))
                        return(hostalias_directory);
 
+               if ( (!strcasecmp(type, "masqdomain"))
+                  && (!strcasecmp(&fqdn[strlen(fqdn)-strlen(host)], host)))
+                       return(hostalias_masq);
+
        }
 
        return(hostalias_nomatch);
@@ -381,6 +384,18 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) {
                processed = 1;
        }
 
+       else if (!strcasecmp(key, "Return-Path")) {
+               if (msg->cm_fields['P'] == NULL)
+                       msg->cm_fields['P'] = strdup(value);
+               processed = 1;
+       }
+
+       else if (!strcasecmp(key, "Envelope-To")) {
+               if (msg->cm_fields['V'] == NULL)
+                       msg->cm_fields['V'] = strdup(value);
+               processed = 1;
+       }
+
        /* Clean up and move on. */
        free(key);      /* Don't free 'value', it's actually the same buffer */
        return(processed);
@@ -552,7 +567,7 @@ void directory_key(char *key, char *addr) {
 /* Return nonzero if the supplied address is in a domain we keep in
  * the directory
  */
-int IsDirectory(char *addr) {
+int IsDirectory(char *addr, int allow_masq_domains) {
        char domain[256];
        int h;
 
@@ -561,6 +576,9 @@ int IsDirectory(char *addr) {
 
        h = CtdlHostAlias(domain);
 
+       if ( (h == hostalias_masq) && allow_masq_domains)
+               return(1);
+       
        if ( (h == hostalias_localhost) || (h == hostalias_directory) ) {
                return(1);
        }
@@ -586,7 +604,7 @@ void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
 
        lprintf(CTDL_DEBUG, "Dir: %s --> %s\n",
                internet_addr, citadel_addr);
-       if (IsDirectory(internet_addr) == 0) return;
+       if (IsDirectory(internet_addr, 0) == 0) return;
 
        directory_key(key, internet_addr);
 
@@ -625,7 +643,7 @@ int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen) {
        if (num_tokens(internet_addr, '@') != 2) return(-1);
 
        /* Only do lookups for domains in the directory */
-       if (IsDirectory(internet_addr) == 0) return(-1);
+       if (IsDirectory(internet_addr, 0) == 0) return(-1);
 
        directory_key(key, internet_addr);
        cdbrec = cdb_fetch(CDB_DIRECTORY, key, strlen(key) );
@@ -662,7 +680,7 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) {
                strcat(addr, " <");
                strcat(addr, msg->cm_fields['F']);
                strcat(addr, ">");
-               if (IsDirectory(msg->cm_fields['F'])) {
+               if (IsDirectory(msg->cm_fields['F'], 0)) {
                        is_harvestable = 0;
                }
        }