У меня есть эта схема:
DOMAIN = {
'banned': {
'schema': {
'ip': {
'type': 'string',
'regex': '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$',
'unique': True,
'required': True
},
'host': {
'type': 'string'
},
'country': {
'type': 'string'
},
'jail': {
'type': 'string'
}
}
}
}
Но когда я пытаюсь выполнить запрос, используя curl
, например:
curl -i http://localhost:5000/banned?where=ip=='8.8.8.8'
Я получаю эту ошибку:
HTTP/1.0 400 BAD REQUEST
Content-Type: application/json
Content-Length: 134
Server: Eve/1.0 Werkzeug/0.16.0 Python/3.7.3
Date: Thu, 23 Jan 2020 16:56:02 GMT
{"_status": "ERR", "_error": {"code": 400, "message": "The browser (or proxy) sent a request that this server could not understand."}}
Если я пытаюсь выполнить запрос, используя страну, работает:
curl -i http://localhost:5000/banned?where=country=='VE'
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 854
X-Total-Count: 2
Last-Modified: Thu, 23 Jan 2020 16:24:42 GMT
Server: Eve/1.0 Werkzeug/0.16.0 Python/3.7.3
Date: Thu, 23 Jan 2020 19:57:04 GMT
{"_items": [{"_id": "5e29c8c3def61367e225e6c8", "ip": "8.8.8.5", "host": "test-work", "country": "VE", "jail": "SSH", "_updated": "Thu, 23 Jan 2020 16:24:35 GMT", "_created": "Thu, 23 Jan 2020 16:24:35 GMT", "_etag": "7c6598e85b4977f7ef90d586ec2c9d3a9731878e", "_links": {"self": {"title": "Banned", "href": "banned/5e29c8c3def61367e225e6c8"}}}, {"_id": "5e29c8cadef61367e225e6c9", "ip": "8.8.8.8", "host": "test-work", "country": "VE", "jail": "SSH", "_updated": "Thu, 23 Jan 2020 16:24:42 GMT", "_created": "Thu, 23 Jan 2020 16:24:42 GMT", "_etag": "dfb770fa9837322896a5bd70768e3445ae29ce2b", "_links": {"self": {"title": "Banned", "href": "banned/5e29c8cadef61367e225e6c9"}}}], "_links": {"parent": {"title": "home", "href": "/"}, "self": {"title": "banned", "href": "banned?where=country==VE"}}, "_meta": {"page": 1, "max_results": 25, "total": 2}}
Есть ли обходной путь, чтобы сделать этот запрос по ip? или, может быть, мне нужно сохранить это поле в формате CIDR?