mirror of
				https://github.com/9001/copyparty.git
				synced 2025-10-31 04:32:20 -06:00 
			
		
		
		
	unvendorable dnslib (#887);
stolen/dnslib/ can be deleted and replaced with system lib
NOTE: unvendoring dnslib will make it impossible to communicate with
  devices which have a particular avahi bug; see 6c1cf68bca
			
			
This commit is contained in:
		
							parent
							
								
									08ebb0b4c9
								
							
						
					
					
						commit
						39bd4e5b58
					
				|  | @ -2999,6 +2999,7 @@ force use of system modules  instead of the vendored versions: | ||||||
| | env-var              | what it does | | | env-var              | what it does | | ||||||
| | -------------------- | ------------ | | | -------------------- | ------------ | | ||||||
| | `PRTY_SYS_ALL`       | all of the below | | | `PRTY_SYS_ALL`       | all of the below | | ||||||
|  | | `PRTY_SYS_DNSLIB`    | replace [stolen/dnslib](./copyparty/stolen/dnslib) with [upstream](https://pypi.org/project/dnslib/) | | ||||||
| | `PRTY_SYS_IFADDR`    | replace [stolen/ifaddr](./copyparty/stolen/ifaddr) with [upstream](https://pypi.org/project/ifaddr/) | | | `PRTY_SYS_IFADDR`    | replace [stolen/ifaddr](./copyparty/stolen/ifaddr) with [upstream](https://pypi.org/project/ifaddr/) | | ||||||
| | `PRTY_SYS_QRCG`      | replace [stolen/qrcodegen.py](./copyparty/stolen/qrcodegen.py) with [upstream](https://github.com/nayuki/QR-Code-generator/blob/master/python/qrcodegen.py) | | | `PRTY_SYS_QRCG`      | replace [stolen/qrcodegen.py](./copyparty/stolen/qrcodegen.py) with [upstream](https://github.com/nayuki/QR-Code-generator/blob/master/python/qrcodegen.py) | | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| from __future__ import print_function, unicode_literals | from __future__ import print_function, unicode_literals | ||||||
| 
 | 
 | ||||||
| import errno | import errno | ||||||
|  | import os | ||||||
| import random | import random | ||||||
| import select | import select | ||||||
| import socket | import socket | ||||||
|  | @ -12,31 +13,64 @@ from ipaddress import IPv4Network, IPv6Network | ||||||
| from .__init__ import TYPE_CHECKING | from .__init__ import TYPE_CHECKING | ||||||
| from .__init__ import unicode as U | from .__init__ import unicode as U | ||||||
| from .multicast import MC_Sck, MCast | from .multicast import MC_Sck, MCast | ||||||
| from .stolen.dnslib import ( |  | ||||||
|     AAAA, |  | ||||||
| ) |  | ||||||
| from .stolen.dnslib import CLASS as DC |  | ||||||
| from .stolen.dnslib import ( |  | ||||||
|     NSEC, |  | ||||||
|     PTR, |  | ||||||
|     QTYPE, |  | ||||||
|     RR, |  | ||||||
|     SRV, |  | ||||||
|     TXT, |  | ||||||
|     A, |  | ||||||
|     DNSHeader, |  | ||||||
|     DNSQuestion, |  | ||||||
|     DNSRecord, |  | ||||||
|     set_avahi_379, |  | ||||||
| ) |  | ||||||
| from .util import IP6_LL, CachedSet, Daemon, Netdev, list_ips, min_ex | from .util import IP6_LL, CachedSet, Daemon, Netdev, list_ips, min_ex | ||||||
| 
 | 
 | ||||||
|  | try: | ||||||
|  |     if os.getenv("PRTY_SYS_ALL") or os.getenv("PRTY_SYS_DNSLIB"): | ||||||
|  |         raise ImportError() | ||||||
|  |     from .stolen.dnslib import ( | ||||||
|  |         AAAA, | ||||||
|  |     ) | ||||||
|  |     from .stolen.dnslib import CLASS as DC | ||||||
|  |     from .stolen.dnslib import ( | ||||||
|  |         NSEC, | ||||||
|  |         PTR, | ||||||
|  |         QTYPE, | ||||||
|  |         RR, | ||||||
|  |         SRV, | ||||||
|  |         TXT, | ||||||
|  |         A, | ||||||
|  |         DNSHeader, | ||||||
|  |         DNSQuestion, | ||||||
|  |         DNSRecord, | ||||||
|  |         set_avahi_379, | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     DNS_VND = True | ||||||
|  | except ImportError: | ||||||
|  |     DNS_VND = False | ||||||
|  |     from dnslib import ( | ||||||
|  |         AAAA, | ||||||
|  |     ) | ||||||
|  |     from dnslib import CLASS as DC | ||||||
|  |     from dnslib import ( | ||||||
|  |         NSEC, | ||||||
|  |         PTR, | ||||||
|  |         QTYPE, | ||||||
|  |         RR, | ||||||
|  |         SRV, | ||||||
|  |         TXT, | ||||||
|  |         A, | ||||||
|  |         Bimap, | ||||||
|  |         DNSHeader, | ||||||
|  |         DNSQuestion, | ||||||
|  |         DNSRecord, | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     DC.forward[0x8001] = "F_IN" | ||||||
|  |     DC.reverse["F_IN"] = 0x8001 | ||||||
|  | 
 | ||||||
| if TYPE_CHECKING: | if TYPE_CHECKING: | ||||||
|     from .svchub import SvcHub |     from .svchub import SvcHub | ||||||
| 
 | 
 | ||||||
| if True:  # pylint: disable=using-constant-test | if True:  # pylint: disable=using-constant-test | ||||||
|     from typing import Any, Optional, Union |     from typing import Any, Optional, Union | ||||||
| 
 | 
 | ||||||
|  | if os.getenv("PRTY_MODSPEC"): | ||||||
|  |     from inspect import getsourcefile | ||||||
|  | 
 | ||||||
|  |     print("PRTY_MODSPEC: dnslib:", getsourcefile(A)) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| MDNS4 = "224.0.0.251" | MDNS4 = "224.0.0.251" | ||||||
| MDNS6 = "ff02::fb" | MDNS6 = "ff02::fb" | ||||||
|  | @ -75,7 +109,7 @@ class MDNS(MCast): | ||||||
|         self.ngen = ngen |         self.ngen = ngen | ||||||
|         self.ttl = 300 |         self.ttl = 300 | ||||||
| 
 | 
 | ||||||
|         if not self.args.zm_nwa_1: |         if not self.args.zm_nwa_1 and DNS_VND: | ||||||
|             set_avahi_379() |             set_avahi_379() | ||||||
| 
 | 
 | ||||||
|         zs = self.args.zm_fqdn or (self.args.name + ".local") |         zs = self.args.zm_fqdn or (self.args.name + ".local") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue