mirror of
https://github.com/sstent/containers.git
synced 2025-12-06 08:01:51 +00:00
34 lines
926 B
Python
34 lines
926 B
Python
import ssl
|
|
import unificontrol
|
|
from unificontrol.metaprogram import UnifiAPICall, UnifiAPICallNoSite, MetaNameFixer
|
|
from pprint import pprint
|
|
import os
|
|
|
|
FWD_IP = os.getenv('IP_ADDR')
|
|
cert = ssl.get_server_certificate(("unifi.service.dc1.consul", 8443))
|
|
# Store the cert in a safe place
|
|
...
|
|
# Fetch the cert from a safe place
|
|
client = unificontrol.UnifiClient(host="unifi.service.dc1.consul",
|
|
username="admin", password="tSxLlolgmXq6Zp1HplWK", site="default",
|
|
cert=cert)
|
|
|
|
edit_forward = UnifiAPICall(
|
|
"update Port forward",
|
|
"rest/portforward/613a5bb648247c60a5b14ba6",
|
|
json_args=[
|
|
('_id', '613a5bb648247c60a5b14ba6'),
|
|
('enabled', 'true'),
|
|
('dst_port', '51820'),
|
|
('fwd', FWD_IP),
|
|
('fwd_port', '51820'),
|
|
('name', 'wireguard'),
|
|
('proto', 'udp'),
|
|
('site_id', '5c9419f5e718399f4a746e7f'),
|
|
('src', 'any')],
|
|
method="PUT",
|
|
)
|
|
|
|
pprint(edit_forward(client))
|
|
|