# Path: Milter/utils.py
# PAT_IP4 = r'\.'.join([r'(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])']*4)
# MASK = 0xFFFFFFFF
# MASK6 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
# def addr2bin(s):
# def bin2long6(s):
#     def inet_ntop(s):
#     def inet_pton(s):
# def cidr(i,n,mask=MASK):
# def iniplist(ipaddr,iplist):
# def parseaddr(t):
# def decode(s, convert_eols=None):
# def parse_addr(t):
# def parse_header(val):


from socket import AF_INET,AF_INET6
from sys import version as VERSION
  from io import BytesIO
  from StringIO import StringIO as BytesIO
from Milter import utils
import time
import mime
import Milter
  def _abort(self):
    "What Milter sets for abort_callback"
    self._priv.abort()
    self._close()

  def _close(self):
    Milter.close_callback(self)

  def _negotiate(self):
    self._body = None
    self._bodyreplaced = False
    self._priv = None
    self._opts = TestCtx.default_opts
    self._stage = -1
    rc = Milter.negotiate_callback(self,self._opts)
    if rc == Milter.ALL_OPTS:
      self._opts = TestCtx.default_opts
    elif rc != Milter.CONTINUE:
      self._abort()
      self._close()
    self._protocol = self._opts[1]
    return rc

  def _connect(self,host='localhost',helo='spamrelay',ip='1.2.3.4'):
    rc = self._negotiate()
    # FIXME: what if not CONTINUE or ALL_OPTS?
    if self._protocol & Milter.P_NOCONNECT:
      return Milter.CONTINUE
    if utils.ip4re.match(ip):
      af = AF_INET

# Path: Milter/utils.py
# PAT_IP4 = r'\.'.join([r'(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])']*4)
# MASK = 0xFFFFFFFF
# MASK6 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
# def addr2bin(s):
# def bin2long6(s):
#     def inet_ntop(s):
#     def inet_pton(s):
# def cidr(i,n,mask=MASK):
# def iniplist(ipaddr,iplist):
# def parseaddr(t):
# def decode(s, convert_eols=None):
# def parse_addr(t):
# def parse_header(val):


# Path: Milter/testctx.py
from socket import AF_INET,AF_INET6
from sys import version as VERSION
  from io import BytesIO
  from StringIO import StringIO as BytesIO
from Milter import utils
import time
import mime
import Milter

  def _abort(self):
    "What Milter sets for abort_callback"
    self._priv.abort()
    self._close()

  def _close(self):
    Milter.close_callback(self)

  def _negotiate(self):
    self._body = None
    self._bodyreplaced = False
    self._priv = None
    self._opts = TestCtx.default_opts
    self._stage = -1
    rc = Milter.negotiate_callback(self,self._opts)
    if rc == Milter.ALL_OPTS:
      self._opts = TestCtx.default_opts
    elif rc != Milter.CONTINUE:
      self._abort()
      self._close()
    self._protocol = self._opts[1]
    return rc

  def _connect(self,host='localhost',helo='spamrelay',ip='1.2.3.4'):
    rc = self._negotiate()
    # FIXME: what if not CONTINUE or ALL_OPTS?
    if self._protocol & Milter.P_NOCONNECT:
      return Milter.CONTINUE
    if utils.ip4re.match(ip):
      af = AF_INET

    elif utils.ip6re.match(ip):