Merge remote-tracking branch 'origin/v3.5'

This commit is contained in:
Adolfo Gómez García 2022-03-30 15:43:38 +02:00
commit 69192a2a1b
2 changed files with 25 additions and 2 deletions

View File

@ -59,11 +59,11 @@ class Processes:
for i, c in enumerate(self.children):
try:
if c[2].status() == 'zombie': # Bad kill!!
raise psutil.ZombieProcess(c[2].pid)
raise psutil.ZombieProcess(c[2])
percent = c[2].cpu_percent()
except (psutil.ZombieProcess, psutil.NoSuchProcess) as e:
# Process is missing...
logger.warning('Missing process found: %s', e.pid)
logger.warning('Missing process found: %s', e)
try:
c[0].close() # Close pipe to missing process
except Exception:

View File

@ -129,6 +129,27 @@ async def tunnel_proc_async(
if cfg.ssl_dhparam:
context.load_dh_params(cfg.ssl_dhparam)
async def processSocket(ssock: socket.socket) -> None:
sock = curio.io.Socket(ssock)
try:
# First, ensure handshake (simple handshake) and command
async with curio.timeout_after(3): # type: ignore
data = await sock.recv(len(consts.HANDSHAKE_V1))
if data != consts.HANDSHAKE_V1:
raise Exception(data) # Invalid handshake
except (curio.errors.CancelledError, Exception) as e:
logger.error('HANDSHAKE from %s (%s)', address, 'timeout' if isinstance(e, curio.errors.CancelledError) else e)
# Close Source and continue
await sock.close()
return
sslsock = await context.wrap_socket(
sock, server_side=True # type: ignore
)
await group.spawn(tunneler, sslsock, address)
del sslsock
while True:
address: typing.Tuple[str, int] = ('', 0)
try:
@ -167,6 +188,8 @@ def process_connection(
# Close Source and continue
client.close()
logger.info('PROCESS %s stopped', os.getpid())
def tunnel_main():
cfg = config.read()