masqmail
diff src/deliver.c @ 354:08932c629849
reworked the route concept; removed the idea of the localnet
Renamed to reflect the actual meaning more clearly:
s/online_routes/query_routes/g
s/local_net_route/permanent_routes/g
Removed local_nets, which are now represented by allowed_recipients
in a permanent route. (See. examples/localnet.route)
There is no more abiguity between `local' and `local net'.
Run admin/config-transition on your config to learn how to update it.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Sun, 04 Sep 2011 11:25:38 +0200 |
parents | 332999b1303f |
children | 41958685480d |
line diff
1.1 --- a/src/deliver.c Sun Sep 04 10:23:00 2011 +0200 1.2 +++ b/src/deliver.c Sun Sep 04 11:25:38 2011 +0200 1.3 @@ -667,15 +667,34 @@ 1.4 return TRUE; 1.5 } 1.6 1.7 -gboolean 1.8 -deliver_msgout_list_online(GList * msgout_list) 1.9 +int 1.10 +deliver_remote(GList* remote_msgout_list) 1.11 { 1.12 + int ok = TRUE; 1.13 + GList *route_list = NULL; 1.14 + GList *route_node; 1.15 GList *rf_list = NULL; 1.16 gchar *connect_name = NULL; 1.17 - gboolean ok = FALSE; 1.18 - GList *route_node; 1.19 - GList *route_list; 1.20 1.21 + if (!remote_msgout_list) { 1.22 + return FALSE; 1.23 + } 1.24 + 1.25 + /* perma routes */ 1.26 + if (conf.perma_routes) { 1.27 + DEBUG(5) debugf("processing perma_routes\n"); 1.28 + 1.29 + route_list = read_route_list(conf.perma_routes, TRUE); 1.30 + foreach(route_list, route_node) { 1.31 + connect_route *route = (connect_route *) (route_node->data); 1.32 + if (!deliver_route_msg_list(route, remote_msgout_list)) { 1.33 + ok = FALSE; 1.34 + } 1.35 + } 1.36 + destroy_route_list(route_list); 1.37 + } 1.38 + 1.39 + /* query routes */ 1.40 connect_name = online_query(); 1.41 if (!connect_name) { 1.42 DEBUG(5) debugf("online query returned false\n"); 1.43 @@ -686,7 +705,7 @@ 1.44 DEBUG(5) debugf("processing query_routes\n"); 1.45 logwrite(LOG_NOTICE, "detected online configuration `%s'\n", connect_name); 1.46 1.47 - rf_list = (GList *) table_find(conf.connect_routes, connect_name); 1.48 + rf_list = (GList *) table_find(conf.query_routes, connect_name); 1.49 if (!rf_list) { 1.50 logwrite(LOG_ALERT, "route list with name '%s' not found.\n", connect_name); 1.51 return FALSE; 1.52 @@ -701,7 +720,7 @@ 1.53 foreach(route_list, route_node) { 1.54 connect_route *route = (connect_route *) (route_node->data); 1.55 /* TODO: ok gets overwritten */ 1.56 - ok = deliver_route_msg_list(route, msgout_list); 1.57 + ok = deliver_route_msg_list(route, remote_msgout_list); 1.58 } 1.59 destroy_route_list(route_list); 1.60 1.61 @@ -709,10 +728,8 @@ 1.62 } 1.63 1.64 /* 1.65 - This function searches in the list of rcpt addresses 1.66 - for local and 'local net' addresses. Remote addresses 1.67 - which are reachable only when online are treated specially 1.68 - in another function. 1.69 + This function splits the list of rcpt addresses 1.70 + into local and remote addresses and processes them accordingly. 1.71 */ 1.72 gboolean 1.73 deliver_msg_list(GList * msg_list, guint flags) 1.74 @@ -720,8 +737,7 @@ 1.75 GList *msgout_list = NULL; 1.76 GList *msg_node; 1.77 GList *local_msgout_list = NULL; 1.78 - GList *localnet_msgout_list = NULL; 1.79 - GList *other_msgout_list = NULL; 1.80 + GList *remote_msgout_list = NULL; 1.81 GList *msgout_node; 1.82 GList *alias_table = NULL; 1.83 gboolean ok = TRUE; 1.84 @@ -732,7 +748,6 @@ 1.85 msgout_list = g_list_append(msgout_list, create_msg_out(msg)); 1.86 } 1.87 1.88 - 1.89 if (conf.alias_file) { 1.90 alias_table = table_read(conf.alias_file, ':'); 1.91 } 1.92 @@ -742,7 +757,6 @@ 1.93 msg_out *msgout = (msg_out *) (msgout_node->data); 1.94 GList *rcpt_list; 1.95 GList *local_rcpt_list = NULL; 1.96 - GList *localnet_rcpt_list = NULL; 1.97 GList *other_rcpt_list = NULL; 1.98 1.99 if (!spool_lock(msgout->msg->uid)) { 1.100 @@ -767,7 +781,9 @@ 1.101 rcpt_list = aliased_rcpt_list; 1.102 } 1.103 1.104 - split_rcpts(rcpt_list, conf.local_nets, &local_rcpt_list, &localnet_rcpt_list, &other_rcpt_list); 1.105 + /* split_rcpts(rcpt_list, NULL, &local_rcpt_list, * NULL, &other_rcpt_list); */ 1.106 + local_rcpt_list = local_rcpts(rcpt_list); 1.107 + other_rcpt_list = remote_rcpts(rcpt_list); 1.108 g_list_free(rcpt_list); 1.109 1.110 /* local recipients */ 1.111 @@ -777,18 +793,11 @@ 1.112 local_msgout_list = g_list_append(local_msgout_list, local_msgout); 1.113 } 1.114 1.115 - /* local net recipients */ 1.116 - if ((flags & DLVR_LAN) && localnet_rcpt_list) { 1.117 - msg_out *localnet_msgout = clone_msg_out(msgout); 1.118 - localnet_msgout->rcpt_list = localnet_rcpt_list; 1.119 - localnet_msgout_list = g_list_append(localnet_msgout_list, localnet_msgout); 1.120 - } 1.121 - 1.122 - /* remote recipients (the rest), requires online delivery */ 1.123 + /* remote recipients, requires online delivery */ 1.124 if ((flags & DLVR_ONLINE) && other_rcpt_list) { 1.125 - msg_out *other_msgout = clone_msg_out(msgout); 1.126 - other_msgout->rcpt_list = other_rcpt_list; 1.127 - other_msgout_list = g_list_append(other_msgout_list, other_msgout); 1.128 + msg_out *remote_msgout = clone_msg_out(msgout); 1.129 + remote_msgout->rcpt_list = other_rcpt_list; 1.130 + remote_msgout_list = g_list_append(remote_msgout_list, remote_msgout); 1.131 } 1.132 } 1.133 1.134 @@ -796,7 +805,7 @@ 1.135 destroy_table(alias_table); 1.136 } 1.137 1.138 - /* actual delivery */ 1.139 + /* process local/remote msgout lists -> delivery */ 1.140 1.141 if (local_msgout_list) { 1.142 DEBUG(5) debugf("local_msgout_list\n"); 1.143 @@ -809,33 +818,10 @@ 1.144 destroy_msg_out_list(local_msgout_list); 1.145 } 1.146 1.147 - if (localnet_msgout_list) { 1.148 - GList *route_list = NULL; 1.149 - GList *route_node; 1.150 - 1.151 - DEBUG(5) debugf("localnet_msgout_list\n"); 1.152 - if (conf.local_net_routes) { 1.153 - route_list = read_route_list(conf.local_net_routes, TRUE); 1.154 - } else { 1.155 - route_list = g_list_append(NULL, create_local_route()); 1.156 - } 1.157 - 1.158 - foreach(route_list, route_node) { 1.159 - connect_route *route = (connect_route *) (route_node->data); 1.160 - if (!deliver_route_msg_list(route, localnet_msgout_list)) { 1.161 - ok = FALSE; 1.162 - } 1.163 - } 1.164 - destroy_msg_out_list(localnet_msgout_list); 1.165 - destroy_route_list(route_list); 1.166 - } 1.167 - 1.168 - if (other_msgout_list) { 1.169 - DEBUG(5) debugf("other_msgout_list\n"); 1.170 - if (!deliver_msgout_list_online(other_msgout_list)) { 1.171 - ok = FALSE; 1.172 - } 1.173 - destroy_msg_out_list(other_msgout_list); 1.174 + if (remote_msgout_list) { 1.175 + DEBUG(5) debugf("remote_msgout_list\n"); 1.176 + deliver_remote(remote_msgout_list); 1.177 + destroy_msg_out_list(remote_msgout_list); 1.178 } 1.179 1.180 /* unlock spool files */