Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2eb5f5e

Browse files
committed
Handling 'address already in use' for sqlmapapi server instance
1 parent 31d250f commit 2eb5f5e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/utils/api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os
1111
import re
1212
import shlex
13+
import socket
1314
import sqlite3
1415
import sys
1516
import tempfile
@@ -654,7 +655,13 @@ def server(host="0.0.0.0", port=RESTAPI_SERVER_PORT):
654655
DataStore.current_db.init()
655656

656657
# Run RESTful API
657-
run(host=host, port=port, quiet=True, debug=False)
658+
try:
659+
run(host=host, port=port, quiet=True, debug=False)
660+
except socket.error, ex:
661+
if "already in use" in getSafeExString(ex):
662+
logger.error("Address already in use ('%s:%s')" % (host, port))
663+
else:
664+
raise
658665

659666

660667
def _client(url, options=None):

0 commit comments

Comments
 (0)