@@ -240,18 +240,26 @@ def write_to_file(self, filename: Path):
240
240
with open (filename , 'w' ) as file :
241
241
json .dump (self .as_dict (anonymous = not self .show_target ), file , indent = 4 )
242
242
243
- def upload_to_ddosdb (self , host : str , token : str , protocol : str = 'https' , noverify : bool = False ) -> int :
243
+ def upload_to_ddosdb (self ,
244
+ host : str ,
245
+ token : str ,
246
+ protocol : str = 'https' ,
247
+ noverify : bool = False ,
248
+ shareable : bool = False ) -> int :
244
249
"""
245
250
Upload fingerprint to a DDoS-DB instance
246
251
:param host: hostname of the DDoS-DB instance, without schema (like db.example.com)
247
252
:param token: DDoS-DB Authorization Token
248
253
:param protocol: Protocol to use (http or https)
249
254
:param noverify: (bool) ignore invalid TLS certificate
255
+ :param shareable: (bool) allow the DDoS-DB to push fingerprint on to other DDoS-DB instances
250
256
:return: HTTP response code
251
257
"""
252
258
LOGGER .info (f'Uploading fingerprint to DDoS-DB: { host } ...' )
253
259
254
- fp_json = json .dumps (self .as_dict (anonymous = not self .show_target ))
260
+ fp_dict = self .as_dict (anonymous = not self .show_target )
261
+ fp_dict ['shareable' ] = bool (shareable )
262
+ fp_json = json .dumps (fp_dict )
255
263
headers = {
256
264
'Authorization' : f'Token { token } '
257
265
}
@@ -279,7 +287,7 @@ def upload_to_ddosdb(self, host: str, token: str, protocol: str = 'https', nover
279
287
elif r .status_code == 413 :
280
288
LOGGER .critical ('Fingerprint is too large to upload to this DDoS-DB instance.' )
281
289
elif r .status_code == 201 :
282
- LOGGER .info (f'Upload success! URL: https ://{ host } /details?key={ self .checksum } ' )
290
+ LOGGER .info (f'Upload success! URL: { protocol } ://{ host } /details?key={ self .checksum } ' )
283
291
else :
284
292
LOGGER .critical ('DDoS-DB Internal Server Error.' )
285
293
LOGGER .critical ('Error Code: {}' .format (r .status_code ))
0 commit comments