[CalendarServer-changes] [7356] CalendarServer/branches/users/wsanchez/deployment

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 22 10:02:38 PDT 2011


Revision: 7356
          http://trac.macosforge.org/projects/calendarserver/changeset/7356
Author:   cdaboo at apple.com
Date:     2011-04-22 10:02:38 -0700 (Fri, 22 Apr 2011)
Log Message:
-----------
Better IP checking to handle forwarding external requests between partitions.

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/deployment/support/patchapply
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/scheduling/scheduler.py
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/servers.py

Added Paths:
-----------
    CalendarServer/branches/users/wsanchez/deployment/twisted/plugins/dropin.cache

Modified: CalendarServer/branches/users/wsanchez/deployment/support/patchapply
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/support/patchapply	2011-04-22 17:01:13 UTC (rev 7355)
+++ CalendarServer/branches/users/wsanchez/deployment/support/patchapply	2011-04-22 17:02:38 UTC (rev 7356)
@@ -26,24 +26,37 @@
 #
 
 #projects = ("Twisted", "vobject", "dateutil", "xattr")
-projects = ("Twisted", "vobject",)
+#projects = (("Twisted-4", "Twisted"), ("vobject-2","vobject",),)
+projects = (("Twisted-4", "Twisted"),)
+
 cwd = os.getcwd()
 libpatches = os.path.join(cwd, "lib-patches")
 
 cmd = "/usr/bin/patch"
 
 def applypatch(project, patch):
-    stat = os.system("%s -s -d ../%s/ -p0 --forward --dry-run -i %s > /dev/null" % (cmd, project, patch, ))
+
+    if isinstance(project, tuple):
+        project_path, project_name = project
+    else:
+        project_path = project_name = project
+
+    stat = os.system("%s -s -d ../%s/ -p0 --forward --dry-run -i %s > /dev/null" % (cmd, project_path, patch, ))
     if stat == 0:
-        print "+++ Patching %s with %s" % (project, patch[len(cwd) + 1:],)
-        os.system("%s -s -d ../%s/ -p0 --forward -i %s" % (cmd, project, patch, ))
+        print "+++ Patching %s with %s" % (project_path, patch[len(cwd) + 1:],)
+        os.system("%s -s -d ../%s/ -p0 --forward -i %s" % (cmd, project_path, patch, ))
     else:
-        print "*** Failed to patch %s with %s" % (project, patch[len(cwd) + 1:],)
+        print "*** Failed to patch %s with %s" % (project_path, patch[len(cwd) + 1:],)
 
 def applypatches(project):
     
+    if isinstance(project, tuple):
+        project_path, project_name = project
+    else:
+        project_path = project_name = project
+
     # Iterate over each patch file in the patches directory
-    path = os.path.join(libpatches, project)
+    path = os.path.join(libpatches, project_name)
     for file in os.listdir(path):
         fpath = os.path.join(path, file)
         if os.path.isfile(fpath) and fpath.endswith(".patch"):

Added: CalendarServer/branches/users/wsanchez/deployment/twisted/plugins/dropin.cache
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twisted/plugins/dropin.cache	                        (rev 0)
+++ CalendarServer/branches/users/wsanchez/deployment/twisted/plugins/dropin.cache	2011-04-22 17:02:38 UTC (rev 7356)
@@ -0,0 +1,95 @@
+(dp1
+S'caldav'
+p2
+ccopy_reg
+_reconstructor
+p3
+(ctwisted.plugin
+CachedDropin
+p4
+c__builtin__
+object
+p5
+NtRp6
+(dp7
+S'moduleName'
+p8
+S'twisted.plugins.caldav'
+p9
+sS'description'
+p10
+NsS'plugins'
+p11
+(lp12
+g3
+(ctwisted.plugin
+CachedPlugin
+p13
+g5
+NtRp14
+(dp15
+S'provided'
+p16
+(lp17
+ctwisted.plugin
+IPlugin
+p18
+actwisted.application.service
+IServiceMaker
+p19
+asS'dropin'
+p20
+g6
+sS'name'
+p21
+S'CalDAVNotifier'
+p22
+sg10
+Nsbag3
+(g13
+g5
+NtRp23
+(dp24
+g16
+(lp25
+g18
+ag19
+asg20
+g6
+sg21
+S'TwistedCalDAV'
+p26
+sg10
+NsbasbsS'kqueuereactor'
+p27
+g3
+(g4
+g5
+NtRp28
+(dp29
+g8
+S'twisted.plugins.kqueuereactor'
+p30
+sg10
+Nsg11
+(lp31
+g3
+(g13
+g5
+NtRp32
+(dp33
+g16
+(lp34
+g18
+actwisted.application.reactors
+IReactorInstaller
+p35
+asg20
+g28
+sg21
+S'caldav_kqueue'
+p36
+sg10
+S'\n    @ivar moduleName: The fully-qualified Python name of the module of which\n    the install callable is an attribute.\n    '
+p37
+sbasbs.
\ No newline at end of file

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/scheduling/scheduler.py	2011-04-22 17:01:13 UTC (rev 7355)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/scheduling/scheduler.py	2011-04-22 17:02:38 UTC (rev 7356)
@@ -45,6 +45,7 @@
 from twistedcaldav.scheduling.ischedule import ScheduleViaISchedule
 from twistedcaldav.scheduling.ischeduleservers import IScheduleServers
 from twistedcaldav.scheduling.itip import iTIPRequestStatus
+from twistedcaldav.servers import Servers
 
 import datetime
 import itertools
@@ -785,9 +786,16 @@
         # Get the request IP and map to hostname.
         clientip = self.request.remoteAddr.host
         
-        # First compare as dotted IP
+        # Check against this server (or any of its partitions). We need this because an external iTIP message
+        # may be addressed to users on different partitions, and the node receiving the iTIP message will need to
+        # forward it to the partition nodes, thus the client ip seen by the partitions will in fact be the initial
+        # receiving node.
         matched = False
-        if isIPAddress(expected_uri.hostname):
+        if Servers.getThisServer().checkThisIP(clientip):
+            matched = True
+    
+        # Next compare as dotted IP
+        elif isIPAddress(expected_uri.hostname):
             if clientip == expected_uri.hostname:
                 matched = True
         else:

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/servers.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/servers.py	2011-04-22 17:01:13 UTC (rev 7355)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/servers.py	2011-04-22 17:02:38 UTC (rev 7356)
@@ -20,6 +20,7 @@
 from twistedcaldav.log import Logger
 from twistedcaldav.xmlutil import readXML
 import urlparse
+import socket
 
 """
 XML based server configuration file handling.
@@ -92,8 +93,10 @@
     def __init__(self):
         self.id = None
         self.uri = None
+        self.ips = set()
         self.thisServer = False
         self.partitions = {}
+        self.partitions_ips = set()
     
     def check(self):
         # Check whether this matches the current server
@@ -106,6 +109,21 @@
                 if config.SSLPort:
                     self.thisServer = parsed_uri.port in (config.SSLPort,) + tuple(config.BindSSLPorts)
         
+        # Need to cache IP addresses
+        _ignore_host, _ignore_aliases, ips = socket.gethostbyname_ex(parsed_uri.hostname)
+        self.ips = set(ips)
+
+        for uri in self.partitions.values():
+            parsed_uri = urlparse.urlparse(uri)
+            _ignore_host, _ignore_aliases, ips = socket.gethostbyname_ex(parsed_uri.hostname)
+            self.partitions_ips.update(ips)
+    
+    def checkThisIP(self, ip):
+        """
+        Check that the passed in IP address corresponds to this server or one of its partitions.
+        """
+        return (ip in self.ips) or (ip in self.partitions_ips)
+
     def addPartition(self, id, uri):
         self.partitions[id] = uri
     
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110422/582cd9cd/attachment-0001.html>


More information about the calendarserver-changes mailing list