Support only https_proxy.
This commit is contained in:
parent
190097fe53
commit
1aee1232f7
@ -239,6 +239,7 @@ Shell completion scripts for Bash, Fish and Zsh can be found in respective subdi
|
||||
- --stag : search bookmarks by a tag, or show all tags alphabetically (if no arguments).
|
||||
- Search results are indexed serially. This index is different from actual database index of a bookmark record which is shown in bold within `[]` after the URL.
|
||||
- **Encryption** is optional and manual. AES256 algorithm is used. To use encryption, the database file should be unlocked (-k) before using buku and locked (-l) afterwards. Between these 2 operations, the database file lies unencrypted on the disk, and NOT in memory. Also, note that the database file is *unencrypted on creation*.
|
||||
- **Proxy** support: environment variable *https_proxy*, if defined, is used to tunnel data for both http and https connections. The supported format is `http[s]://proxyhost:proxyport/`.
|
||||
|
||||
## GUI integration
|
||||
|
||||
|
16
buku.1
16
buku.1
@ -57,6 +57,8 @@ Bookmarks with immutable titles are listed with bold '(L)' after the URL.
|
||||
- Search results are indexed serially. This index is different from actual database index of a bookmark record which is shown in bold within '[]' after the URL.
|
||||
.PP
|
||||
\fIEncryption\fR is optional and manual. AES256 algorithm is used. To use encryption, the database file should be unlocked (-k) before using buku and locked (-l) afterwards. Between these 2 operations, the database file lies unencrypted on the disk, and NOT in memory. Also, note that the database file is \fBunencrypted on creation\fR.
|
||||
.PP
|
||||
\fIProxy\fR support: refer to the \fBENVIRONMENT\fR section.
|
||||
.SH GENERAL OPTIONS
|
||||
.TP
|
||||
.BI \-a " " \--add " URL [tag, ...]"
|
||||
@ -223,19 +225,11 @@ Exit buku.
|
||||
Overrides the default browser. Ref:
|
||||
.I http://docs.python.org/library/webbrowser.html
|
||||
.TP
|
||||
.BR http_proxy ", " HTTP_PROXY ", " https_proxy " or " HTTPS_PROXY"
|
||||
.BI https_proxy
|
||||
If defined, will be used to access http and https resources through the configured proxy. Supported format:
|
||||
|
||||
If defined, will be used to access http and https resources through the configured proxy.
|
||||
For https requests, if https proxy is not defined but http is, the latter will be used
|
||||
instead.
|
||||
http[s]://proxyhost:proxyport/
|
||||
|
||||
They should be in the following format:
|
||||
|
||||
http[s]://proxyhost:proxyport
|
||||
|
||||
Buku uses urllib3 for proxy support, but that library doesn't support authenticated
|
||||
proxies. So, if that's your need, you should use a local intermediate proxy, such as
|
||||
cntlm, TinyProxy or Polipo.
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
.IP 1. 4
|
||||
|
34
buku.py
34
buku.py
@ -1492,35 +1492,19 @@ def get_page_title(resp):
|
||||
return htmlparser.parsed_title
|
||||
|
||||
|
||||
def create_poolmanager(url):
|
||||
'''Creates a pool manager with proxy support, if needed.
|
||||
|
||||
Checks to see if there are proxy variables defined and creates
|
||||
a ProxyManager. If not, creates a PoolManager.
|
||||
def get_PoolManager():
|
||||
'''Creates a pool manager with proxy support, if applicable
|
||||
|
||||
:return: ProxyManager if https_proxy is defined, else PoolManager.
|
||||
'''
|
||||
|
||||
# Check if http_proxy or HTTP_PROXY is defined
|
||||
http_proxy = os.environ.get('http_proxy')
|
||||
if not http_proxy:
|
||||
http_proxy = os.environ.get('HTTP_PROXY')
|
||||
|
||||
# Check if https_proxy or HTTPS_PROXY is defined
|
||||
https_proxy = os.environ.get('https_proxy')
|
||||
if not https_proxy:
|
||||
https_proxy = os.environ.get('HTTPS_PROXY')
|
||||
print(https_proxy)
|
||||
|
||||
# If not, falls back to http_proxy, which is more common.
|
||||
if not https_proxy:
|
||||
https_proxy = http_proxy
|
||||
if https_proxy:
|
||||
return urllib3.ProxyManager(https_proxy)
|
||||
|
||||
# Create a pool manager with or without proxy support as needed.
|
||||
if url.startswith('http://') and http_proxy:
|
||||
manager = urllib3.ProxyManager(http_proxy)
|
||||
elif url.startswith('https://') and https_proxy:
|
||||
manager = urllib3.ProxyManager(https_proxy)
|
||||
else:
|
||||
manager = urllib3.PoolManager()
|
||||
return manager;
|
||||
return urllib3.PoolManager()
|
||||
|
||||
|
||||
def network_handler(url):
|
||||
@ -1544,7 +1528,7 @@ def network_handler(url):
|
||||
|
||||
if not http_handler:
|
||||
urllib3.disable_warnings()
|
||||
http_handler = create_poolmanager(url)
|
||||
http_handler = get_PoolManager()
|
||||
|
||||
try:
|
||||
while True:
|
||||
|
Loading…
x
Reference in New Issue
Block a user