@@ -791,6 +791,18 @@ def get(self):
791
791
self .write (True )
792
792
793
793
class SDKEffectInstaller (EffectInstaller ):
794
+ def set_default_headers (self ):
795
+ if 'Origin' not in self .request .headers .keys ():
796
+ return
797
+ origin = self .request .headers ['Origin' ]
798
+ match = re .match (r'^(\w+)://([^/]*)/?' , origin )
799
+ if match is None :
800
+ return
801
+ protocol , domain = match .groups ()
802
+ if protocol != "http" and not domain .endswith (":9000" ) and not domain .endswith (".mod.audio" ):
803
+ return
804
+ self .set_header ("Access-Control-Allow-Origin" , origin )
805
+
794
806
@web .asynchronous
795
807
@gen .engine
796
808
def post (self ):
@@ -816,7 +828,7 @@ def set_default_headers(self):
816
828
if match is None :
817
829
return
818
830
protocol , domain = match .groups ()
819
- if protocol != "http" or not domain .endswith (":9000" ):
831
+ if protocol != "http" and not domain .endswith (":9000" ) and not domain . endswith ( ".mod.audio " ):
820
832
return
821
833
self .set_header ("Access-Control-Allow-Origin" , origin )
822
834
@@ -1135,7 +1147,7 @@ def get(self, instance):
1135
1147
logging .exception (e )
1136
1148
self .write (ok )
1137
1149
1138
- class RemoteWebSocket (websocket .WebSocketHandler ):
1150
+ class RemotePedalboardWebSocket (websocket .WebSocketHandler ):
1139
1151
def check_origin (self , origin ):
1140
1152
match = re .match (r'^(\w+)://([^/]*)/?' , origin )
1141
1153
if match is None :
@@ -1156,6 +1168,41 @@ def on_message(self, pedalboard_id):
1156
1168
self .write_message ("true" )
1157
1169
self .close ()
1158
1170
1171
+ class RemotePluginWebSocket (websocket .WebSocketHandler ):
1172
+ def check_origin (self , origin ):
1173
+ match = re .match (r'^(\w+)://([^/]*)/?' , origin )
1174
+ if match is None :
1175
+ return False
1176
+ protocol , domain = match .groups ()
1177
+ if protocol not in ("http" , "https" ):
1178
+ return False
1179
+ if domain != "mod.audio" and not domain .endswith (".mod.audio" ):
1180
+ return False
1181
+ return True
1182
+
1183
+ @gen .coroutine
1184
+ def on_message (self , package ):
1185
+ if not package :
1186
+ hwdesc = get_hardware_descriptor ()
1187
+ self .write_message (json .dumps ({
1188
+ 'bin-compat' : hwdesc .get ('bin-compat' , "Unknown" ),
1189
+ 'platform' : hwdesc .get ('platform' , "Unknown" ),
1190
+ 'version' : IMAGE_VERSION ,
1191
+ }))
1192
+ return
1193
+
1194
+ filename = os .path .join (DOWNLOAD_TMP_DIR , "remote.tar.gz" )
1195
+
1196
+ with open (filename , 'wb' ) as fh :
1197
+ fh .write (b64decode (package ))
1198
+
1199
+ resp = yield gen .Task (install_package , filename )
1200
+
1201
+ if resp ['ok' ]:
1202
+ SESSION .msg_callback ("rescan " + b64encode (json .dumps (resp ).encode ("utf-8" )).decode ("utf-8" ))
1203
+
1204
+ self .write_message (json .dumps (resp ))
1205
+
1159
1206
class ServerWebSocket (websocket .WebSocketHandler ):
1160
1207
@gen .coroutine
1161
1208
def open (self ):
@@ -2368,7 +2415,8 @@ def get(self):
2368
2415
(r"/js/templates.js$" , BulkTemplateLoader ),
2369
2416
2370
2417
(r"/websocket/?$" , ServerWebSocket ),
2371
- (r"/rpbsocket/?$" , RemoteWebSocket ),
2418
+ (r"/rpbsocket/?$" , RemotePedalboardWebSocket ),
2419
+ (r"/rplsocket/?$" , RemotePluginWebSocket ),
2372
2420
2373
2421
(r"/(.*)" , TimelessStaticFileHandler , {"path" : HTML_DIR }),
2374
2422
],
0 commit comments