GNServer 0.0.0.0.20__tar.gz → 0.0.0.0.21__tar.gz
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-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer/__init__.py +1 -1
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer/_app.py +85 -7
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer.egg-info/PKG-INFO +1 -1
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/PKG-INFO +1 -1
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/setup.py +1 -1
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer/___client.py +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer/_client.py +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer.egg-info/SOURCES.txt +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer.egg-info/dependency_links.txt +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer.egg-info/requires.txt +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/GNServer.egg-info/top_level.txt +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/LICENSE +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/GNServer/mmbConfig.json +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/LICENSE +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/MANIFEST.in +0 -0
- {gnserver-0.0.0.0.20 → gnserver-0.0.0.0.21}/setup.cfg +0 -0
@@ -52,19 +52,97 @@ class _BaseEXception(Exception):
|
|
52
52
|
self._message = message
|
53
53
|
|
54
54
|
def assembly(self):
|
55
|
+
"""
|
56
|
+
Собирает ошибку в ответ типа `GNResponse`
|
57
|
+
"""
|
55
58
|
return gn.GNResponse(f'gn:error:{self._code}', payload={'msg': self._message})
|
56
59
|
|
57
60
|
|
58
61
|
class GNExceptions:
|
59
62
|
class UnprocessableEntity(_BaseEXception):
|
60
63
|
def __init__(self):
|
64
|
+
"""
|
65
|
+
# Некорректные данные
|
66
|
+
"""
|
61
67
|
super().__init__('422', "Unprocessable Entity")
|
62
68
|
|
63
69
|
class BadRequest(_BaseEXception):
|
64
70
|
def __init__(self):
|
71
|
+
"""
|
72
|
+
# неправильного синтаксис url или параметров
|
73
|
+
"""
|
65
74
|
super().__init__('400', "Bad Request")
|
66
75
|
|
76
|
+
class Forbidden(_BaseEXception):
|
77
|
+
def __init__(self):
|
78
|
+
"""
|
79
|
+
# Доступ запрещён, даже при наличии авторизации
|
80
|
+
"""
|
81
|
+
super().__init__('403', "Forbidden")
|
82
|
+
|
83
|
+
|
84
|
+
class NotFound(_BaseEXception):
|
85
|
+
def __init__(self):
|
86
|
+
"""
|
87
|
+
# Ресурс не найден
|
88
|
+
"""
|
89
|
+
super().__init__('404', "Not Found")
|
90
|
+
|
91
|
+
|
92
|
+
class MethodNotAllowed(_BaseEXception):
|
93
|
+
def __init__(self):
|
94
|
+
"""
|
95
|
+
# Метод запроса не поддерживается данным ресурсом
|
96
|
+
"""
|
97
|
+
super().__init__('405', "Method Not Allowed")
|
98
|
+
|
99
|
+
|
100
|
+
class Conflict(_BaseEXception):
|
101
|
+
def __init__(self):
|
102
|
+
"""
|
103
|
+
# Конфликт состояния ресурса (например, дубликат)
|
104
|
+
"""
|
105
|
+
super().__init__('409', "Conflict")
|
106
|
+
|
107
|
+
|
108
|
+
class InternalServerError(_BaseEXception):
|
109
|
+
def __init__(self):
|
110
|
+
"""
|
111
|
+
# Внутренняя ошибка сервера
|
112
|
+
"""
|
113
|
+
super().__init__('500', "Internal Server Error")
|
114
|
+
|
115
|
+
|
116
|
+
class NotImplemented(_BaseEXception):
|
117
|
+
def __init__(self):
|
118
|
+
"""
|
119
|
+
# Метод или функционал ещё не реализован
|
120
|
+
"""
|
121
|
+
super().__init__('501', "Not Implemented")
|
122
|
+
|
123
|
+
|
124
|
+
class BadGateway(_BaseEXception):
|
125
|
+
def __init__(self):
|
126
|
+
"""
|
127
|
+
# Ошибка шлюза или прокси при обращении к апстриму
|
128
|
+
"""
|
129
|
+
super().__init__('502', "Bad Gateway")
|
130
|
+
|
131
|
+
|
132
|
+
class ServiceUnavailable(_BaseEXception):
|
133
|
+
def __init__(self):
|
134
|
+
"""
|
135
|
+
# Сервис временно недоступен
|
136
|
+
"""
|
137
|
+
super().__init__('503', "Service Unavailable")
|
138
|
+
|
67
139
|
|
140
|
+
class GatewayTimeout(_BaseEXception):
|
141
|
+
def __init__(self):
|
142
|
+
"""
|
143
|
+
# Таймаут при обращении к апстриму
|
144
|
+
"""
|
145
|
+
super().__init__('504', "Gateway Timeout")
|
68
146
|
|
69
147
|
def guess_type(filename: str) -> str:
|
70
148
|
"""
|
@@ -552,8 +630,8 @@ class App:
|
|
552
630
|
)
|
553
631
|
|
554
632
|
if allowed:
|
555
|
-
|
556
|
-
|
633
|
+
raise GNExceptions.MethodNotAllowed()
|
634
|
+
raise GNExceptions.NotFound()
|
557
635
|
|
558
636
|
|
559
637
|
def fastFile(self, path: str, file_path: str, cors: Optional[gn.CORSObject] = None, template: Optional[gn.TemplateObject] = None, payload: Optional[dict] = None):
|
@@ -564,7 +642,7 @@ class App:
|
|
564
642
|
file_path = file_path[:-1]
|
565
643
|
|
566
644
|
if not os.path.isfile(file_path):
|
567
|
-
|
645
|
+
raise GNExceptions.NotFound()
|
568
646
|
|
569
647
|
fileObject = gn.FileObject(file_path, template)
|
570
648
|
return gn.GNResponse('ok', payload=payload, files=fileObject, cors=cors)
|
@@ -579,7 +657,7 @@ class App:
|
|
579
657
|
file_path = file_path[:-1]
|
580
658
|
|
581
659
|
if not os.path.isfile(file_path):
|
582
|
-
|
660
|
+
raise GNExceptions.NotFound()
|
583
661
|
|
584
662
|
fileObject = gn.FileObject(file_path, template)
|
585
663
|
return gn.GNResponse('ok', payload=payload, files=fileObject, cors=cors)
|
@@ -591,8 +669,8 @@ class App:
|
|
591
669
|
@self.post('/!gn-vm-host/ping', cors=gn.CORSObject(None))
|
592
670
|
async def r_ping(request: gn.GNRequest):
|
593
671
|
|
594
|
-
if request.
|
595
|
-
|
672
|
+
if request.client.remote_addr != '127.0.0.1':
|
673
|
+
raise GNExceptions.Forbidden()
|
596
674
|
return gn.GNResponse('ok', {'time': datetime.datetime.now(datetime.UTC).isoformat()})
|
597
675
|
|
598
676
|
|
@@ -692,7 +770,7 @@ class App:
|
|
692
770
|
|
693
771
|
async def _handle_request(self, request: gn.GNRequest, mode: int):
|
694
772
|
|
695
|
-
request.
|
773
|
+
request.client._data['remote_addr'] = self._quic._network_paths[0].addr[0]
|
696
774
|
|
697
775
|
try:
|
698
776
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|