-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoteview.py
More file actions
executable file
·33 lines (27 loc) · 861 Bytes
/
Copy pathremoteview.py
File metadata and controls
executable file
·33 lines (27 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import socket
from typing import Callable
from loguru import logger
from PIL import Image
from vnc.vncserver import VNCClientThread, VNCConfig
def vnc_server_thread(
vnc_config: VNCConfig,
vnc_bind: str,
vnc_port: int,
source: Callable[[], Image.Image],
):
sockServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockServer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sockServer.bind((vnc_bind, vnc_port))
logger.debug("VNC server started")
while True:
sockServer.listen(4)
(conn, (ip, port)) = sockServer.accept()
newthread = VNCClientThread(
sock=conn,
image_source=source,
ip=ip,
port=port,
vnc_config=vnc_config,
)
newthread.daemon = True
newthread.start()