Make compression optional

ref: https://github.com/PrivateBin/PrivateBin/issues/38
Compression is optional only in v2 paste format.
Currently available types: 'zlib' and 'none'.
To set compression use `-c "none"` or `--compression "none".

When receiving paste, compression detected from 'adata' field
This commit is contained in:
r4sas
2019-06-07 09:12:00 +00:00
parent 4c124a33c0
commit d11beb10af
3 changed files with 44 additions and 12 deletions

View File

@@ -14,7 +14,16 @@ def send(args, api_client):
text = ""
paste = Paste(args.debug)
paste.setVersion(api_client.getVersion())
# get from server supported paste format version and update object
version = api_client.getVersion()
paste.setVersion(version)
# set compression type, works only on v2 pastes
if version == 2:
paste.setCompression(args.compression)
# add text in paste (if it provided)
paste.setText(text)
# If we set PASSWORD variable