[CalendarServer-changes] [7355] CalendarServer/branches/users/cdaboo/pods/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 22 10:01:13 PDT 2011
Revision: 7355
http://trac.macosforge.org/projects/calendarserver/changeset/7355
Author: cdaboo at apple.com
Date: 2011-04-22 10:01:13 -0700 (Fri, 22 Apr 2011)
Log Message:
-----------
Better IP checking to handling forwarding external requests between partitions. Do not normalize calendar
user addresses for freebusy lookups from external servers.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py
CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py
Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py 2011-04-22 10:34:21 UTC (rev 7354)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py 2011-04-22 17:01:13 UTC (rev 7355)
@@ -49,6 +49,7 @@
from twistedcaldav.scheduling.ischedule import ScheduleViaISchedule
from twistedcaldav.scheduling.ischeduleservers import IScheduleServers
from twistedcaldav.scheduling.itip import iTIPRequestStatus
+from twistedcaldav.servers import Servers
"""
CalDAV/Server-to-Server scheduling behavior.
@@ -264,7 +265,7 @@
# Parse the calendar object from the HTTP request stream
try:
self.calendar = (yield Component.fromIStream(self.request.stream))
-
+
self.preProcessCalendarData()
self.calendardata = str(self.calendar)
except:
@@ -825,22 +826,24 @@
def preProcessCalendarData(self):
"""
For data coming in from outside we need to normalize the calendar user addresses so that later iTIP
- processing will match calendar users against those in stored calendar data.
+ processing will match calendar users against those in stored calendar data. Only do that for invites
+ not freebusy.
"""
- def lookupFunction(cuaddr):
- principal = self.resource.principalForCalendarUserAddress(cuaddr)
- if principal is None:
- return (None, None, None)
- else:
- return (
- principal.record.fullName.decode("utf-8"),
- principal.record.guid,
- principal.record.calendarUserAddresses
- )
+ if not self.checkForFreeBusy():
+ def lookupFunction(cuaddr):
+ principal = self.resource.principalForCalendarUserAddress(cuaddr)
+ if principal is None:
+ return (None, None, None)
+ else:
+ return (
+ principal.record.fullName.decode("utf-8"),
+ principal.record.guid,
+ principal.record.calendarUserAddresses
+ )
+
+ self.calendar.normalizeCalendarUserAddresses(lookupFunction)
- self.calendar.normalizeCalendarUserAddresses(lookupFunction)
-
def checkAuthorization(self):
# Must have an unauthenticated user
if self.resource.currentPrincipal(self.request) != davxml.Principal(davxml.Unauthenticated()):
@@ -946,9 +949,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/cdaboo/pods/twistedcaldav/servers.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py 2011-04-22 10:34:21 UTC (rev 7354)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py 2011-04-22 17:01:13 UTC (rev 7355)
@@ -20,6 +20,7 @@
from twistedcaldav.config import config, fullServerPath
from twistedcaldav.xmlutil import readXML
import urlparse
+import socket
"""
XML based server configuration file handling.
@@ -96,7 +97,9 @@
self.id = None
self.uri = None
self.thisServer = False
+ self.ips = set()
self.partitions = {}
+ self.partitions_ips = set()
self.isImplicit = True
def check(self):
@@ -110,6 +113,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/76a54f35/attachment.html>
More information about the calendarserver-changes
mailing list