maybe_sasl() -> sasl_auth(SASLParms)
This commit is contained in:
parent
8cc3db5e58
commit
2d93e27feb
3 changed files with 11 additions and 11 deletions
|
@ -6,7 +6,7 @@ from ircstates import Server
|
||||||
from irctokens import Line
|
from irctokens import Line
|
||||||
|
|
||||||
from .matching import BaseResponse
|
from .matching import BaseResponse
|
||||||
from .params import ConnectionParams
|
from .params import ConnectionParams, SASLParams
|
||||||
|
|
||||||
class SendPriority(IntEnum):
|
class SendPriority(IntEnum):
|
||||||
HIGH = 0
|
HIGH = 0
|
||||||
|
@ -63,5 +63,5 @@ class IServer(Server):
|
||||||
def collect_caps(self) -> List[str]:
|
def collect_caps(self) -> List[str]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def maybe_sasl(self) -> bool:
|
async def sasl_auth(self, sasl: SASLParams) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -83,8 +83,9 @@ class CAPContext(ServerContext):
|
||||||
if cap in caps:
|
if cap in caps:
|
||||||
caps.remove(cap)
|
caps.remove(cap)
|
||||||
|
|
||||||
if self.server.cap_agreed(CAP_SASL):
|
if (self.server.cap_agreed(CAP_SASL) and
|
||||||
await self.server.maybe_sasl()
|
not self.server.params.sasl is None):
|
||||||
|
await self.server.sasl_auth(self.server.params.sasl)
|
||||||
|
|
||||||
await self.server.send(build("CAP", ["END"]))
|
await self.server.send(build("CAP", ["END"]))
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -9,7 +9,7 @@ from irctokens import build, Line, tokenise
|
||||||
|
|
||||||
from .ircv3 import CAPContext, CAPS, CAP_SASL
|
from .ircv3 import CAPContext, CAPS, CAP_SASL
|
||||||
from .interface import (ConnectionParams, ICapability, IServer, SentLine,
|
from .interface import (ConnectionParams, ICapability, IServer, SentLine,
|
||||||
SendPriority)
|
SendPriority, SASLParams)
|
||||||
from .matching import BaseResponse
|
from .matching import BaseResponse
|
||||||
from .sasl import SASLContext, SASLResult
|
from .sasl import SASLContext, SASLResult
|
||||||
from .security import ssl_context
|
from .security import ssl_context
|
||||||
|
@ -143,17 +143,16 @@ class Server(IServer):
|
||||||
async def _cap_new(self, emit: Emit):
|
async def _cap_new(self, emit: Emit):
|
||||||
if not emit.tokens is None:
|
if not emit.tokens is None:
|
||||||
tokens = [t.split("=", 1)[0] for t in emit.tokens]
|
tokens = [t.split("=", 1)[0] for t in emit.tokens]
|
||||||
if CAP_SASL.available(tokens):
|
if CAP_SASL.available(tokens) and not self.params.sasl is None:
|
||||||
await self.maybe_sasl()
|
await self.sasl_auth(self.params.sasl)
|
||||||
|
|
||||||
async def maybe_sasl(self) -> bool:
|
async def sasl_auth(self, params: SASLParams) -> bool:
|
||||||
if (self.sasl_state == SASLResult.NONE and
|
if (self.sasl_state == SASLResult.NONE and
|
||||||
not self.params.sasl is None and
|
|
||||||
self.cap_agreed(CAP_SASL)):
|
self.cap_agreed(CAP_SASL)):
|
||||||
res = await SASLContext(self).from_params(self.params.sasl)
|
|
||||||
|
res = await SASLContext(self).from_params(params)
|
||||||
self.sasl_state = res
|
self.sasl_state = res
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# /CAP-related
|
# /CAP-related
|
||||||
|
|
Loading…
Reference in a new issue