mirror of
https://github.com/znc/znc.git
synced 2026-05-02 19:42:32 +02:00
Make unix sockets work from modules
This commit is contained in:
@@ -47,7 +47,12 @@ class Socket:
|
||||
return AsPyModule(self._csock.GetModule()).GetNewPyObj()
|
||||
|
||||
def Listen(self, addrtype='all', port=None, bindhost='', ssl=False,
|
||||
maxconns=GetSOMAXCONN(), timeout=0):
|
||||
maxconns=GetSOMAXCONN(), timeout=0, path=''):
|
||||
if addrtype == 'unix':
|
||||
return self.GetModule().GetManager().ListenUnix(
|
||||
self.ConstructSockName("Py-LU"),
|
||||
path, self._csock)
|
||||
|
||||
try:
|
||||
addr = self.ADDR_MAP[addrtype.lower()]
|
||||
except KeyError:
|
||||
@@ -55,7 +60,7 @@ class Socket:
|
||||
"Specified addrtype [{0}] isn't supported".format(addrtype))
|
||||
|
||||
args = (
|
||||
"python socket for {0}".format(self.GetModule()),
|
||||
self.ConstructSockName("Py-L"),
|
||||
bindhost,
|
||||
ssl,
|
||||
maxconns,
|
||||
@@ -76,13 +81,19 @@ class Socket:
|
||||
return self.GetModule().GetManager().Connect(
|
||||
host,
|
||||
port,
|
||||
'python conn socket for {0}'.format(self.GetModule()),
|
||||
self.ConstructSockName("Py-C"),
|
||||
timeout,
|
||||
ssl,
|
||||
bindhost,
|
||||
self._csock
|
||||
)
|
||||
|
||||
def ConnectUnix(self, path):
|
||||
return self.GetModule().GetManager().ConnectUnix(
|
||||
self.ConstructSockName("Py-CU"),
|
||||
path, self._csock
|
||||
)
|
||||
|
||||
def Write(self, data):
|
||||
if (isinstance(data, str)):
|
||||
return self._csock.Write(data)
|
||||
|
||||
Reference in New Issue
Block a user