Added instance id option to mark messages
Signed-off-by: tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
parent
1312510074
commit
0524358cef
4 changed files with 30 additions and 1 deletions
|
@ -26,4 +26,6 @@ extern uint16_t listen_port, forward_port;
|
|||
|
||||
extern int abort_on_pgp, abort_on_dkim;
|
||||
|
||||
extern char* instance_id;
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
uint16_t listen_port = 4269, forward_port = 4270;
|
||||
int abort_on_pgp = true, abort_on_dkim = true;
|
||||
char* instance_id = NULL;
|
||||
|
|
|
@ -58,6 +58,7 @@ bool detect_dkim(struct email_t* mail){
|
|||
if(strcasestr(mail->message, dkim_signatures[i]) != NULL
|
||||
&& strcasestr(mail->message, dkim_signatures[i])
|
||||
<= (mail->message+mail->header_len)){
|
||||
/* DKIM only happens inside the header, not the body! */
|
||||
points++;
|
||||
}
|
||||
|
||||
|
|
24
src/main.c
24
src/main.c
|
@ -7,6 +7,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "network.h"
|
||||
#include "config.h"
|
||||
|
@ -27,12 +30,13 @@ int main(int argc, char* argv[]){
|
|||
{"noabort-dkim",no_argument, &abort_on_dkim,0},
|
||||
{"in-port", required_argument, 0, 'i'},
|
||||
{"out-port", required_argument, 0, 'o'},
|
||||
{"instance-id", required_argument, 0, 'n'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
/* getopt_long stores the option index here. */
|
||||
int option_index = 0;
|
||||
|
||||
c = getopt_long (argc, argv, "i:o:pd",
|
||||
c = getopt_long (argc, argv, "n:i:o:pd",
|
||||
long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options. */
|
||||
|
@ -50,6 +54,10 @@ int main(int argc, char* argv[]){
|
|||
case 'o':
|
||||
forward_port = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
instance_id = optarg;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
/* getopt_long already printed an error message. */
|
||||
|
@ -61,6 +69,17 @@ int main(int argc, char* argv[]){
|
|||
}
|
||||
}
|
||||
|
||||
/* If not already specified, populate the instance ID with the sytem
|
||||
* hostname.
|
||||
*/
|
||||
if(instance_id == NULL){
|
||||
instance_id = malloc(HOST_NAME_MAX + 1);
|
||||
memset(instance_id, 0, HOST_NAME_MAX + 1);
|
||||
if(gethostname(instance_id, HOST_NAME_MAX) < 0){
|
||||
perror("gethostname failed! set instance id manually");
|
||||
}
|
||||
}
|
||||
|
||||
printf("Incoming port: %u outgoing port: %u on loopback interface\n",
|
||||
listen_port, forward_port);
|
||||
|
||||
|
@ -69,6 +88,9 @@ int main(int argc, char* argv[]){
|
|||
|
||||
printf("Ignoring DKIM signed messages: %s\n",
|
||||
abort_on_dkim ? "true" : "false");
|
||||
|
||||
printf("Instance id for messages: %s\n",
|
||||
instance_id);
|
||||
|
||||
if(init_net() < 0){
|
||||
return EXIT_FAILURE;
|
||||
|
|
Loading…
Reference in a new issue