[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/SMTP - ISMTPCommandHandler.py:1.1.2.2 SMTPConfigurations.py:1.1.2.2 SMTPServer.py:1.1.2.5 SMTPServerChannel.py:1.1.2.6 SMTPSpamFilter.py:1.1.2.2 SMTPStatusMessages.py:1.1.2.3 SMTPUtilities.py:1.1.2.2 __init__.py:1.1.2.2
Shane Hathaway
shane@cvs.zope.org
Thu, 11 Apr 2002 10:13:18 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Server/SMTP
In directory cvs.zope.org:/tmp/cvs-serv24692/SMTP
Modified Files:
Tag: Zope3-Server-Branch
ISMTPCommandHandler.py SMTPConfigurations.py SMTPServer.py
SMTPServerChannel.py SMTPSpamFilter.py SMTPStatusMessages.py
SMTPUtilities.py __init__.py
Log Message:
Removed CRs
=== Zope3/lib/python/Zope/Server/SMTP/ISMTPCommandHandler.py 1.1.2.1 => 1.1.2.2 === (421/521 lines abridged)
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-from Interface import Interface
-
-class ISMTPCommandHandler(Interface):
- """This interface defines all the SMTP commands that are supported by the
- server.
-
- Every command takes the args as first arguments, since it is
- responsible for parsing the rest of the input (which is usually
- easy).
- """
-
- def cmd_data(args):
- """DATA (DATA)
-
- The receiver treats the lines following the command as mail
- data from the sender. This command causes the mail data
- from this command to be appended to the mail data buffer.
- The mail data may contain any of the 128 ASCII character
- codes.
-
- The mail data is terminated by a line containing only a
- period, that is the character sequence "<CRLF>.<CRLF>" (see
- Section 4.5.2 on Transparency). This is the end of mail
- data indication.
-
- The end of mail data indication requires that the receiver
- must now process the stored mail transaction information.
- This processing consumes the information in the reverse-path
- buffer, the forward-path buffer, and the mail data buffer,
- and on the completion of this command these buffers are
- cleared. If the processing is successful the receiver must
- send an OK reply. If the processing fails completely the
- receiver must send a failure reply.
[-=- -=- -=- 421 lines omitted -=- -=- -=-]
+
+ The forward-path consists of an optional list of hosts and a
+ required destination mailbox. When the list of hosts is
+ present, it is a source route and indicates that the mail
+ must be relayed to the next host on the list. If the
+ receiver-SMTP does not implement the relay function it may
+ user the same reply it would for an unknown local user
+ (550).
+
+ When mail is relayed, the relay host must remove itself from
+ the beginning forward-path and put itself at the beginning
+ of the reverse-path. When mail reaches its ultimate
+ destination (the forward-path contains only a destination
+ mailbox), the receiver-SMTP inserts it into the destination
+ mailbox in accordance with its host mail conventions.
+
+ For example, mail received at relay host A with arguments
+
+ FROM:<USERX@HOSTY.ARPA>
+ TO:<@HOSTA.ARPA,@HOSTB.ARPA:USERC@HOSTD.ARPA>
+
+ will be relayed on to host B with arguments
+
+ FROM:<@HOSTA.ARPA:USERX@HOSTY.ARPA>
+ TO:<@HOSTB.ARPA:USERC@HOSTD.ARPA>.
+
+ This command causes its forward-path argument to be appended
+ to the forward-path buffer.
+ """
+
+ def cmd_rset(args):
+ """RESET (RSET)
+
+ This command specifies that the current mail transaction is
+ to be aborted. Any stored sender, recipients, and mail data
+ must be discarded, and all buffers and state tables cleared.
+ The receiver must send an OK reply.
+ """
+
+ def cmd_vrfy(args):
+ """VERIFY (VRFY)
+
+ This command asks the receiver to confirm that the argument
+ identifies a user. If it is a user name, the full name of
+ the user (if known) and the fully specified mailbox are
+ returned.
+
+ This command has no effect on any of the reverse-path
+ buffer, the forward-path buffer, or the mail data buffer.
+ """
=== Zope3/lib/python/Zope/Server/SMTP/SMTPConfigurations.py 1.1.2.1 => 1.1.2.2 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-# ** Relay rules **
-
-# Specify relay level.
-# true: Allow relaying except from domains specified in DENY_RELAY_FROM
-# and to domains in DENY_RELAY_TO
-# false: Deny relaying except from domains specified in ALLOW_RELAY_FROM
-# and to domains in ALLOW_RELAY_TO
-RELAY_FROM = 1
-ACCEPT_RELAY_FROM = ('*cbu.edu', '*zope.org')
-DENY_RELAY_FROM = ()
-
-RELAY_TO = 1
-ACCEPT_RELAY_TO = ('*.cbu.edu')
-DENY_RELAY_TO = ()
-
-# If specified all mail is forwarded to this server.
-USE_RELAY_SERVER = ''
-
-# When set to true, a local sender is only allowed to send, if the connection
-# is coming from a local IP.
-STRICT_RELAY_TEST = 0
-
-# Define some standard mail accounts
-ADMIN_ACCOUNT = 'foo'
-UNKNOWN_ACCOUNT = 'unknown'
-
-LOCAL_DOMAIN_NAME = '*cbu.edu'
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+# ** Relay rules **
+
+# Specify relay level.
+# true: Allow relaying except from domains specified in DENY_RELAY_FROM
+# and to domains in DENY_RELAY_TO
+# false: Deny relaying except from domains specified in ALLOW_RELAY_FROM
+# and to domains in ALLOW_RELAY_TO
+RELAY_FROM = 1
+ACCEPT_RELAY_FROM = ('*cbu.edu', '*zope.org')
+DENY_RELAY_FROM = ()
+
+RELAY_TO = 1
+ACCEPT_RELAY_TO = ('*.cbu.edu')
+DENY_RELAY_TO = ()
+
+# If specified all mail is forwarded to this server.
+USE_RELAY_SERVER = ''
+
+# When set to true, a local sender is only allowed to send, if the connection
+# is coming from a local IP.
+STRICT_RELAY_TEST = 0
+
+# Define some standard mail accounts
+ADMIN_ACCOUNT = 'foo'
+UNKNOWN_ACCOUNT = 'unknown'
+
+LOCAL_DOMAIN_NAME = '*cbu.edu'
=== Zope3/lib/python/Zope/Server/SMTP/SMTPServer.py 1.1.2.4 => 1.1.2.5 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -20,23 +20,23 @@
import SMTPConfigurations
from Zope.Server.ServerBase import ServerBase
-from Zope.Server.VFS.OSFileSystem import OSFileSystem
+from Zope.Server.VFS.OSFileSystem import OSFileSystem
from Zope.Server.VFS.IFilesystemAccess import IFilesystemAccess
class SMTPServer(ServerBase):
"""Generic FTP Server"""
-
+
channel_class = SMTPServerChannel
SERVER_IDENT = 'Zope.Server.SMTPServer'
config = SMTPConfigurations
def __init__(self, ip, port, maildir, *args, **kw):
-
+
assert IFilesystemAccess.isImplementedBy(maildir)
self.maildir = maildir
-
+
super(SMTPServer, self).__init__(ip, port, *args, **kw)
=== Zope3/lib/python/Zope/Server/SMTP/SMTPServerChannel.py 1.1.2.5 => 1.1.2.6 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -25,7 +25,7 @@
from Zope.Server.VFS.UsernamePassword import UsernamePassword
from SMTPStatusMessages import status_msgs
-from ISMTPCommandHandler import ISMTPCommandHandler
+from ISMTPCommandHandler import ISMTPCommandHandler
class SMTPServerChannel(LineServerChannel):
@@ -62,7 +62,7 @@
self._from = ''
self._to = []
self._message = ''
-
+
self._sender_host = None
self.receiving_data = 0
@@ -84,7 +84,7 @@
self.handleMail()
break
else:
- self._message += data
+ self._message += data
data = None
else:
if preq is None:
@@ -105,9 +105,9 @@
def _getFilesystem(self):
"""Open the filesystem using the current credentials."""
- credentials = UsernamePassword('foo', 'bar')
+ credentials = UsernamePassword('foo', 'bar')
return self.server.maildir.open(credentials)
-
+
############################################################
# Implementation methods for interface
@@ -137,7 +137,7 @@
'See Zope.Server.SMTP.ISMTPCommandHandler.ISMTPCommandHandler'
if args:
self.sender_host = args
- hostname = args
+ hostname = args
ip = hostname2ip(args, args)
self.reply('OK_GREETING', (args, hostname, ip))
else:
@@ -203,7 +203,7 @@
self._to = []
self._message = ''
self.reply('OK_RESET')
-
+
def cmd_vrfy(self, args):
'See Zope.Server.SMTP.ISMTPCommandHandler.ISMTPCommandHandler'
@@ -236,7 +236,7 @@
self._from = ''
self._to = []
- self._message = ''
+ self._message = ''
self.reply('OK_DATA_RECV')
@@ -251,7 +251,7 @@
# this users mail. It is the final destination.
if self.isLocalAddress(address):
return 1
-
+
# set default relay setting
allow = config.RELAY_TO
@@ -261,7 +261,7 @@
rules = config.DENY_RELAY_TO
else:
rules = config.ALLOW_RELAY_TO
-
+
# enumerate all rules. they are priority-sorted, with higher
# priorities comming later
for rule in rules:
@@ -278,10 +278,10 @@
address = address[1:-1]
config = self.server.config
-
+
# If the sender is a local address, it must come from a local
# IP, otherwise access is denied
- if ( config.STRICT_RELAY_TEST and
+ if ( config.STRICT_RELAY_TEST and
self.isLocalConnection() and
not self.isLocalAddress(address) ):
return 0
@@ -317,7 +317,7 @@
# it is a message from somebody outside
can_process_message, remote_receivers = 1, 0
-
+
for receiver in self._to:
rid, rcs = self.getAddressID(receiver)
@@ -350,7 +350,7 @@
username, domain = address.split('@')
except:
username, domain = address, ''
-
+
if self.server.maildir.hasUser(username):
return username, 1
elif self.config.LOCAL_DOMAIN_NAME == domain.lower():
@@ -369,8 +369,8 @@
except:
username, domain = address, ''
- return '"%s" <%s@%s>' %(username, username, domain)
-
+ return '"%s" <%s@%s>' %(username, username, domain)
+
def isLocalConnection(self):
name = ip2hostname(self.addr[0])
@@ -394,8 +394,8 @@
return 1
return 0
-
-
+
+
def ip2hostname(ip, default=None):
"""Resolves an IP into a hostname"""
@@ -403,7 +403,7 @@
return socket.gethostbyaddr(ip)[0]
except socket.herror:
return default
-
+
def hostname2ip(hostname, default=None):
=== Zope3/lib/python/Zope/Server/SMTP/SMTPSpamFilter.py 1.1.2.1 => 1.1.2.2 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-import spam_data
-
-def isSpamSubjectLine(subject):
- subject = subject.lower()
- reload(spam_data)
-
- weight = float(reduce(lambda x,y:x+y,map(ord,subject)))/len(subject)
- if weight > 128:
- print "Weight %.2f indicates spam mail." % weight
- return 1
-
- for token_tuple in spam_data.subject_tokens:
- found = 0
- for token in token_tuple:
- if subject.find(token) >= 0:
- found += 1
- if found == len(token_tuple):
- print "Tokens '%s' indicate spam mail." % str(token_tuple).strip()
- return 1
-
- tokens = subject.split()
- try:
- isdigit = int(tokens[-1])
- isdigit = len(tokens[-1]) > 3
- except:
- isdigit = 0
- if isdigit:
- print "Integer as last token indicates spam mail."
- return 1
-
- return 0
-
-
-def checkSpamMail(lines):
- index = -1
- for line in lines:
- index += 1
- if line.strip() == "": break
-
- s = line.find(':')
- if s < 0: continue
-
- tokens = (line[:s],line[s:])
- keyword = tokens[0].lower()
- if keyword == 'subject':
- if IsSpamSubjectLine(tokens[1]):
- print "SPAM SUBJECT: "+tokens[1].strip()
- new_subject_line = line[:9] + "[SPAM] " + line[9:]
- lines[index] = new_subject_line
- else:
- print "NOT SPAM SUBJECT: "+ tokens[1].strip()
- break
- return lines
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import spam_data
+
+def isSpamSubjectLine(subject):
+ subject = subject.lower()
+ reload(spam_data)
+
+ weight = float(reduce(lambda x,y:x+y,map(ord,subject)))/len(subject)
+ if weight > 128:
+ print "Weight %.2f indicates spam mail." % weight
+ return 1
+
+ for token_tuple in spam_data.subject_tokens:
+ found = 0
+ for token in token_tuple:
+ if subject.find(token) >= 0:
+ found += 1
+ if found == len(token_tuple):
+ print "Tokens '%s' indicate spam mail." % str(token_tuple).strip()
+ return 1
+
+ tokens = subject.split()
+ try:
+ isdigit = int(tokens[-1])
+ isdigit = len(tokens[-1]) > 3
+ except:
+ isdigit = 0
+ if isdigit:
+ print "Integer as last token indicates spam mail."
+ return 1
+
+ return 0
+
+
+def checkSpamMail(lines):
+ index = -1
+ for line in lines:
+ index += 1
+ if line.strip() == "": break
+
+ s = line.find(':')
+ if s < 0: continue
+
+ tokens = (line[:s],line[s:])
+ keyword = tokens[0].lower()
+ if keyword == 'subject':
+ if IsSpamSubjectLine(tokens[1]):
+ print "SPAM SUBJECT: "+tokens[1].strip()
+ new_subject_line = line[:9] + "[SPAM] " + line[9:]
+ lines[index] = new_subject_line
+ else:
+ print "NOT SPAM SUBJECT: "+ tokens[1].strip()
+ break
+ return lines
=== Zope3/lib/python/Zope/Server/SMTP/SMTPStatusMessages.py 1.1.2.2 => 1.1.2.3 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-
-status_msgs = {
- 'OK_HELP' : '214 Help not available. RTFM!',
- 'OK_WELCOME' : '220 %s Zope 3 SMTP Service ready; %s',
- 'OK_QUIT' : '221 Closing transmission channel',
- 'OK_NOOP' : '250 OK',
- 'OK_GREETING' : '250 %s Hello %s [%s], pleased to meet you',
- 'OK_FROM_ACCPT' : '250 Sender has been accepted',
- 'OK_TO_ACCPT' : '250 Receiver has been accepted',
- 'OK_RESET' : '250 Session reset',
- 'OK_VERIFY' : '250 %s',
- 'OK_DATA_RECV' : '250 Data received',
- 'OK_TSFR_START' : '354 Start mail input; end with <CRLF>.<CRLF>',
-
- 'ERR_CMD_UNKNOWN' : '500 "%s" Syntax error, command unrecognized',
- 'ERR_DOMAIN_REQ' : '501 HELO requires domain address',
- 'ERR_MISS_FROM' : '501 MAIL command without "FROM:"',
- 'ERR_MISS_TO' : '501 RCPT command without "TO:"',
- 'ERR_USR_UNKNOWN' : '550 No user called "%s" known',
- 'ERR_FROM_DENIED' : '551 Access for sender %s denied',
- 'ERR_TO_DENIED' : '551 Access for sender %s denied',
- 'ERR_ACC_DENIED' : '551 Data transfer access denied',
- }
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+
+status_msgs = {
+ 'OK_HELP' : '214 Help not available. RTFM!',
+ 'OK_WELCOME' : '220 %s Zope 3 SMTP Service ready; %s',
+ 'OK_QUIT' : '221 Closing transmission channel',
+ 'OK_NOOP' : '250 OK',
+ 'OK_GREETING' : '250 %s Hello %s [%s], pleased to meet you',
+ 'OK_FROM_ACCPT' : '250 Sender has been accepted',
+ 'OK_TO_ACCPT' : '250 Receiver has been accepted',
+ 'OK_RESET' : '250 Session reset',
+ 'OK_VERIFY' : '250 %s',
+ 'OK_DATA_RECV' : '250 Data received',
+ 'OK_TSFR_START' : '354 Start mail input; end with <CRLF>.<CRLF>',
+
+ 'ERR_CMD_UNKNOWN' : '500 "%s" Syntax error, command unrecognized',
+ 'ERR_DOMAIN_REQ' : '501 HELO requires domain address',
+ 'ERR_MISS_FROM' : '501 MAIL command without "FROM:"',
+ 'ERR_MISS_TO' : '501 RCPT command without "TO:"',
+ 'ERR_USR_UNKNOWN' : '550 No user called "%s" known',
+ 'ERR_FROM_DENIED' : '551 Access for sender %s denied',
+ 'ERR_TO_DENIED' : '551 Access for sender %s denied',
+ 'ERR_ACC_DENIED' : '551 Data transfer access denied',
+ }
=== Zope3/lib/python/Zope/Server/SMTP/SMTPUtilities.py 1.1.2.1 => 1.1.2.2 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-def getLongIpAddress(ipaddr):
- """ """
- tokens = ipaddr.split(".")
-
- if len(tokens) != 4:
- raise "ERROR, IP-Address '%s' invalid" % ipaddr
-
- tokens = map(long,tokens)
-
- return ( tokens[0] * (256 * 256 * 256) + tokens[1] * (256 * 256) +
- tokens[2] * (256) + tokens[3] )
-
-
-def decodeValidIpRanges(data):
- """ """
- data = data.split(",")
-
- for i in xrange(len(data)):
- item = map(GetLongIpAddress,data[i].split("-"))
- if len(item) == 1:
- item.append(item[0])
- elif len(item) > 2:
- raise "ERROR, IP-Addressrange '%s' invalid" % data[i]
- data[i] = tuple(item)
- return tuple(data)
-
-
-def domainOfAddress(address):
- x = address.find('@')
- if x >= 0:
- return address[x+1:]
- return ""
-
-
-def splitMailHeader(s):
- result = []
- startindex = -1
- index = 0
- while index < len(s):
- c = s[index]
- if c == ' ':
- # ok, split
- if startindex != -1:
- result.append(s[startindex:index])
- startindex = -1
- elif c == ':':
- # ok, split
- if startindex != -1:
- result.append(s[startindex:index+1])
- startindex = -1
- # ok, split *including* this character
- elif startindex == -1:
- startindex = index
- index += 1
- if startindex != -1:
- result.append(s[startindex:])
- return result
-
-import spam_data
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+def getLongIpAddress(ipaddr):
+ """ """
+ tokens = ipaddr.split(".")
+
+ if len(tokens) != 4:
+ raise "ERROR, IP-Address '%s' invalid" % ipaddr
+
+ tokens = map(long,tokens)
+
+ return ( tokens[0] * (256 * 256 * 256) + tokens[1] * (256 * 256) +
+ tokens[2] * (256) + tokens[3] )
+
+
+def decodeValidIpRanges(data):
+ """ """
+ data = data.split(",")
+
+ for i in xrange(len(data)):
+ item = map(GetLongIpAddress,data[i].split("-"))
+ if len(item) == 1:
+ item.append(item[0])
+ elif len(item) > 2:
+ raise "ERROR, IP-Addressrange '%s' invalid" % data[i]
+ data[i] = tuple(item)
+ return tuple(data)
+
+
+def domainOfAddress(address):
+ x = address.find('@')
+ if x >= 0:
+ return address[x+1:]
+ return ""
+
+
+def splitMailHeader(s):
+ result = []
+ startindex = -1
+ index = 0
+ while index < len(s):
+ c = s[index]
+ if c == ' ':
+ # ok, split
+ if startindex != -1:
+ result.append(s[startindex:index])
+ startindex = -1
+ elif c == ':':
+ # ok, split
+ if startindex != -1:
+ result.append(s[startindex:index+1])
+ startindex = -1
+ # ok, split *including* this character
+ elif startindex == -1:
+ startindex = index
+ index += 1
+ if startindex != -1:
+ result.append(s[startindex:])
+ return result
+
+import spam_data
=== Zope3/lib/python/Zope/Server/SMTP/__init__.py 1.1.2.1 => 1.1.2.2 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""