Esempio n. 1
0
	def optneg_milter(self, actions=SMFI_V2_ACTS, protocol=0):
		"""Perform the initial option negotiation as a milter,
		reading the MTA's SMFIR_OPTNEG and replying with ours.
		Returns a tuple of (actions, protocol) bitmasks for what
		both we and the MTA will do."""
		r = self.get_msg()
		if r[0] != SMFIC_OPTNEG:
			raise MilterConvoError("first message not SMFIR_OPTNEG, was: %s/%s" % (r[0], str(r[1])))
		ract, rprot =  codec.optneg_milter_capable(r[1]['actions'],
							   r[1]['protocol'],
							   actions, protocol)
		self.sock.sendall(codec.encode_optneg(ract, rprot,
						      is_milter=True))
		return (ract, rprot)
	def testOptnegMilterCap(self):
		"""Test that optneg_milter_capable correctly masks things."""
		for a, b, c in self.optneg_milter_tests:
			r = codec.optneg_milter_capable(a[0], a[1],
							b[0], b[1])
			self.assertEqual(r, c)