Skip to content

Commit

Permalink
0.3.0
Browse files Browse the repository at this point in the history
New:
* Added validation of PrivateBin instance URL - #18 (it must contain trailing slash because POST is used)
* URL shortener support with various supported services - #19
* Shortener configuration, certificate validation and insecure warning settings can be configured in config file or via env

Changed:
* Restructured some parts of code by splitting big code chunks in funtions (encrypt/decrypt)
* Rework error messaging repeatable code (moved in utils)
* Reduce code duplication (requests session configuring)

Signed-off-by: r4sas <[email protected]>
  • Loading branch information
r4sas committed Sep 20, 2019
1 parent 9d82c72 commit 682b47f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.gitattributes export-ignore
.gitignore export-ignore
README.md export-ignore
2 changes: 1 addition & 1 deletion pbincli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# -*- coding: utf-8 -*-

__author__ = "R4SAS <[email protected]>"
__version__ = "0.2.2b1"
__version__ = "0.3.0"
__copyright__ = "Copyright (c) R4SAS"
__license__ = "MIT"
13 changes: 12 additions & 1 deletion pbincli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,19 @@ def __init__(self, settings=None):
def _yourls_init(self, settings):
if not settings['short_url']:
PBinCLIError("YOURLS: An API URL is required")
self.apiurl = settings['short_url']

# setting API URL
apiurl = settings['short_url']
if apiurl.endswith('/yourls-api.php'):
self.apiurl = apiurl
elif apiurl.endswith('/'):
self.apiurl = apiurl + 'yourls-api.php'
else:
PBinCLIError("YOURLS: Incorrect URL is provided.\n" +
"It must contain full address to 'yourls-api.php' script (like https://example.com/yourls-api.php)\n" +
"or just contain instance URL with '/' at the end (like https://example.com/)")

# validating for required credentials
if settings['short_user'] and settings['short_pass'] and settings['short_token'] is None:
self.auth_args = {'username': settings['short_user'], 'password': settings['short_pass']}
elif settings['short_user'] is None and settings['short_pass'] is None and settings['short_token']:
Expand Down

0 comments on commit 682b47f

Please sign in to comment.