mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-24 03:45:38 +08:00
adds a zonefile announce endpoint
This commit is contained in:
@@ -1011,6 +1011,43 @@ class BlockstackAPIEndpointHandler(SimpleHTTPRequestHandler):
|
||||
self._reply_json(resp, status_code=202)
|
||||
return
|
||||
|
||||
def POST_raw_zonefile( self, ses, path_info ):
|
||||
"""
|
||||
Publish a zonefile which has *already* been announced.
|
||||
Return 200 and {'status': True, 'servers': ...} on success
|
||||
Return 401 when zonefile invalid with {'error': ...}
|
||||
"""
|
||||
request_schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'zonefile': {
|
||||
'type': 'string',
|
||||
'maxLength': RPC_MAX_ZONEFILE_LEN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
conf = blockstack_config.get_config(self.server.config_path)
|
||||
|
||||
server = (conf['server'], conf['port'])
|
||||
|
||||
request = self._read_json(schema=request_schema)
|
||||
if request is None:
|
||||
self._reply_json({"error": 'Invalid request'}, status_code=401)
|
||||
return
|
||||
elif 'error' in request:
|
||||
self._reply_json({"error": request["error"]}, status_code=401)
|
||||
return
|
||||
|
||||
zonefile_str = request.get('zonefile')
|
||||
|
||||
resp = zonefile.zonefile_data_publish(None, zonefile_str, [ server ])
|
||||
status_code = 200
|
||||
if 'error' in resp:
|
||||
status_code = 401
|
||||
|
||||
self._reply_json(resp, status_code=status_code)
|
||||
return
|
||||
|
||||
def PUT_name_zonefile( self, ses, path_info, name ):
|
||||
"""
|
||||
@@ -3271,6 +3308,20 @@ class BlockstackAPIEndpointHandler(SimpleHTTPRequestHandler):
|
||||
},
|
||||
},
|
||||
},
|
||||
r'^/v1/zonefile/': {
|
||||
'routes': {
|
||||
'POST' : self.POST_raw_zonefile
|
||||
},
|
||||
'whitelist': {
|
||||
'POST': {
|
||||
'name': 'zonefiles',
|
||||
'desc': 'publish a zonefile',
|
||||
'auth_session': False,
|
||||
'auth_pass': False,
|
||||
'need_data_key': False,
|
||||
},
|
||||
},
|
||||
},
|
||||
r'^/v1/names/({})/zonefile$'.format(NAME_CLASS): {
|
||||
'routes': {
|
||||
'GET': self.GET_name_zonefile,
|
||||
|
||||
Reference in New Issue
Block a user