util/Zeroconf.py
changeset 1783 3311eea28d56
parent 1782 5b6ad7a7fd9d
child 1826 91796f408540
equal deleted inserted replaced
1782:5b6ad7a7fd9d 1783:3311eea28d56
     1 """ Multicast DNS Service Discovery for Python, v0.12
     1 #  Multicast DNS Service Discovery for Python, v0.12
     2     Copyright (C) 2003, Paul Scott-Murphy
     2 #     Copyright (C) 2003, Paul Scott-Murphy
     3 
     3 #
     4     This module provides a framework for the use of DNS Service Discovery
     4 #     This module provides a framework for the use of DNS Service Discovery
     5     using IP multicast.  It has been tested against the JRendezvous
     5 #     using IP multicast.  It has been tested against the JRendezvous
     6     implementation from <a href="http://strangeberry.com">StrangeBerry</a>,
     6 #     implementation from <a href="http://strangeberry.com">StrangeBerry</a>,
     7     and against the mDNSResponder from Mac OS X 10.3.8.
     7 #     and against the mDNSResponder from Mac OS X 10.3.8.
     8 
     8 
     9     This library is free software; you can redistribute it and/or
     9 #     This library is free software; you can redistribute it and/or
    10     modify it under the terms of the GNU Lesser General Public
    10 #     modify it under the terms of the GNU Lesser General Public
    11     License as published by the Free Software Foundation; either
    11 #     License as published by the Free Software Foundation; either
    12     version 2.1 of the License, or (at your option) any later version.
    12 #     version 2.1 of the License, or (at your option) any later version.
    13 
    13 
    14     This library is distributed in the hope that it will be useful,
    14 #     This library is distributed in the hope that it will be useful,
    15     but WITHOUT ANY WARRANTY; without even the implied warranty of
    15 #     but WITHOUT ANY WARRANTY; without even the implied warranty of
    16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16 #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    17     Lesser General Public License for more details.
    17 #     Lesser General Public License for more details.
    18 
    18 
    19     You should have received a copy of the GNU Lesser General Public
    19 #     You should have received a copy of the GNU Lesser General Public
    20     License along with this library; if not, write to the Free Software
    20 #     License along with this library; if not, write to the Free Software
    21     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21 #     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    22 
    22 #
    23 """
    23 #
    24 
    24 #
    25 """0.12 update - allow selection of binding interface
    25 # 0.12 update - allow selection of binding interface
    26          typo fix - Thanks A. M. Kuchlingi
    26 #          typo fix - Thanks A. M. Kuchlingi
    27          removed all use of word 'Rendezvous' - this is an API change"""
    27 #          removed all use of word 'Rendezvous' - this is an API change
    28 
    28 #
    29 """0.11 update - correction to comments for addListener method
    29 # 0.11 update - correction to comments for addListener method
    30                  support for new record types seen from OS X
    30 #                  support for new record types seen from OS X
    31                   - IPv6 address
    31 #                   - IPv6 address
    32                   - hostinfo
    32 #                   - hostinfo
    33                  ignore unknown DNS record types
    33 #                  ignore unknown DNS record types
    34                  fixes to name decoding
    34 #                  fixes to name decoding
    35                  works alongside other processes using port 5353 (e.g. on Mac OS X)
    35 #                  works alongside other processes using port 5353 (e.g. on Mac OS X)
    36                  tested against Mac OS X 10.3.2's mDNSResponder
    36 #                  tested against Mac OS X 10.3.2's mDNSResponder
    37                  corrections to removal of list entries for service browser"""
    37 #                  corrections to removal of list entries for service browser
    38 
    38 #
    39 """0.10 update - Jonathon Paisley contributed these corrections:
    39 # 0.10 update - Jonathon Paisley contributed these corrections:
    40                  always multicast replies, even when query is unicast
    40 #                  always multicast replies, even when query is unicast
    41                  correct a pointer encoding problem
    41 #                  correct a pointer encoding problem
    42                  can now write records in any order
    42 #                  can now write records in any order
    43                  traceback shown on failure
    43 #                  traceback shown on failure
    44                  better TXT record parsing
    44 #                  better TXT record parsing
    45                  server is now separate from name
    45 #                  server is now separate from name
    46                  can cancel a service browser
    46 #                  can cancel a service browser
    47 
    47 #
    48                  modified some unit tests to accommodate these changes"""
    48 #                  modified some unit tests to accommodate these changes
    49 
    49 #
    50 """0.09 update - remove all records on service unregistration
    50 # 0.09 update - remove all records on service unregistration
    51                  fix DOS security problem with readName"""
    51 #                  fix DOS security problem with readName
    52 
    52 #
    53 """0.08 update - changed licensing to LGPL"""
    53 # 0.08 update - changed licensing to LGPL
    54 
    54 #
    55 """0.07 update - faster shutdown on engine
    55 # 0.07 update - faster shutdown on engine
    56                  pointer encoding of outgoing names
    56 #                  pointer encoding of outgoing names
    57                  ServiceBrowser now works
    57 #                  ServiceBrowser now works
    58                  new unit tests"""
    58 #                  new unit tests
    59 
    59 #
    60 """0.06 update - small improvements with unit tests
    60 # 0.06 update - small improvements with unit tests
    61                  added defined exception types
    61 #                  added defined exception types
    62                  new style objects
    62 #                  new style objects
    63                  fixed hostname/interface problem
    63 #                  fixed hostname/interface problem
    64                  fixed socket timeout problem
    64 #                  fixed socket timeout problem
    65                  fixed addServiceListener() typo bug
    65 #                  fixed addServiceListener() typo bug
    66                  using select() for socket reads
    66 #                  using select() for socket reads
    67                  tested on Debian unstable with Python 2.2.2"""
    67 #                  tested on Debian unstable with Python 2.2.2
    68 
    68 #
    69 """0.05 update - ensure case insensitivty on domain names
    69 # 0.05 update - ensure case insensitivty on domain names
    70                  support for unicast DNS queries"""
    70 #                  support for unicast DNS queries
    71 
    71 #
    72 """0.04 update - added some unit tests
    72 # 0.04 update - added some unit tests
    73                  added __ne__ adjuncts where required
    73 #                  added __ne__ adjuncts where required
    74                  ensure names end in '.local.'
    74 #                  ensure names end in '.local.'
    75                  timeout on receiving socket for clean shutdown"""
    75 #                  timeout on receiving socket for clean shutdown
    76 
       
    77 __author__ = "Paul Scott-Murphy"
       
    78 __email__ = "paul at scott dash murphy dot com"
       
    79 __version__ = "0.12"
       
    80 
    76 
    81 import string
    77 import string
    82 import time
    78 import time
    83 import struct
    79 import struct
    84 import socket
    80 import socket
    85 import threading
    81 import threading
    86 import select
    82 import select
    87 import traceback
    83 import traceback
       
    84 
       
    85 
       
    86 __author__ = "Paul Scott-Murphy"
       
    87 __email__ = "paul at scott dash murphy dot com"
       
    88 __version__ = "0.12"
       
    89 
    88 
    90 
    89 __all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"]
    91 __all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"]
    90 
    92 
    91 # hook for threads
    93 # hook for threads
    92 
    94