mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
minor vnc fixes
This commit is contained in:
1
PKGBUILD
1
PKGBUILD
@@ -41,6 +41,7 @@ depends=(
|
|||||||
python-pam
|
python-pam
|
||||||
python-pillow
|
python-pillow
|
||||||
python-xlib
|
python-xlib
|
||||||
|
freetype2
|
||||||
v4l-utils
|
v4l-utils
|
||||||
nginx-mainline
|
nginx-mainline
|
||||||
openssl
|
openssl
|
||||||
|
|||||||
@@ -352,12 +352,12 @@ class RfbClient: # pylint: disable=too-many-instance-attributes
|
|||||||
"middle": bool(buttons & 0x2),
|
"middle": bool(buttons & 0x2),
|
||||||
},
|
},
|
||||||
wheel={
|
wheel={
|
||||||
"x": (32 if buttons & 0x40 else (-32 if buttons & 0x20 else 0)),
|
"x": (-4 if buttons & 0x40 else (4 if buttons & 0x20 else 0)),
|
||||||
"y": (32 if buttons & 0x10 else (-32 if buttons & 0x8 else 0)),
|
"y": (-4 if buttons & 0x10 else (4 if buttons & 0x8 else 0)),
|
||||||
},
|
},
|
||||||
move={
|
move={
|
||||||
"x": round(to_x / self._width * 65535 + -32768),
|
"x": round(to_x / self._width * 65535 + -32768),
|
||||||
"y": round(to_y / self._width * 65535 + -32768),
|
"y": round(to_y / self._height * 65535 + -32768),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import asyncio
|
|||||||
import asyncio.queues
|
import asyncio.queues
|
||||||
import socket
|
import socket
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
import contextlib
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
@@ -281,31 +282,31 @@ class VncServer:
|
|||||||
logger = get_logger(0)
|
logger = get_logger(0)
|
||||||
logger.info("Listening VNC on TCP [%s]:%d ...", self.__host, self.__port)
|
logger.info("Listening VNC on TCP [%s]:%d ...", self.__host, self.__port)
|
||||||
|
|
||||||
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
with contextlib.closing(socket.socket(socket.AF_INET6, socket.SOCK_STREAM)) as sock:
|
||||||
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, False)
|
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, False)
|
||||||
sock.bind((self.__host, self.__port))
|
sock.bind((self.__host, self.__port))
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
server = loop.run_until_complete(asyncio.start_server(
|
server = loop.run_until_complete(asyncio.start_server(
|
||||||
client_connected_cb=self.__handle_client,
|
client_connected_cb=self.__handle_client,
|
||||||
sock=sock,
|
sock=sock,
|
||||||
backlog=self.__max_clients,
|
backlog=self.__max_clients,
|
||||||
loop=loop,
|
loop=loop,
|
||||||
))
|
))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
except (SystemExit, KeyboardInterrupt):
|
except (SystemExit, KeyboardInterrupt):
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
server.close()
|
server.close()
|
||||||
loop.run_until_complete(server.wait_closed())
|
loop.run_until_complete(server.wait_closed())
|
||||||
tasks = asyncio.Task.all_tasks()
|
tasks = asyncio.Task.all_tasks()
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True))
|
loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True))
|
||||||
loop.close()
|
loop.close()
|
||||||
logger.info("Bye-bye")
|
logger.info("Bye-bye")
|
||||||
|
|
||||||
async def __handle_client(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
|
async def __handle_client(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
|
||||||
await _Client(reader, writer, self.__kvmd, self.__streamer, self.__symmap, self.__shared_params).run()
|
await _Client(reader, writer, self.__kvmd, self.__streamer, self.__symmap, self.__shared_params).run()
|
||||||
|
|||||||
Reference in New Issue
Block a user