FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
validator-node-api/ping_ca.py at main · orcfax/validator-node-api · GitHub
orcfax
/
validator-node-api
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
7
Actions
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
validator-node-api
/
ping_ca.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (41 loc) · 1.24 KB
Breadcrumbs
validator-node-api
/
ping_ca.py
Copy path
File metadata and controls
58 lines (41 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Provide a mechanism to ping the server to see if everything is
working as expected.
ping_ca.py allows you to connect to a web-socket signed by a certificate
authority.
For more information about how the certifi procedure works see:
* https://stackoverflow.com/a/59209977/21120938
"""
import
asyncio
import
logging
import
ssl
import
time
from
typing
import
Final
import
certifi
import
websockets
# Set up logging
logging
.
basicConfig
(
format
=
"%(asctime)-15s %(levelname)s :: %(filename)s:%(lineno)s:%(funcName)s() :: %(message)s"
,
# noqa: E501
datefmt
=
"%Y-%m-%d %H:%M:%S"
,
level
=
"INFO"
,
handlers
=
[
logging
.
StreamHandler
(),
],
)
logging
.
Formatter
.
converter
=
time
.
gmtime
logger
=
logging
.
getLogger
(
__name__
)
PING_URI
:
Final
[
str
]
=
""
async
def
ping
():
"""Ping the server."""
validator_connection
=
f"
{
PING_URI
}
"
# pylint: disable=E1101
async
with
websockets
.
connect
(
validator_connection
,
ssl
=
ssl
.
create_default_context
(
cafile
=
certifi
.
where
())
)
as
websocket
:
await
websocket
.
send
(
"PING"
)
msg
=
await
websocket
.
recv
()
logger
.
info
(
msg
)
async
def
main
():
"""Primary entry point of this script."""
await
ping
()
if
__name__
==
"__main__"
:
asyncio
.
run
(
main
())
Back
|
FazBrowse Home
|
New Git URL