GNServer 0.0.0.0.12__py3-none-any.whl → 0.0.0.0.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- GNServer/_app.py +20 -12
- {gnserver-0.0.0.0.12.dist-info → gnserver-0.0.0.0.13.dist-info}/METADATA +1 -1
- gnserver-0.0.0.0.13.dist-info/RECORD +7 -0
- gnserver-0.0.0.0.12.dist-info/RECORD +0 -7
- {gnserver-0.0.0.0.12.dist-info → gnserver-0.0.0.0.13.dist-info}/WHEEL +0 -0
- {gnserver-0.0.0.0.12.dist-info → gnserver-0.0.0.0.13.dist-info}/licenses/LICENSE +0 -0
- {gnserver-0.0.0.0.12.dist-info → gnserver-0.0.0.0.13.dist-info}/top_level.txt +0 -0
GNServer/_app.py
CHANGED
@@ -75,6 +75,7 @@ def guess_type(filename: str) -> str:
|
|
75
75
|
"webp": "image/webp",
|
76
76
|
"svg": "image/svg+xml",
|
77
77
|
"avif": "image/avif",
|
78
|
+
"ico": "image/x-icon",
|
78
79
|
|
79
80
|
# 🔹 Видео (современные форматы)
|
80
81
|
"mp4": "video/mp4",
|
@@ -171,6 +172,14 @@ def resolve_cors(origin_url: str, rules: list[str]) -> bool:
|
|
171
172
|
- "https://*.site.tld" -> с проверкой схемы
|
172
173
|
- "!<regex>" -> полное соответствие по regex к origin_url
|
173
174
|
"""
|
175
|
+
|
176
|
+
if origin_url == 'gn:proxy:sys':
|
177
|
+
return True
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
174
183
|
origin = origin_url.rstrip("/")
|
175
184
|
pu = urlparse(origin)
|
176
185
|
scheme = (pu.scheme or "").lower()
|
@@ -430,7 +439,7 @@ class App:
|
|
430
439
|
return gn.GNResponse("gn:backend:801", {'error': 'Cors error. Route has cors but request has no origin url.'})
|
431
440
|
if not resolve_cors(request._origin, r.cors._allow_origins):
|
432
441
|
return gn.GNResponse("gn:backend:802", {'error': 'Cors error: origin'})
|
433
|
-
if request.method not in r.cors._allow_methods:
|
442
|
+
if request.method not in r.cors._allow_methods and '*' not in r.cors._allow_methods:
|
434
443
|
return gn.GNResponse("gn:backend:803", {'error': 'Cors error: method'})
|
435
444
|
|
436
445
|
sig = inspect.signature(r.handler)
|
@@ -457,12 +466,14 @@ class App:
|
|
457
466
|
|
458
467
|
result = await r.handler(**kw)
|
459
468
|
if isinstance(result, gn.GNResponse):
|
469
|
+
if result._cors is None:
|
470
|
+
result._cors = self._cors
|
460
471
|
if result._cors is not None and result._cors != r.cors:
|
461
472
|
if request._origin is None:
|
462
473
|
return gn.GNResponse("gn:backend:801", {'error': 'Cors error. Route has cors but request has no origin url.'})
|
463
|
-
if not resolve_cors(request._origin,
|
474
|
+
if not resolve_cors(request._origin, result._cors._allow_origins):
|
464
475
|
return gn.GNResponse("gn:backend:802", {'error': 'Cors error: origin'})
|
465
|
-
if request.method not in
|
476
|
+
if request.method not in result._cors._allow_methods and '*' not in result._cors._allow_methods:
|
466
477
|
return gn.GNResponse("gn:backend:803", {'error': 'Cors error: method'})
|
467
478
|
return result
|
468
479
|
else:
|
@@ -542,7 +553,7 @@ class App:
|
|
542
553
|
|
543
554
|
if not stream: # если не стрим, то ждем конец quic стрима и запускаем обработку ответа
|
544
555
|
if event.end_stream:
|
545
|
-
request = gn.GNRequest.deserialize(buf,
|
556
|
+
request = gn.GNRequest.deserialize(buf, 1)
|
546
557
|
# request.stream_id = event.stream_id
|
547
558
|
# loop = asyncio.get_event_loop()
|
548
559
|
# request.fut = loop.create_future()
|
@@ -567,7 +578,7 @@ class App:
|
|
567
578
|
del buf[:lenght]
|
568
579
|
|
569
580
|
# формируем запрос
|
570
|
-
request = gn.GNRequest.deserialize(data,
|
581
|
+
request = gn.GNRequest.deserialize(data, 1)
|
571
582
|
|
572
583
|
logger.debug(request, f'event.stream_id -> {event.stream_id}')
|
573
584
|
|
@@ -615,32 +626,29 @@ class App:
|
|
615
626
|
async for chunk in response: # type: ignore[misc]
|
616
627
|
chunk._stream = True
|
617
628
|
chunk = await self.resolve_response(chunk)
|
618
|
-
self._quic.send_stream_data(request.stream_id, chunk.serialize(
|
629
|
+
self._quic.send_stream_data(request.stream_id, chunk.serialize(1), end_stream=False)
|
619
630
|
self.transmit()
|
620
631
|
|
621
632
|
l = gn.GNResponse('gn:end-stream')
|
622
633
|
l._stream = True
|
623
634
|
l = self.resolve_response(l)
|
624
|
-
self._quic.send_stream_data(request.stream_id, l.serialize(
|
635
|
+
self._quic.send_stream_data(request.stream_id, l.serialize(1), end_stream=True)
|
625
636
|
self.transmit()
|
626
637
|
return
|
627
638
|
|
628
639
|
|
629
640
|
response = await self.resolve_response(response)
|
630
|
-
self._quic.send_stream_data(request.stream_id, response.serialize(
|
641
|
+
self._quic.send_stream_data(request.stream_id, response.serialize(1), end_stream=True)
|
631
642
|
logger.debug(f'Отправлен на сервер ответ -> {response.command} {response.payload if response.payload and len((response.payload)) < 200 else ''}')
|
632
643
|
self.transmit()
|
633
644
|
except Exception as e:
|
634
645
|
logger.error('GNServer: error\n' + traceback.format_exc())
|
635
646
|
|
636
647
|
response = gn.GNResponse('gn:backend:500')
|
637
|
-
self._quic.send_stream_data(request.stream_id, response.serialize(
|
648
|
+
self._quic.send_stream_data(request.stream_id, response.serialize(1), end_stream=True)
|
638
649
|
self.transmit()
|
639
650
|
|
640
651
|
async def resolve_response(self, response: gn.GNResponse) -> gn.GNResponse:
|
641
|
-
if response._cors is None:
|
642
|
-
response._cors = self._api._cors
|
643
|
-
|
644
652
|
await response.assembly()
|
645
653
|
|
646
654
|
return response
|
@@ -0,0 +1,7 @@
|
|
1
|
+
GNServer/__init__.py,sha256=GLKkKL03phIhxRLpl2X1ibwTw7BvnMMOwKgRD578RaU,1404
|
2
|
+
GNServer/_app.py,sha256=NiINMe7Vv2F1H-m1G6ovOfbvGJgmGGQdTHCc8v_igJI,24201
|
3
|
+
gnserver-0.0.0.0.13.dist-info/licenses/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
|
4
|
+
gnserver-0.0.0.0.13.dist-info/METADATA,sha256=Eswpz48CSM0tezRIZGpkU_1Y7aEg1YDDFNNlQduVZJk,805
|
5
|
+
gnserver-0.0.0.0.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
gnserver-0.0.0.0.13.dist-info/top_level.txt,sha256=-UOUBuD4u7Qkb1o5PdcwyA3kx8xCH2lwy0tJHi26Wb4,9
|
7
|
+
gnserver-0.0.0.0.13.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
GNServer/__init__.py,sha256=GLKkKL03phIhxRLpl2X1ibwTw7BvnMMOwKgRD578RaU,1404
|
2
|
-
GNServer/_app.py,sha256=t4h0RFttUAGufXm2moYsWLju52NnghisrK1d4RkSmHs,24029
|
3
|
-
gnserver-0.0.0.0.12.dist-info/licenses/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
|
4
|
-
gnserver-0.0.0.0.12.dist-info/METADATA,sha256=U17Yx7wt5IXf_sTaDuVLFXwcFHrHQdW2X_P7KpCfsU8,805
|
5
|
-
gnserver-0.0.0.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
gnserver-0.0.0.0.12.dist-info/top_level.txt,sha256=-UOUBuD4u7Qkb1o5PdcwyA3kx8xCH2lwy0tJHi26Wb4,9
|
7
|
-
gnserver-0.0.0.0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|