mirror of https://github.com/Mikaela/Limnoria.git
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
11
src/conf.py
11
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:
|
||||
self.error()
|
||||
try:
|
||||
int(v.rsplit(':', 1)[1])
|
||||
except ValueError:
|
||||
self.error()
|
||||
if isSocketAddress(v):
|
||||
proxies = {
|
||||
'http': v,
|
||||
'https': v
|
||||
}
|
||||
else:
|
||||
self.error()
|
||||
proxyHandler = ProxyHandler(proxies)
|
||||
proxyOpenerDirector = build_opener(proxyHandler)
|
||||
install_opener(proxyOpenerDirector)
|
||||
|
|
Loading…
Reference in New Issue