mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Improved HttpProxy validation routine
Validation routine for HttpProxy updated to use the newly introduced isSocketAddress() function
This commit is contained in:
parent
3e72aa5da5
commit
3a2b603f2f
17
src/conf.py
17
src/conf.py
@ -35,6 +35,7 @@ import socket
|
||||
|
||||
from . import ircutils, registry, utils
|
||||
from .utils import minisix
|
||||
from .utils.net import isSocketAddress
|
||||
from .version import version
|
||||
from .i18n import PluginInternationalization
|
||||
_ = PluginInternationalization()
|
||||
@ -1179,17 +1180,13 @@ class HttpProxy(registry.String):
|
||||
def setValue(self, v):
|
||||
proxies = {}
|
||||
if v != "":
|
||||
# TODO: improve checks
|
||||
if ':' not in v:
|
||||
if isSocketAddress(v):
|
||||
proxies = {
|
||||
'http': v,
|
||||
'https': v
|
||||
}
|
||||
else:
|
||||
self.error()
|
||||
try:
|
||||
int(v.rsplit(':', 1)[1])
|
||||
except ValueError:
|
||||
self.error()
|
||||
proxies = {
|
||||
'http': v,
|
||||
'https': v
|
||||
}
|
||||
proxyHandler = ProxyHandler(proxies)
|
||||
proxyOpenerDirector = build_opener(proxyHandler)
|
||||
install_opener(proxyOpenerDirector)
|
||||
|
Loading…
Reference in New Issue
Block a user