Skip to content

Instantly share code, notes, and snippets.

View smfreegard's full-sized avatar

Steve Freegard smfreegard

  • Fort Systems Ltd.
  • Chichester, UK
View GitHub Profile
[root@mail1-ec2 Haraka]# diff -uNr plugins.js.orig plugins.js
--- plugins.js.orig 2012-04-14 15:22:47.575558052 +0000
+++ plugins.js 2012-04-16 17:56:01.915136250 +0000
@@ -30,6 +30,7 @@
this.full_paths = full_paths;
this.config = config;
this.hooks = {};
+ this.server = {}; // set by server.js
};
@smfreegard
smfreegard / gist:3503446
Created August 28, 2012 19:52
socket.setTimeout issues
With socket.setTimeout(300 * 1000);
write(26, "SYMBOLS SPAMC/1.3\r\n", 19) = 19
gettimeofday({1346183319, 801942}, NULL) = 0
futex(0x87386e4, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x87386e0, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x87386b8, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0xb760046c, FUTEX_WAKE_PRIVATE, 1) = 1
gettimeofday({1346183319, 802733}, NULL) = 0
write(26, "User: steve.freegard@fsl.com\r\n\r\n", 32) = 32
gettimeofday({1346183319, 803082}, NULL) = 0
Date/Time: Wed, 14 Nov 2012 17:01:53 GMT
ID : 14D54B2C-E2DE-4367-A837-E349568738E2.1
Host/IP : 188-223-62-1.zone14.bethere.co.uk [188.223.62.1]
Auth User: smf@fsl.com
Sender : steve.freegard@fsl.com
Detail : Message is infected with Eicar-Test-Signature
From: "MAILER DAEMON" <postmaster@mail1-ec2.fsl.com>
To: <steve@stevefreegard.com>
Subject: Administrative Alert
MIME-Version: 1.0
Nov 21 18:42:26 mail1-ec2 haraka[29858]: [INFO] [FE497A00-20A4-4C94-9A05-EDBA3EADC025.1] [queue/smtp_forward] forwarding to 127.0.0.1:2525
Nov 21 18:42:26 mail1-ec2 haraka[29858]: [INFO] [FE497A00-20A4-4C94-9A05-EDBA3EADC025.1] [core] hook=queue plugin=queue/smtp_forward function=hook_queue params="" retval=OK msg="2.0.0 qALIemCN030226 Message accepted for delivery (FE497A00-20A4-4C94-9A05-EDBA3EADC025.1)"
Nov 21 18:42:26 mail1-ec2 haraka[29858]: [INFO] [FE497A00-20A4-4C94-9A05-EDBA3EADC025.1] [core] hook=queue_ok plugin=queue/discard function=hook_queue_ok params="2.0.0 qALIemCN030226 Message accepted for delivery (FE497A00-20A4-4C94-9A05-EDBA3EADC025.1)" retval=OK msg=""
Nov 21 18:42:26 mail1-ec2 haraka[29858]: [NOTICE] [FE497A00-20A4-4C94-9A05-EDBA3EADC025.1] [core] queue code=OK msg="2.0.0 qALIemCN030226 Message accepted for delivery (FE497A00-20A4-4C94-9A05-EDBA3EADC025.1)"
Nov 21 18:42:26 mail1-ec2 haraka[29858]: [WARN] [FE497A00-20A4-4C94-9A05-EDBA3EADC025.1] [core] client ch1ehsobe002.messaging.micros
@smfreegard
smfreegard / gist:4178792
Created November 30, 2012 21:31
multipart bannering
Subject: multipart test
Content-Type: multipart/mixed; boundary=--=_boundary_1
MIME-Version: 1.0
prolog
----=_boundary_1
Content-Type: multipart/alternative; boundary=--=_boundary_2
----=_boundary_2
@smfreegard
smfreegard / gist:4191321
Created December 2, 2012 22:20
mongo.js
var Stream = require('stream').Stream;
exports.hook_queue = function (next, connection) {
// MongoDB configuration settings.
var databaseUrl = "localhost";
var collections = ["email"];
var db = require("mongojs").connect(databaseUrl, collections);
// basic logging so we can see if we have an email hitting the stack
this.loginfo("New inbound email detected, inserting into mongodb");
var net = require('net');
var server = net.createServer(function (client) {
var addr = client.server.address();
client.write(JSON.stringify(addr, null, '\t'));
client.end();
});
server.listen(1234, function () {
var addr = server.address();
"use strict";
var line = '" John Stirling & Jeremy Bray <johnstirling=windermere.com@mondoflyers.com>';
console.log('before match');
var match = /^("(?:[^"\\]+|\\.)*")\s*/.exec(line);
console.log('after match');
var Address = require('./address').Address;
var rewrite_to = 'steve.freegard@gmail.com';
exports.hook_data = function (next, connection) {
var txn = connection.transaction;
// Use outbound...
connection.relaying = true;
var addr = new Address(rewrite_to);
txn.rcpt_to = [ addr ];
return next();
[Unit]
Description=Haraka SMTP service daemon
After=syslog.target network.target spamassassin.service clamd@haraka.service
Conflicts=postfix.service sendmail.service exim.service
[Service]
LimitNOFILE=infinity
# The ?'s are to allow the process_title plugin enough room
# to rewrite the process title and not run out of space.
ExecStart=/usr/bin/haraka -c /etc/haraka ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????