Handling 'address already in use' for sqlmapapi server instance

This commit is contained in:
Miroslav Stampar 2015-12-09 12:20:09 +01:00
parent 31d250f98e
commit 2eb5f5e841

View File

@ -10,6 +10,7 @@ import logging
import os
import re
import shlex
import socket
import sqlite3
import sys
import tempfile
@ -654,7 +655,13 @@ def server(host="0.0.0.0", port=RESTAPI_SERVER_PORT):
DataStore.current_db.init()
# Run RESTful API
run(host=host, port=port, quiet=True, debug=False)
try:
run(host=host, port=port, quiet=True, debug=False)
except socket.error, ex:
if "already in use" in getSafeExString(ex):
logger.error("Address already in use ('%s:%s')" % (host, port))
else:
raise
def _client(url, options=None):