haraka 0.0.33 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/.githooks/pre-commit +41 -0
  2. package/.prettierignore +7 -0
  3. package/.qlty/.gitignore +7 -0
  4. package/.qlty/configs/.shellcheckrc +1 -0
  5. package/.qlty/qlty.toml +15 -0
  6. package/CHANGELOG.md +1898 -0
  7. package/CONTRIBUTORS.md +34 -0
  8. package/Dockerfile +50 -0
  9. package/LICENSE +22 -0
  10. package/Plugins.md +227 -0
  11. package/README.md +119 -4
  12. package/SECURITY.md +178 -0
  13. package/TODO +22 -0
  14. package/bin/haraka +593 -0
  15. package/bin/haraka_grep +32 -0
  16. package/config/aliases +2 -0
  17. package/config/auth_flat_file.ini +7 -0
  18. package/config/auth_vpopmaild.ini +9 -0
  19. package/config/connection.ini +79 -0
  20. package/config/delay_deny.ini +7 -0
  21. package/config/host_list +3 -0
  22. package/config/host_list_regex +6 -0
  23. package/config/http.ini +11 -0
  24. package/config/lmtp.ini +7 -0
  25. package/config/log.ini +11 -0
  26. package/config/outbound.bounce_message +18 -0
  27. package/config/outbound.bounce_message_html +36 -0
  28. package/config/outbound.bounce_message_image +106 -0
  29. package/config/outbound.ini +24 -0
  30. package/config/plugins +67 -0
  31. package/config/smtp.ini +37 -0
  32. package/config/smtp_bridge.ini +4 -0
  33. package/config/smtp_forward.ini +31 -0
  34. package/config/smtp_proxy.ini +27 -0
  35. package/config/tarpit.timeout +1 -0
  36. package/config/tls.ini +83 -0
  37. package/config/watch.ini +12 -0
  38. package/config/xclient.hosts +2 -0
  39. package/connection.js +1865 -0
  40. package/contrib/Haraka.cf +6 -0
  41. package/contrib/Haraka.pm +35 -0
  42. package/contrib/bad_smtp_server.pl +25 -0
  43. package/contrib/bsd-rc.d/haraka +63 -0
  44. package/contrib/debian-init.d/haraka +87 -0
  45. package/contrib/haraka.init +96 -0
  46. package/contrib/haraka.service +23 -0
  47. package/contrib/plugin2npm.sh +81 -0
  48. package/contrib/ubuntu-upstart/haraka.conf +27 -0
  49. package/docs/Body.md +1 -0
  50. package/docs/Config.md +1 -0
  51. package/docs/Connection.md +153 -0
  52. package/docs/CoreConfig.md +96 -0
  53. package/docs/CustomReturnCodes.md +3 -0
  54. package/docs/HAProxy.md +62 -0
  55. package/docs/Header.md +1 -0
  56. package/docs/Logging.md +129 -0
  57. package/docs/Outbound.md +210 -0
  58. package/docs/Plugins.md +372 -0
  59. package/docs/Results.md +7 -0
  60. package/docs/Transaction.md +135 -0
  61. package/docs/Tutorial.md +183 -0
  62. package/docs/deprecated/access.md +3 -0
  63. package/docs/deprecated/backscatterer.md +9 -0
  64. package/docs/deprecated/connect.rdns_access.md +53 -0
  65. package/docs/deprecated/data.headers.md +3 -0
  66. package/docs/deprecated/data.nomsgid.md +7 -0
  67. package/docs/deprecated/data.noreceived.md +11 -0
  68. package/docs/deprecated/data.rfc5322_header_checks.md +11 -0
  69. package/docs/deprecated/dkim_sign.md +97 -0
  70. package/docs/deprecated/dkim_verify.md +28 -0
  71. package/docs/deprecated/dnsbl.md +80 -0
  72. package/docs/deprecated/dnswl.md +73 -0
  73. package/docs/deprecated/lookup_rdns.strict.md +67 -0
  74. package/docs/deprecated/mail_from.access.md +52 -0
  75. package/docs/deprecated/mail_from.blocklist.md +18 -0
  76. package/docs/deprecated/mail_from.nobounces.md +8 -0
  77. package/docs/deprecated/rcpt_to.access.md +53 -0
  78. package/docs/deprecated/rcpt_to.blocklist.md +18 -0
  79. package/docs/deprecated/rcpt_to.routes.md +3 -0
  80. package/docs/deprecated/rdns.regexp.md +30 -0
  81. package/docs/plugins/aliases.md +3 -0
  82. package/docs/plugins/auth/auth_bridge.md +34 -0
  83. package/docs/plugins/auth/auth_ldap.md +4 -0
  84. package/docs/plugins/auth/auth_proxy.md +36 -0
  85. package/docs/plugins/auth/auth_vpopmaild.md +33 -0
  86. package/docs/plugins/auth/flat_file.md +40 -0
  87. package/docs/plugins/block_me.md +18 -0
  88. package/docs/plugins/data.signatures.md +11 -0
  89. package/docs/plugins/delay_deny.md +23 -0
  90. package/docs/plugins/max_unrecognized_commands.md +6 -0
  91. package/docs/plugins/prevent_credential_leaks.md +22 -0
  92. package/docs/plugins/process_title.md +42 -0
  93. package/docs/plugins/queue/deliver.md +3 -0
  94. package/docs/plugins/queue/discard.md +32 -0
  95. package/docs/plugins/queue/lmtp.md +24 -0
  96. package/docs/plugins/queue/qmail-queue.md +16 -0
  97. package/docs/plugins/queue/quarantine.md +87 -0
  98. package/docs/plugins/queue/smtp_bridge.md +32 -0
  99. package/docs/plugins/queue/smtp_forward.md +127 -0
  100. package/docs/plugins/queue/smtp_proxy.md +68 -0
  101. package/docs/plugins/queue/test.md +7 -0
  102. package/docs/plugins/rcpt_to.in_host_list.md +34 -0
  103. package/docs/plugins/rcpt_to.max_count.md +3 -0
  104. package/docs/plugins/record_envelope_addresses.md +20 -0
  105. package/docs/plugins/relay.md +3 -0
  106. package/docs/plugins/reseed_rng.md +16 -0
  107. package/docs/plugins/status.md +41 -0
  108. package/docs/plugins/tarpit.md +50 -0
  109. package/docs/plugins/tls.md +235 -0
  110. package/docs/plugins/toobusy.md +27 -0
  111. package/docs/plugins/xclient.md +10 -0
  112. package/docs/tutorials/Migrating_from_v1_to_v2.md +96 -0
  113. package/docs/tutorials/SettingUpOutbound.md +62 -0
  114. package/eslint.config.mjs +2 -0
  115. package/haraka.js +74 -0
  116. package/haraka.sh +2 -0
  117. package/http/html/404.html +58 -0
  118. package/http/html/index.html +47 -0
  119. package/http/package.json +21 -0
  120. package/line_socket.js +24 -0
  121. package/logger.js +322 -0
  122. package/outbound/client_pool.js +59 -0
  123. package/outbound/config.js +134 -0
  124. package/outbound/hmail.js +1504 -0
  125. package/outbound/index.js +349 -0
  126. package/outbound/qfile.js +93 -0
  127. package/outbound/queue.js +399 -0
  128. package/outbound/tls.js +85 -0
  129. package/outbound/todo.js +17 -0
  130. package/package.json +100 -4
  131. package/plugins/.eslintrc.yaml +3 -0
  132. package/plugins/auth/auth_base.js +261 -0
  133. package/plugins/auth/auth_bridge.js +20 -0
  134. package/plugins/auth/auth_proxy.js +227 -0
  135. package/plugins/auth/auth_vpopmaild.js +162 -0
  136. package/plugins/auth/flat_file.js +44 -0
  137. package/plugins/block_me.js +88 -0
  138. package/plugins/data.signatures.js +30 -0
  139. package/plugins/delay_deny.js +153 -0
  140. package/plugins/prevent_credential_leaks.js +61 -0
  141. package/plugins/process_title.js +197 -0
  142. package/plugins/profile.js +11 -0
  143. package/plugins/queue/deliver.js +12 -0
  144. package/plugins/queue/discard.js +27 -0
  145. package/plugins/queue/lmtp.js +45 -0
  146. package/plugins/queue/qmail-queue.js +93 -0
  147. package/plugins/queue/quarantine.js +133 -0
  148. package/plugins/queue/smtp_bridge.js +45 -0
  149. package/plugins/queue/smtp_forward.js +371 -0
  150. package/plugins/queue/smtp_proxy.js +142 -0
  151. package/plugins/queue/test.js +15 -0
  152. package/plugins/rcpt_to.host_list_base.js +65 -0
  153. package/plugins/rcpt_to.in_host_list.js +56 -0
  154. package/plugins/record_envelope_addresses.js +17 -0
  155. package/plugins/reseed_rng.js +7 -0
  156. package/plugins/status.js +274 -0
  157. package/plugins/tarpit.js +45 -0
  158. package/plugins/tls.js +164 -0
  159. package/plugins/toobusy.js +47 -0
  160. package/plugins/xclient.js +124 -0
  161. package/plugins.js +605 -0
  162. package/run_tests +11 -0
  163. package/server.js +827 -0
  164. package/smtp_client.js +504 -0
  165. package/test/.eslintrc.yaml +11 -0
  166. package/test/config/auth_flat_file.ini +5 -0
  167. package/test/config/block_me.recipient +1 -0
  168. package/test/config/block_me.senders +1 -0
  169. package/test/config/dhparams.pem +8 -0
  170. package/test/config/host_list +2 -0
  171. package/test/config/outbound_tls_cert.pem +1 -0
  172. package/test/config/outbound_tls_key.pem +1 -0
  173. package/test/config/plugins +7 -0
  174. package/test/config/smtp.ini +11 -0
  175. package/test/config/smtp_forward.ini +30 -0
  176. package/test/config/tls/example.com/_.example.com.key +28 -0
  177. package/test/config/tls/example.com/example.com.crt +25 -0
  178. package/test/config/tls/haraka.local.pem +51 -0
  179. package/test/config/tls.ini +45 -0
  180. package/test/config/tls_cert.pem +21 -0
  181. package/test/config/tls_key.pem +28 -0
  182. package/test/connection.js +820 -0
  183. package/test/fixtures/haproxy_allowed/config/connection.ini +3 -0
  184. package/test/fixtures/haproxy_disabled/config/connection.ini +3 -0
  185. package/test/fixtures/haproxy_untrusted/config/connection.ini +3 -0
  186. package/test/fixtures/line_socket.js +21 -0
  187. package/test/fixtures/todo_qfile.txt +0 -0
  188. package/test/fixtures/util_hmailitem.js +156 -0
  189. package/test/installation/config/test-plugin-flat +1 -0
  190. package/test/installation/config/test-plugin.ini +10 -0
  191. package/test/installation/config/tls.ini +1 -0
  192. package/test/installation/node_modules/load_first/index.js +5 -0
  193. package/test/installation/node_modules/load_first/package.json +11 -0
  194. package/test/installation/node_modules/test-plugin/config/test-plugin-flat +1 -0
  195. package/test/installation/node_modules/test-plugin/config/test-plugin.ini +9 -0
  196. package/test/installation/node_modules/test-plugin/package.json +5 -0
  197. package/test/installation/node_modules/test-plugin/test-plugin.js +5 -0
  198. package/test/installation/plugins/base_plugin.js +3 -0
  199. package/test/installation/plugins/folder_plugin/index.js +3 -0
  200. package/test/installation/plugins/folder_plugin/package.json +11 -0
  201. package/test/installation/plugins/inherits.js +7 -0
  202. package/test/installation/plugins/load_first.js +3 -0
  203. package/test/installation/plugins/plugin.js +1 -0
  204. package/test/installation/plugins/tls.js +3 -0
  205. package/test/logger.js +217 -0
  206. package/test/loud/config/dhparams.pem +0 -0
  207. package/test/loud/config/tls/goobered.pem +45 -0
  208. package/test/loud/config/tls.ini +43 -0
  209. package/test/mail_specimen/base64-root-part.txt +23 -0
  210. package/test/mail_specimen/varied-fold-lengths-preserve-data.txt +283 -0
  211. package/test/outbound/bounce_net_errors.js +133 -0
  212. package/test/outbound/bounce_rfc3464.js +226 -0
  213. package/test/outbound/hmail.js +210 -0
  214. package/test/outbound/index.js +385 -0
  215. package/test/outbound/qfile.js +124 -0
  216. package/test/outbound/queue.js +325 -0
  217. package/test/plugins/auth/auth_base.js +620 -0
  218. package/test/plugins/auth/auth_bridge.js +80 -0
  219. package/test/plugins/auth/auth_vpopmaild.js +81 -0
  220. package/test/plugins/auth/flat_file.js +123 -0
  221. package/test/plugins/block_me.js +141 -0
  222. package/test/plugins/data.signatures.js +111 -0
  223. package/test/plugins/delay_deny.js +262 -0
  224. package/test/plugins/prevent_credential_leaks.js +174 -0
  225. package/test/plugins/process_title.js +141 -0
  226. package/test/plugins/queue/deliver.js +98 -0
  227. package/test/plugins/queue/discard.js +78 -0
  228. package/test/plugins/queue/lmtp.js +137 -0
  229. package/test/plugins/queue/qmail-queue.js +98 -0
  230. package/test/plugins/queue/quarantine.js +80 -0
  231. package/test/plugins/queue/smtp_bridge.js +152 -0
  232. package/test/plugins/queue/smtp_forward.js +1023 -0
  233. package/test/plugins/queue/smtp_proxy.js +138 -0
  234. package/test/plugins/rcpt_to.host_list_base.js +102 -0
  235. package/test/plugins/rcpt_to.in_host_list.js +186 -0
  236. package/test/plugins/record_envelope_addresses.js +66 -0
  237. package/test/plugins/reseed_rng.js +34 -0
  238. package/test/plugins/status.js +207 -0
  239. package/test/plugins/tarpit.js +90 -0
  240. package/test/plugins/tls.js +86 -0
  241. package/test/plugins/toobusy.js +198 -0
  242. package/test/plugins/xclient.js +119 -0
  243. package/test/plugins.js +230 -0
  244. package/test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_fixed +0 -0
  245. package/test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka +0 -0
  246. package/test/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka +0 -0
  247. package/test/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka +0 -0
  248. package/test/queue/zero-length +0 -0
  249. package/test/server.js +1012 -0
  250. package/test/smtp_client.js +1303 -0
  251. package/test/tls_socket.js +321 -0
  252. package/test/transaction.js +554 -0
  253. package/tls_socket.js +771 -0
  254. package/transaction.js +267 -0
@@ -0,0 +1,6 @@
1
+ loadplugin Mail::SpamAssassin::Plugin::Haraka Haraka.pm
2
+
3
+ ifplugin Mail::SpamAssassin::Plugin::Haraka
4
+ header __HARAKA eval:get_haraka_uuid()
5
+ endif
6
+
@@ -0,0 +1,35 @@
1
+ package Mail::SpamAssassin::Plugin::Haraka;
2
+ my $VERSION = 0.1;
3
+
4
+ use warnings;
5
+ use strict;
6
+ use Mail::SpamAssassin::Plugin;
7
+ use vars qw(@ISA);
8
+ @ISA = qw(Mail::SpamAssassin::Plugin);
9
+
10
+ sub dbg {
11
+ Mail::SpamAssassin::Plugin::dbg ("Haraka: @_");
12
+ }
13
+
14
+ sub new {
15
+ my ($class, $mailsa) = @_;
16
+ $class = ref($class) || $class;
17
+ my $self = $class->SUPER::new($mailsa);
18
+ bless ($self, $class);
19
+ $self->register_eval_rule("get_haraka_uuid");
20
+ }
21
+
22
+ sub get_haraka_uuid {
23
+ my ($self, $pms) = @_;
24
+
25
+ # Add last external IP
26
+ my $le = $pms->get_tag('LASTEXTERNALIP');
27
+ if(defined($le) && $le) {
28
+ $pms->set_spamd_result_item( sub { return "last-external=$le"; } );
29
+ }
30
+ my $header = $pms->get("X-Haraka-UUID");
31
+ if(defined($header) && $header) {
32
+ $pms->set_spamd_result_item( sub { return "haraka-uuid=$header"; } );
33
+ }
34
+ return 0;
35
+ }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/perl
2
+
3
+ use warnings;
4
+ use strict;
5
+
6
+ use IO::Socket;
7
+
8
+ my $server = IO::Socket::INET->new(Listen => 5, LocalPort => 2525, Proto => "tcp");
9
+ $server || die $!;
10
+
11
+ while (my $client = $server->accept()) {
12
+ print "Got connection\n";
13
+ $client->print("220 hostname\r\n");
14
+ my $helo = <$client>;
15
+ $client->print("250 hi\r\n");
16
+ my $mail = <$client>;
17
+ $client->print("250 ok\r\n");
18
+ my $rcpt = <$client>;
19
+ $client->print("250 ok\r\n");
20
+ my $data = <$client>;
21
+ $client->print("354 ok\r\n");
22
+ my $line = <$client>;
23
+ $client->close();
24
+ print "Closed client\n";
25
+ }
@@ -0,0 +1,63 @@
1
+ #!/bin/sh
2
+ # USAGE: rename this as 'haraka' and drop it in /usr/local/etc/rc.d
3
+ # tested on FreeBSD. Should work on NetBSD and Dragonfly
4
+
5
+ # PROVIDE: haraka
6
+ # REQUIRE: NETWORKING ldconfig
7
+ # KEYWORD: shutdown
8
+
9
+ PATH="$PATH:/usr/local/bin"
10
+
11
+ . /etc/rc.subr
12
+
13
+ name="haraka"
14
+ rcvar="haraka_enable"
15
+
16
+ command="/usr/local/bin/haraka"
17
+ pidfile="/var/run/${name}.pid"
18
+
19
+ haraka_flags=${haraka_flags:="-c /data"}
20
+
21
+ start_cmd="start"
22
+ status_cmd="status"
23
+ stop_cmd="stop"
24
+
25
+ load_rc_config $name
26
+
27
+ start()
28
+ {
29
+ /usr/local/bin/node /usr/local/bin/haraka $haraka_flags
30
+ }
31
+
32
+ status()
33
+ {
34
+ if [ -f $pidfile ];
35
+ then
36
+ LPID=`cat $pidfile`
37
+ LPROC=`/bin/ps -p $PID`
38
+ if [ -n $LPROC ];
39
+ then
40
+ echo "$name is running as $LPID"
41
+ else
42
+ echo "$name is not running"
43
+ fi
44
+ else
45
+ echo "$name is not running"
46
+ fi
47
+ }
48
+
49
+ stop()
50
+ {
51
+ if [ -f $pidfile ];
52
+ then
53
+ kill `cat $pidfile`
54
+ if [ -f $pidfile ];
55
+ then
56
+ rm $pidfile
57
+ fi
58
+ else
59
+ echo "no PID file!"
60
+ fi
61
+ }
62
+
63
+ run_rc_command "$1"
@@ -0,0 +1,87 @@
1
+ #!/bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: haraka
4
+ # Required-Start: $local_fs $remote_fs $network $syslog $named
5
+ # Required-Stop: $local_fs $remote_fs $network $syslog $named
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # X-Interactive: true
9
+ # Short-Description: Start/stop haraka SMTP server
10
+ ### END INIT INFO
11
+ # Thx to author of http://www.thegeekstuff.com/2012/03/lsbinit-script/
12
+
13
+
14
+ DAEMON="/usr/local/bin/haraka"
15
+ NAME="haraka"
16
+ APP_DIR="/etc/haraka"
17
+ CONFIG="$APP_DIR/config/smtp.ini"
18
+ MAX_OPEN_FILES=65535
19
+ EXEC_OPTS="-c $APP_DIR"
20
+ PIDFILE="/var/run/$NAME/smtp.pid"
21
+
22
+ . /lib/lsb/init-functions
23
+
24
+
25
+ case "$1" in
26
+ start)
27
+ # Checked the PID file exists and check the actual status of process
28
+ if [ -e $PIDFILE ]; then
29
+ status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?"
30
+ # If the status is SUCCESS then don't need to start again.
31
+ if [ $status = "0" ]; then
32
+ exit # Exit
33
+ fi
34
+ fi
35
+ # Start the daemon.
36
+ log_daemon_msg "Starting the process" "$NAME"
37
+ # Start the daemon with the help of start-stop-daemon
38
+ # Log the message appropriately
39
+ if start-stop-daemon --start --oknodo --pidfile $PIDFILE --exec $DAEMON -- $EXEC_OPTS; then
40
+ log_end_msg 0
41
+ else
42
+ log_end_msg 1
43
+ fi
44
+ ;;
45
+ stop)
46
+ # Stop the daemon.
47
+ if [ -e $PIDFILE ]; then
48
+ status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" && status="0" || status="$?"
49
+ if [ "$status" = 0 ]; then
50
+ start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
51
+ /bin/rm -rf $PIDFILE
52
+ fi
53
+ else
54
+ log_daemon_msg "$NAME process is not running"
55
+ log_end_msg 0
56
+ fi
57
+ ;;
58
+ restart)
59
+ # Restart the daemon.
60
+ $0 stop && sleep 2 && $0 start
61
+ ;;
62
+ status)
63
+ # Check the status of the process.
64
+ if [ -e $PIDFILE ]; then
65
+ status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $?
66
+ else
67
+ log_daemon_msg "$NAME Process is not running"
68
+ log_end_msg 0
69
+ fi
70
+ ;;
71
+ reload)
72
+ # Reload the process. Basically sending some signal to a daemon to reload
73
+ # it configurations.
74
+ if [ -e $PIDFILE ]; then
75
+ start-stop-daemon --stop --oknodo --signal 1 --quiet --pidfile $PIDFILE --name $NAME
76
+ log_success_msg "$NAME process reloaded successfully"
77
+ else
78
+ log_failure_msg "$PIDFILE does not exists"
79
+ fi
80
+ ;;
81
+ *)
82
+ # For invalid arguments, print the usage message.
83
+ echo "Usage: $0 {start|stop|restart|reload|status}"
84
+ exit 2
85
+ ;;
86
+ esac
87
+ exit $?
@@ -0,0 +1,96 @@
1
+ #!/bin/sh
2
+ #
3
+ # Haraka
4
+ #
5
+ # chkconfig: 2345 80 30
6
+ # description: Node.js Mail Server
7
+ #
8
+
9
+ # Source function library.
10
+ . /etc/rc.d/init.d/functions
11
+
12
+ exec="/usr/local/bin/haraka"
13
+ prog="haraka"
14
+ config="/etc/haraka/config/smtp.ini"
15
+
16
+ [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
17
+
18
+ [ -z "$max_open_files" ] && max_open_files=65535
19
+
20
+ lockfile=/var/lock/subsys/$prog
21
+
22
+ start() {
23
+ [ -x $exec ] || exit 5
24
+ [ -f $config ] || exit 6
25
+ echo -n $"Starting $prog: "
26
+ ulimit -n $max_open_files
27
+ daemon "$exec -c /etc/haraka 2>&1 >> /var/log/haraka.log"
28
+ retval=$?
29
+ echo
30
+ [ $retval -eq 0 ] && touch $lockfile
31
+ return $retval
32
+ }
33
+
34
+ stop() {
35
+ echo -n $"Stopping $prog: "
36
+ killproc $prog
37
+ retval=$?
38
+ echo
39
+ rm -f $lockfile
40
+ return $retval
41
+ }
42
+
43
+ restart() {
44
+ stop
45
+ start
46
+ }
47
+
48
+ reload() {
49
+ restart
50
+ }
51
+
52
+ force_reload() {
53
+ restart
54
+ }
55
+
56
+ rh_status() {
57
+ # run checks to determine if the service is running or use generic status
58
+ status $prog
59
+ }
60
+
61
+ rh_status_q() {
62
+ rh_status >/dev/null 2>&1
63
+ }
64
+
65
+
66
+ case "$1" in
67
+ start)
68
+ rh_status_q && exit 0
69
+ $1
70
+ ;;
71
+ stop)
72
+ rh_status_q || exit 0
73
+ $1
74
+ ;;
75
+ restart)
76
+ $1
77
+ ;;
78
+ reload)
79
+ rh_status_q || exit 7
80
+ $1
81
+ ;;
82
+ force-reload)
83
+ force_reload
84
+ ;;
85
+ status)
86
+ rh_status
87
+ ;;
88
+ condrestart|try-restart)
89
+ rh_status_q || exit 0
90
+ restart
91
+ ;;
92
+ *)
93
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
94
+ exit 2
95
+ esac
96
+ exit $?
@@ -0,0 +1,23 @@
1
+ #
2
+ # systemd service file for Haraka
3
+ #
4
+ # Ensure that `daemonize` in `smtp.ini` is set to `false` (which is the default value).
5
+ #
6
+ # Put this file in /etc/systemd/system, modify the paths to suit, then run:
7
+ # sudo systemctl enable haraka
8
+ # sudo systemctl start haraka
9
+ #
10
+
11
+ [Unit]
12
+ Description=Haraka MTA
13
+ After=syslog.target network.target remote-fs.target nss-lookup.target
14
+
15
+ [Service]
16
+ Type=simple
17
+ PIDFile=/var/run/haraka.pid
18
+ ExecStart=/usr/bin/haraka -c /path/to/your/config
19
+ KillMode=process
20
+ PrivateTmp=true
21
+
22
+ [Install]
23
+ WantedBy=multi-user.target
@@ -0,0 +1,81 @@
1
+ #!/bin/sh
2
+
3
+ usage()
4
+ {
5
+ echo "$0 \$plugin_name"
6
+ exit
7
+ }
8
+
9
+ if [ -z "$1" ]; then
10
+ usage
11
+ fi
12
+
13
+ export GITHUB_ORG="haraka"
14
+ export PLUGIN_NAME="haraka-plugin-$1"
15
+ export PLUGIN_REPO="../$PLUGIN_NAME"
16
+ export GIT_CMD="git -C $PLUGIN_REPO"
17
+
18
+ if [ -d "$PLUGIN_REPO" ]; then
19
+ echo "repo exists at $PLUGIN_REPO"
20
+ else
21
+ git clone git@github.com:haraka/haraka-plugin-template.git "$PLUGIN_REPO" || exit
22
+ $GIT_CMD remote rm origin || exit
23
+ $GIT_CMD remote add origin "git@github.com:$GITHUB_ORG/$PLUGIN_NAME.git" || exit
24
+ fi
25
+
26
+ if grep template "$PLUGIN_REPO/README.md"; then
27
+ echo "redressing as $PLUGIN_NAME"
28
+ sed -i '' -e "s/template/${1}/g" "$PLUGIN_REPO/README.md"
29
+
30
+ sed -i '' \
31
+ -e "s/template/${1}/g" \
32
+ -e "s/template\.ini/$1.ini/" \
33
+ "$PLUGIN_REPO/test/index.js"
34
+
35
+ sed -i '' -e "s/template/${1}/g" "$PLUGIN_REPO/package.json"
36
+
37
+ sed -i '' \
38
+ -e "s/_template/_${1}/g" \
39
+ -e "s/template\.ini/$1.ini/" \
40
+ "$PLUGIN_REPO/index.js"
41
+
42
+ $GIT_CMD mv config/template.ini "config/$1.ini"
43
+
44
+ $GIT_CMD add package.json README.md index.js test config
45
+ $GIT_CMD commit -m "publish $1 as NPM module"
46
+
47
+ $GIT_CMD rm redress.sh
48
+ fi
49
+
50
+ if [ -f "docs/plugins/$1.md" ]; then
51
+ echo "copying docs/plugin/$1.md to $PLUGIN_REPO/README.md"
52
+ head -n8 "$PLUGIN_REPO/README.md" > foo.md
53
+ cat "docs/plugins/$1.md" >> foo.md
54
+ tail -n14 "$PLUGIN_REPO/README.md" >> foo.md
55
+ mv foo.md "$PLUGIN_REPO/README.md"
56
+ git rm "docs/plugins/$1.md" || exit
57
+ fi
58
+
59
+ if [ -f "config/$1.ini" ]; then
60
+ echo "copying $1.ini"
61
+ cp "config/$1.ini" "$PLUGIN_REPO/config/$1.ini"
62
+ git rm "config/$1.ini"
63
+ $GIT_CMD add "config/$1.ini"
64
+ fi
65
+
66
+ if [ -f "plugins/$1.js" ]; then
67
+ echo "copying plugins/$1.js"
68
+ cp "plugins/$1.js" "$PLUGIN_REPO/index.js"
69
+ tee "plugins/$1.js" <<DEPRECATED
70
+ exports.register = function () {
71
+ this.logerror('This plugin has moved. See https://github.com/haraka/haraka-plugin-$1');
72
+ }
73
+ DEPRECATED
74
+ $GIT_CMD add index.js
75
+ fi
76
+
77
+ if [ -f "test/plugins/$1.js" ]; then
78
+ echo "copying test/plugins/$1.js"
79
+ cp "test/plugins/$1.js" "$PLUGIN_REPO/test/index.js"
80
+ git rm "test/plugins/$1.js"
81
+ fi
@@ -0,0 +1,27 @@
1
+ # haraka - nodejs email server
2
+ #
3
+ # Ubuntu Upstart script (place in /etc/init and run "initctl start haraka")
4
+ # (Assumes running w/the daemonize plugin)
5
+ #
6
+ # Contributed by "David Weekly" <david@weekly.org>
7
+ #
8
+
9
+ description "Haraka Email Server"
10
+
11
+ start on (local-filesystems and net-device-up IFACE=eth0)
12
+ stop on shutdown
13
+
14
+ respawn
15
+ respawn limit 10 5
16
+ umask 022
17
+ limit nofile 65535 65535
18
+
19
+ console none
20
+
21
+ pre-start script
22
+ test -x /usr/local/bin/haraka || { stop; exit 0; }
23
+ test -c /dev/null || { stop; exit 0; }
24
+ end script
25
+
26
+ expect fork
27
+ exec /usr/local/bin/haraka -c /etc/haraka
package/docs/Body.md ADDED
@@ -0,0 +1 @@
1
+ moved to [Body](https://github.com/haraka/email-message#body)
package/docs/Config.md ADDED
@@ -0,0 +1 @@
1
+ This documentation has moved to [haraka-config](https://github.com/haraka/haraka-config).
@@ -0,0 +1,153 @@
1
+ # Connection Object
2
+
3
+ For each connection to Haraka there is one connection object. It is the first argument passed to almost every plugin hook and is the primary context object plugins use to inspect and act on the SMTP session.
4
+
5
+ ## Properties
6
+
7
+ ### connection.uuid
8
+
9
+ A unique UUID for this connection. Used as the connection identifier in logs and inherited by `transaction.uuid`.
10
+
11
+ ### connection.remote
12
+
13
+ Information about the host connecting to Haraka.
14
+
15
+ - `ip` — remote IP address
16
+ - `port` — remote TCP port
17
+ - `host` — reverse DNS of the remote IP (populated by the `connect.rdns_access` / `connect` hooks)
18
+ - `info` — free-form descriptor (e.g. populated by FCrDNS)
19
+ - `closed` — `true` once the remote end has dropped the connection
20
+ - `is_private` — `true` if the remote IP is in a private range (RFC 1918, loopback, link-local, etc.)
21
+ - `is_local` — `true` if the remote IP is localhost / loopback
22
+
23
+ ### connection.local
24
+
25
+ Information about the Haraka server endpoint handling this connection.
26
+
27
+ - `ip` — the IP of the Haraka server, as reported by the OS
28
+ - `port` — the port number handling the connection
29
+ - `host` — the primary host name of the Haraka server
30
+ - `info` — `Haraka` (with `/<version>` appended when `headers.show_version` is enabled in `connection.ini`)
31
+
32
+ ### connection.hello
33
+
34
+ The greeting given by the client.
35
+
36
+ - `verb` — `EHLO` or `HELO`, whichever the client used
37
+ - `host` — the hostname argument
38
+
39
+ ### connection.tls
40
+
41
+ State of the TLS layer on this connection.
42
+
43
+ - `enabled` — `true` once STARTTLS has been negotiated (or the listener is `smtps`)
44
+ - `advertised` — `true` if Haraka advertised STARTTLS in the EHLO response
45
+ - `verified` — `true` if the peer certificate validated against the configured CAs
46
+ - `cipher` — the negotiated cipher object (`name`, `version`, …)
47
+ - `verifyError` — the verification error, if any
48
+ - `peerCertificate` — the parsed peer certificate (when client certs are used)
49
+
50
+ ### connection.proxy
51
+
52
+ Proxy-protocol state, set when the connection arrived via HAProxy (see [HAProxy.md](HAProxy.md)).
53
+
54
+ - `allowed` — `true` if the remote IP is in the `haproxy.hosts` allow-list
55
+ - `ip` — the proxy server's IP (the real client IP appears in `connection.remote.ip` once PROXY is parsed)
56
+ - `type` — currently `null` or `'haproxy'`
57
+
58
+ ### connection.notes
59
+
60
+ A plain object that persists for the lifetime of the connection. Use it to share state between plugin hooks. For structured per-test results prefer `connection.results`. See also [haraka-notes](https://github.com/haraka/haraka-notes).
61
+
62
+ ### connection.results
63
+
64
+ Structured store for plugin results. See [haraka-results](https://github.com/haraka/haraka-results).
65
+
66
+ ### connection.transaction
67
+
68
+ The current `Transaction` object. Valid between `MAIL FROM` and the end of `queue` / `RSET` (or until `MAIL FROM` is rejected). See [Transaction.md](Transaction.md).
69
+
70
+ ### connection.relaying
71
+
72
+ Boolean. `true` if this connection is allowed to relay (i.e. deliver mail outbound). Normally set by an auth plugin or an IP allow-list. Reading or writing this property transparently routes through the current transaction when one exists, so the flag survives across multiple messages in a single connection only when set on the connection.
73
+
74
+ ### connection.capabilities
75
+
76
+ Array of ESMTP capabilities advertised in the EHLO response (e.g. `['PIPELINING', '8BITMIME', 'SIZE 0', 'STARTTLS', 'AUTH PLAIN LOGIN']`). Plugins may push additional capability strings during the `capabilities` hook.
77
+
78
+ ### connection.esmtp
79
+
80
+ `true` if the client used `EHLO` (as opposed to `HELO`).
81
+
82
+ ### connection.pipelining
83
+
84
+ `true` once Haraka has advertised, and the client has used, SMTP pipelining.
85
+
86
+ ### connection.early_talker
87
+
88
+ `true` if the client sent data before Haraka issued its banner — a
89
+ common spam-bot signal.
90
+
91
+ ### connection.tran_count
92
+
93
+ Number of transactions completed on this connection.
94
+
95
+ ### connection.rcpt_count / connection.msg_count
96
+
97
+ Per-disposition counters (`accept`, `tempfail`, `reject`) tracking
98
+ recipients and full messages on this connection.
99
+
100
+ ### connection.start_time
101
+
102
+ Connection start time, in epoch milliseconds (`Date.now()`).
103
+
104
+ ### connection.last_response
105
+
106
+ The last SMTP response line Haraka sent to the client.
107
+
108
+ ### connection.last_reject
109
+
110
+ The text of the last rejection issued to this client (used by
111
+ `max_unrecognized_commands` and similar throttling plugins).
112
+
113
+ ### connection.errors
114
+
115
+ Count of protocol errors on this connection.
116
+
117
+ ### connection.current_line
118
+
119
+ Low-level. The current line as sent by the remote end, verbatim. Useful
120
+ for botnet fingerprinting.
121
+
122
+ ### connection.state
123
+
124
+ The connection's protocol state — one of the values in `haraka-constants`'s `connection.state` table (`PAUSE`, `CMD`, `LOOP`, `DATA`, `DISCONNECTING`, `DISCONNECTED`).
125
+
126
+ ## Methods
127
+
128
+ ### connection.respond(code, msg, cb)
129
+
130
+ Send an SMTP response to the client. `code` is the numeric SMTP code, `msg` is the human-readable text (a string or an array of strings for a multi-line response). The callback fires when the response has been written.
131
+
132
+ ### connection.disconnect()
133
+
134
+ Close the connection after running the `disconnect` hook.
135
+
136
+ ### connection.reset_transaction(cb)
137
+
138
+ Tear down the current transaction (equivalent to `RSET`) and invoke `cb` when complete.
139
+
140
+ ### connection.set(path, value)
141
+
142
+ Assign a nested property safely, e.g. `connection.set('remote.host', 'mx.example.com')`. Setting `remote.ip`
143
+ automatically recomputes `remote.is_private` / `remote.is_local`.
144
+
145
+ ### connection.get(path)
146
+
147
+ Read a nested property, returning `undefined` if any segment is missing.
148
+
149
+ ### connection.loginfo / lognotice / logwarn / logerror / logdebug / logcrit / logalert / logemerg / logprotocol / logdata
150
+
151
+ Log at the named level. Each takes either `(msg)` or `(plugin, msg, data)`.
152
+
153
+ See [Logging.md](Logging.md).