mirror of https://github.com/jesopo/ircrobots
Compare commits
6 Commits
7bb4c3d069
...
f2ba48a582
Author | SHA1 | Date |
---|---|---|
jesopo | f2ba48a582 | |
jesopo | cf2e69a9e2 | |
jesopo | a1a459c13e | |
jesopo | 81fa77cf29 | |
jesopo | 422a9a93c1 | |
jesopo | b04a0e0136 |
|
@ -8,7 +8,7 @@ from .contexts import ServerContext
|
|||
from .matching import Response, ANY
|
||||
from .interface import ICapability
|
||||
from .params import ConnectionParams, STSPolicy, ResumePolicy
|
||||
from .security import TLS_VERIFYCHAIN
|
||||
from .security import TLSVerifyChain
|
||||
|
||||
class Capability(ICapability):
|
||||
def __init__(self,
|
||||
|
@ -107,7 +107,7 @@ async def sts_transmute(params: ConnectionParams):
|
|||
since = (now-params.sts.created)
|
||||
if since <= params.sts.duration:
|
||||
params.port = params.sts.port
|
||||
params.tls = TLS_VERIFYCHAIN
|
||||
params.tls = TLSVerifyChain()
|
||||
async def resume_transmute(params: ConnectionParams):
|
||||
if params.resume is not None:
|
||||
params.host = params.resume.address
|
||||
|
@ -183,7 +183,7 @@ class CAPContext(ServerContext):
|
|||
if not params.tls:
|
||||
if "port" in sts_dict:
|
||||
params.port = int(sts_dict["port"])
|
||||
params.tls = TLS_VERIFYCHAIN
|
||||
params.tls = TLSVerifyChain()
|
||||
|
||||
await self.server.bot.disconnect(self.server)
|
||||
await self.server.bot.add_server(self.server.name, params)
|
||||
|
|
|
@ -2,7 +2,7 @@ from re import compile as re_compile
|
|||
from typing import List, Optional
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .security import TLS, TLS_NOVERIFY, TLS_VERIFYCHAIN
|
||||
from .security import TLS, TLSNoVerify, TLSVerifyChain
|
||||
|
||||
class SASLParams(object):
|
||||
mechanism: str
|
||||
|
@ -34,15 +34,15 @@ class ResumePolicy(object):
|
|||
RE_IPV6HOST = re_compile("\[([a-fA-F0-9:]+)\]")
|
||||
|
||||
_TLS_TYPES = {
|
||||
"+": TLS_VERIFYCHAIN,
|
||||
"~": TLS_NOVERIFY
|
||||
"+": TLSVerifyChain,
|
||||
"~": TLSNoVerify,
|
||||
}
|
||||
@dataclass
|
||||
class ConnectionParams(object):
|
||||
nickname: str
|
||||
host: str
|
||||
port: int
|
||||
tls: Optional[TLS] = TLS_VERIFYCHAIN
|
||||
tls: Optional[TLS] = field(default_factory=TLSVerifyChain)
|
||||
|
||||
username: Optional[str] = None
|
||||
realname: Optional[str] = None
|
||||
|
@ -76,7 +76,7 @@ class ConnectionParams(object):
|
|||
if not port_s:
|
||||
port_s = "6667"
|
||||
else:
|
||||
tls_type = _TLS_TYPES.get(port_s[0], None)
|
||||
tls_type = _TLS_TYPES.get(port_s[0], lambda: None)()
|
||||
if tls_type is not None:
|
||||
port_s = port_s[1:] or "6697"
|
||||
|
||||
|
|
|
@ -9,12 +9,10 @@ class TLS:
|
|||
# tls without verification
|
||||
class TLSNoVerify(TLS):
|
||||
pass
|
||||
TLS_NOVERIFY = TLSNoVerify()
|
||||
|
||||
# verify via CAs
|
||||
class TLSVerifyChain(TLS):
|
||||
pass
|
||||
TLS_VERIFYCHAIN = TLSVerifyChain()
|
||||
|
||||
# verify by a pinned hash
|
||||
class TLSVerifyHash(TLSNoVerify):
|
||||
|
|
|
@ -287,9 +287,10 @@ class Server(IServer):
|
|||
|
||||
if not self._process_queue:
|
||||
async with self._read_lwork:
|
||||
read_aw = self._read_line(PING_TIMEOUT)
|
||||
read_aw = asyncio.create_task(self._read_line(PING_TIMEOUT))
|
||||
wait_aw = asyncio.create_task(self._wait_for.wait())
|
||||
dones, notdones = await asyncio.wait(
|
||||
[read_aw, self._wait_for.wait()],
|
||||
[read_aw, wait_aw],
|
||||
return_when=asyncio.FIRST_COMPLETED
|
||||
)
|
||||
self._wait_for.clear()
|
||||
|
|
Loading…
Reference in New Issue