mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-31 18:11:54 +08:00
streamer: send user-agent
This commit is contained in:
@@ -36,6 +36,8 @@ from ...logging import get_logger
|
|||||||
|
|
||||||
from ... import gpio
|
from ... import gpio
|
||||||
|
|
||||||
|
from ... import __version__
|
||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
class Streamer: # pylint: disable=too-many-instance-attributes
|
class Streamer: # pylint: disable=too-many-instance-attributes
|
||||||
@@ -118,10 +120,13 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
async def get_state(self) -> Dict:
|
async def get_state(self) -> Dict:
|
||||||
session = self.__ensure_session()
|
session = self.__ensure_session()
|
||||||
url = "http://%s:%d/state" % (self.__host, self.__port)
|
|
||||||
state = None
|
state = None
|
||||||
try:
|
try:
|
||||||
async with session.get(url, timeout=self.__timeout) as response:
|
async with session.get(
|
||||||
|
url="http://%s:%d/state" % (self.__host, self.__port),
|
||||||
|
headers={"User-Agent": "KVMD/%s" % (__version__)},
|
||||||
|
timeout=self.__timeout,
|
||||||
|
) as response:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
state = (await response.json())["result"]
|
state = (await response.json())["result"]
|
||||||
except (aiohttp.ClientConnectionError, aiohttp.ServerConnectionError):
|
except (aiohttp.ClientConnectionError, aiohttp.ServerConnectionError):
|
||||||
|
|||||||
Reference in New Issue
Block a user