mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 11:03:47 +03:00
add --servername option to support various of bottle server adapter
This commit is contained in:
parent
c6c5a937f9
commit
f5ffd9fa02
|
@ -637,7 +637,7 @@ def download(taskid, target, filename):
|
||||||
return jsonize({"success": False, "message": "File does not exist"})
|
return jsonize({"success": False, "message": "File does not exist"})
|
||||||
|
|
||||||
|
|
||||||
def server(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT):
|
def server(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, server_name='wsgiref'):
|
||||||
"""
|
"""
|
||||||
REST-JSON API server
|
REST-JSON API server
|
||||||
"""
|
"""
|
||||||
|
@ -655,7 +655,14 @@ def server(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT):
|
||||||
|
|
||||||
# Run RESTful API
|
# Run RESTful API
|
||||||
try:
|
try:
|
||||||
run(host=host, port=port, quiet=True, debug=False)
|
if server_name == 'gevent':
|
||||||
|
from gevent import monkey
|
||||||
|
monkey.patch_all()
|
||||||
|
elif server_name == 'eventlet':
|
||||||
|
import eventlet
|
||||||
|
eventlet.monkey_patch()
|
||||||
|
logger.debug('use {0} adapter run bottle'.format(server_name))
|
||||||
|
run(host=host, port=port, quiet=True, debug=False, server=server_name)
|
||||||
except socket.error, ex:
|
except socket.error, ex:
|
||||||
if "already in use" in getSafeExString(ex):
|
if "already in use" in getSafeExString(ex):
|
||||||
logger.error("Address already in use ('%s:%s')" % (host, port))
|
logger.error("Address already in use ('%s:%s')" % (host, port))
|
||||||
|
|
|
@ -37,11 +37,12 @@ def main():
|
||||||
apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_DEFAULT_PORT, action="store_true")
|
apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_DEFAULT_PORT, action="store_true")
|
||||||
apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_DEFAULT_ADDRESS, action="store")
|
apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_DEFAULT_ADDRESS, action="store")
|
||||||
apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_DEFAULT_PORT, type="int", action="store")
|
apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_DEFAULT_PORT, type="int", action="store")
|
||||||
|
apiparser.add_option("", "--servername", help="bottle Server adapter to use default is wsgiref, see bottle document ", default='wsgiref', action="store")
|
||||||
(args, _) = apiparser.parse_args()
|
(args, _) = apiparser.parse_args()
|
||||||
|
|
||||||
# Start the client or the server
|
# Start the client or the server
|
||||||
if args.server is True:
|
if args.server is True:
|
||||||
server(args.host, args.port)
|
server(args.host, args.port, server_name=args.servername)
|
||||||
elif args.client is True:
|
elif args.client is True:
|
||||||
client(args.host, args.port)
|
client(args.host, args.port)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user