-- added the DOMAIN LOCATION queue command that will return if a domain is local or remote. Queue agents should now be able to use this sequence as needed.

--  TODO: add in domain relay code
This commit is contained in:
pfelt
2007-10-08 21:19:43 +00:00
parent 838d06a67e
commit 87f01f576b
4 changed files with 40 additions and 0 deletions
+9
View File
@@ -60,6 +60,12 @@ CalculateCheckQueueLimit(unsigned long concurrent, unsigned long sequential)
return(sequential);
}
int hostedSortFunc(const void *str1, const void *str2) {
int i = strcasecmp(*(char **)str1, *(char **)str2);
return i;
}
static BongoConfigItem trustedHostsConfig[] = {
{ BONGO_JSON_STRING, NULL, &Conf.trustedHosts},
{ BONGO_JSON_NULL, NULL, NULL }
@@ -186,6 +192,9 @@ ReadConfiguration (BOOL *recover)
Conf.bounceHandling &= ~BOUNCE_RETURN;
}
/* sort the hostedDomains to make searching later faster. */
BongoArraySort(Conf.hostedDomains, (ArrayCompareFunc)hostedSortFunc);
/* now let's iterate over the hostedDomains and read in any aliasing information for those domains */
{
Conf.aliasList = BongoArrayNew(sizeof(struct _AliasStruct), Conf.hostedDomains->len);
+2
View File
@@ -122,4 +122,6 @@ BOOL ReadConfiguration(BOOL *recover);
long CalculateCheckQueueLimit(unsigned long concurrent, unsigned long sequential);
int hostedSortFunc(const void *str1, const void *str2);
#endif /* _DELIVERYQUEUE_H */
+3
View File
@@ -113,6 +113,9 @@
#define NMAP_ADDRESS_RESOLVE_COMMAND "ADDRESS RESOLVE"
#define NMAP_ADDRESS_RESOLVE_HELP "ADDRESS RESOLVE - Determine if an email address is local or remote and resolve any aliasing.\r\n"
#define NMAP_DOMAIN_LOCATION_COMMAND "DOMAIN LOCATION"
#define NMAP_DOMAIN_LOCATION_HELP "DOMAIN LOCATION - Determine if a domain is local or remote.\r\n"
#define MSG1000LOCAL "1000 %s LOCAL\r\n"
#define MSG1001RELAY "1001 %s RELAY\r\n"
#define MSG1002REMOTE "1002 %s REMOTE\r\n"
+26
View File
@@ -44,6 +44,7 @@ static int CommandPass(void *param);
static int CommandQuit(void *param);
static int CommandHelp(void *param);
static int CommandAddressResolve(void *param);
static int CommandDomainLocation(void *param);
int aliasFindFunc(const void *str, const void *node);
static ProtocolCommand authCommands[] = {
@@ -52,6 +53,7 @@ static ProtocolCommand authCommands[] = {
{ NMAP_PASS_COMMAND, NMAP_PASS_HELP, sizeof(NMAP_PASS_COMMAND) - 1, CommandPass, NULL, NULL },
{ NMAP_QUIT_COMMAND, NMAP_QUIT_HELP, sizeof(NMAP_QUIT_COMMAND) - 1, CommandQuit, NULL, NULL },
{ NMAP_ADDRESS_RESOLVE_COMMAND, NMAP_ADDRESS_RESOLVE_HELP, sizeof(NMAP_ADDRESS_RESOLVE_COMMAND) -1, CommandAddressResolve, NULL, NULL },
{ NMAP_DOMAIN_LOCATION_COMMAND, NMAP_DOMAIN_LOCATION_HELP, sizeof(NMAP_DOMAIN_LOCATION_COMMAND) -1, CommandDomainLocation, NULL, NULL },
{ NULL, NULL, 0, NULL, NULL, NULL }
};
@@ -97,6 +99,8 @@ static ProtocolCommand commands[] = {
{ NMAP_QUIT_COMMAND, NMAP_QUIT_HELP, sizeof(NMAP_QUIT_COMMAND) - 1, CommandQuit, NULL, NULL },
{ NMAP_QWAIT_COMMAND, NMAP_QWAIT_HELP, sizeof(NMAP_QWAIT_COMMAND) - 1, CommandQwait, NULL, NULL },
{ NMAP_QFLUSH_COMMAND, NMAP_QFLUSH_HELP, sizeof(NMAP_QFLUSH_COMMAND) -1, CommandQflush, NULL, NULL },
{ NMAP_ADDRESS_RESOLVE_COMMAND, NMAP_ADDRESS_RESOLVE_HELP, sizeof(NMAP_ADDRESS_RESOLVE_COMMAND) -1, CommandAddressResolve, NULL, NULL },
{ NMAP_DOMAIN_LOCATION_COMMAND, NMAP_DOMAIN_LOCATION_HELP, sizeof(NMAP_DOMAIN_LOCATION_COMMAND) -1, CommandDomainLocation, NULL, NULL },
{ NULL, NULL, 0, NULL, NULL, NULL }
};
@@ -105,6 +109,11 @@ int aliasFindFunc(const void *str, const void *node) {
return strcasecmp((char *)str, n->original);
}
int hostedFindFunc(const void *str1, const void *str2) {
int i = strcasecmp((char *)str1, *(char **)str2);
return i;
}
/* TODO: error handling on MsgParseAddress() */
BOOL aliasing(Connection *conn, char *addr, int *cnt) {
unsigned char *local = NULL;
@@ -176,6 +185,23 @@ int CommandAddressResolve(void *param) {
return 0;
}
int CommandDomainLocation(void *param) {
QueueClient *client = (QueueClient *)param;
/* first find the domain in the request */
unsigned char *domain = client->buffer + 16;
/* now search for it */
int idx = BongoArrayFindSorted(Conf.hostedDomains, domain, (ArrayCompareFunc)hostedFindFunc);
if (idx > -1) {
ConnWriteF(client->conn, MSG1000LOCAL, domain);
} else {
/* TODO: add the relay domain stuff */
ConnWriteF(client->conn, MSG1002REMOTE, domain);
}
return 0;
}
int
CommandAuth(void *param)
{