projects
/
org.ibex.mail.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8b22f8f
)
drop connection after too many bad recipients
author
adam
<adam@megacz.com>
Thu, 5 Jul 2007 01:43:28 +0000
(
01:43
+0000)
committer
adam
<adam@megacz.com>
Thu, 5 Jul 2007 01:43:28 +0000
(
01:43
+0000)
darcs-hash:
20070705014328
-5007d-
98673b8388a11a5cbd529b763c73d880612a0d55
.gz
src/org/ibex/mail/SMTP.java
patch
|
blob
|
history
diff --git
a/src/org/ibex/mail/SMTP.java
b/src/org/ibex/mail/SMTP.java
index
ba4069f
..
0ae8890
100644
(file)
--- a/
src/org/ibex/mail/SMTP.java
+++ b/
src/org/ibex/mail/SMTP.java
@@
-94,6
+94,7
@@
public class SMTP {
boolean ehlo = false;
String remotehost = null;
String authenticatedAs = null;
boolean ehlo = false;
String remotehost = null;
String authenticatedAs = null;
+ int failedRcptCount = 0;
for(String command = conn.readln(); ; command = conn.readln()) try {
if (command == null) return;
Log.warn("**"+conn.getRemoteAddress()+"**", command);
for(String command = conn.readln(); ; command = conn.readln()) try {
if (command == null) return;
Log.warn("**"+conn.getRemoteAddress()+"**", command);
@@
-178,21
+179,32
@@
public class SMTP {
command = command.substring(8).trim();
if(command.indexOf(' ') != -1) command = command.substring(0, command.indexOf(' '));
Address addr = new Address(command);
command = command.substring(8).trim();
if(command.indexOf(' ') != -1) command = command.substring(0, command.indexOf(' '));
Address addr = new Address(command);
- if (addr.isLocal()) {
- // FEATURE: should check the address further and give 550 if undeliverable
- conn.println("250 " + addr + " is on this machine; I will deliver it");
- to.addElement(addr);
- } else if (conn.getRemoteAddress().isLoopbackAddress() || (from!=null&&from.toString().indexOf("johnw")!=-1)) {
+ if (conn.getRemoteAddress().isLoopbackAddress() || (from!=null&&from.toString().indexOf("johnw")!=-1)) {
conn.println("250 you are connected locally, so I will let you send");
to.addElement(addr);
conn.println("250 you are connected locally, so I will let you send");
to.addElement(addr);
- whitelist.addWhitelist(addr);
+ if (!whitelist.isWhitelisted(addr))
+ whitelist.addWhitelist(addr);
} else if (authenticatedAs!=null) {
conn.println("250 you are authenticated as "+authenticatedAs+", so I will let you send");
to.addElement(addr);
} else if (authenticatedAs!=null) {
conn.println("250 you are authenticated as "+authenticatedAs+", so I will let you send");
to.addElement(addr);
- whitelist.addWhitelist(addr);
+ if (!whitelist.isWhitelisted(addr))
+ whitelist.addWhitelist(addr);
+ } else if (addr.isLocal()) {
+ if (to.size() > 3) {
+ conn.println("536 sorry, limit on 3 RCPT TO's per DATA");
+ } else {
+ // FEATURE: should check the address further and give 550 if undeliverable
+ conn.println("250 " + addr + " is on this machine; I will deliver it");
+ to.addElement(addr);
+ }
} else {
conn.println("535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
Log.warn("","535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
} else {
conn.println("535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
Log.warn("","535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
+ failedRcptCount++;
+ if (failedRcptCount > 3) {
+ conn.close();
+ return;
+ }
}
conn.flush();
} else if (c.startsWith("DATA")) {
}
conn.flush();
} else if (c.startsWith("DATA")) {