mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +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
11
src/conf.py
11
src/conf.py
@ -35,6 +35,7 @@ import socket
|
|||||||
|
|
||||||
from . import ircutils, registry, utils
|
from . import ircutils, registry, utils
|
||||||
from .utils import minisix
|
from .utils import minisix
|
||||||
|
from .utils.net import isSocketAddress
|
||||||
from .version import version
|
from .version import version
|
||||||
from .i18n import PluginInternationalization
|
from .i18n import PluginInternationalization
|
||||||
_ = PluginInternationalization()
|
_ = PluginInternationalization()
|
||||||
@ -1179,17 +1180,13 @@ class HttpProxy(registry.String):
|
|||||||
def setValue(self, v):
|
def setValue(self, v):
|
||||||
proxies = {}
|
proxies = {}
|
||||||
if v != "":
|
if v != "":
|
||||||
# TODO: improve checks
|
if isSocketAddress(v):
|
||||||
if ':' not in v:
|
|
||||||
self.error()
|
|
||||||
try:
|
|
||||||
int(v.rsplit(':', 1)[1])
|
|
||||||
except ValueError:
|
|
||||||
self.error()
|
|
||||||
proxies = {
|
proxies = {
|
||||||
'http': v,
|
'http': v,
|
||||||
'https': v
|
'https': v
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
|
self.error()
|
||||||
proxyHandler = ProxyHandler(proxies)
|
proxyHandler = ProxyHandler(proxies)
|
||||||
proxyOpenerDirector = build_opener(proxyHandler)
|
proxyOpenerDirector = build_opener(proxyHandler)
|
||||||
install_opener(proxyOpenerDirector)
|
install_opener(proxyOpenerDirector)
|
||||||
|
Loading…
Reference in New Issue
Block a user