77
88BASE_PATH = Path (__file__ ).resolve ().parents [2 ]
99RAMDISK_PATH = BASE_PATH / "ramdisk"
10+ LT_PATH = BASE_PATH / "runs/lt"
1011BASE_TOPIC = "openWB-remote/"
1112REMOTE_SUPPORT_TOPIC = BASE_TOPIC + "support"
1213REMOTE_PARTNER_TOPIC = BASE_TOPIC + "partner"
1314CLOUD_TOPIC = BASE_TOPIC + "cloud"
1415support_tunnel : Popen = None
1516partner_tunnel : Popen = None
16-
17+ cloud_tunnel : Popen = None
1718logging .basicConfig (
1819 filename = str (RAMDISK_PATH / "remote_support.log" ),
1920 level = logging .INFO , format = '%(asctime)s: %(message)s'
@@ -77,6 +78,7 @@ def is_tunnel_closed(tunnel: Popen) -> bool:
7778 f"{ port } :localhost:22" , f"{ user } @remotesupport.openwb.de" ])
7879 log .info (f"tunnel running with pid { support_tunnel .pid } " )
7980 else :
81+ log .info ("unknown message: " + payload )
8082 elif msg .topic == REMOTE_PARTNER_TOPIC :
8183 if payload == 'stop' :
8284 if partner_tunnel is None :
@@ -103,7 +105,6 @@ def is_tunnel_closed(tunnel: Popen) -> bool:
103105 else :
104106 log .info ("unknown message: " + payload )
105107 elif msg .topic == CLOUD_TOPIC :
106- log .info ("1" )
107108 if payload == 'stop' :
108109 if cloud_tunnel is None :
109110 log .error ("received stop cloud message but tunnel is not running" )
@@ -113,8 +114,7 @@ def is_tunnel_closed(tunnel: Popen) -> bool:
113114 cloud_tunnel .wait (timeout = 3 )
114115 cloud_tunnel = None
115116 elif re .match (r'^([^;]+)(?:;([a-zA-Z0-9]+)(?:;([a-zA-Z0-9]+))?)?$' , payload ):
116- #elif payload != 'stio':
117- if is_tunnel_closed (partner_tunnel ):
117+ if is_tunnel_closed (cloud_tunnel ):
118118 splitted = payload .split (";" )
119119 if len (splitted ) != 3 :
120120 log .error ("invalid number of settings received!" )
@@ -123,7 +123,7 @@ def is_tunnel_closed(tunnel: Popen) -> bool:
123123 cloudnode = splitted [1 ]
124124 user = splitted [2 ]
125125 log .info ("start cloud tunnel" + token + cloudnode )
126- cloud_tunnel = Popen (["/var/www/html/openWB/runs/lt" , "-h" , "https://" + cloudnode + ".openwb.de/" , "-p" , "80" , "-s" , token ])
126+ cloud_tunnel = Popen ([LT_PATH , "-h" , "https://" + cloudnode + ".openwb.de/" , "-p" , "80" , "-s" , token ])
127127 log .info (f"cloud tunnel running with pid { cloud_tunnel .pid } " )
128128 else :
129129 log .info ("unknown message: " + payload )
0 commit comments