mirror of
https://github.com/django/daphne.git
synced 2025-04-17 23:32:12 +03:00
Detect address family for fd endpoints
By detecting the address family rather than assuming AF_INET, we allow unix domain sockets to be inherited properly.
This commit is contained in:
parent
3d9bbebfda
commit
f6350940e6
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import socket
|
||||
|
||||
from twisted.internet import endpoints
|
||||
|
@ -10,8 +11,13 @@ from zope.interface import implementer
|
|||
class _FDParser:
|
||||
prefix = "fd"
|
||||
|
||||
def _parseServer(self, reactor, fileno, domain=socket.AF_INET):
|
||||
def _parseServer(self, reactor, fileno, domain=None):
|
||||
fileno = int(fileno)
|
||||
if domain:
|
||||
domain = getattr(socket, f"AF_{domain}")
|
||||
else:
|
||||
with socket.socket(fileno=os.dup(fileno)) as sock:
|
||||
domain = sock.family
|
||||
return endpoints.AdoptedStreamServerEndpoint(reactor, fileno, domain)
|
||||
|
||||
def parseStreamServer(self, reactor, *args, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue
Block a user