bug fixes and improvements

- aliases are now handled properly in ABCH
- removed final escargot leftovers (dev webconsole)
- OSCAR etc. logging was not at log level debug
- removed leftover debug code
This commit is contained in:
Athena Funderburg committed 2026-11-06 00:36:13 +00:00
1 parent 4bf878556b
commit 6451bb9426
46 files changed
+307 -541

No files matched your search

+10 -4
View File
@@ -1169,7 +1169,7 @@ class BackendSession(Session):
ctc = self._add_to_list(user, ctc_head, lst, name, group_id, nickname = nickname) ctc = self._add_to_list(user, ctc_head, lst, name, group_id, nickname = nickname)
if lst & ContactList.FL: if lst & ContactList.FL:
# FL needs a matching RL on the contact # FL needs a matching RL on the contact
ctc_me = self._add_to_list(ctc_head, user, ContactList.RL, user.email, None) # type: Optional[Contact] ctc_me = self._add_to_list(ctc_head, user, ContactList.RL, backend.util_get_display_email(user), None) # type: Optional[Contact]
# `ctc_head` was added to `user`'s RL # `ctc_head` was added to `user`'s RL
for sess_added in backend._sc.get_sessions_by_user(ctc_head): for sess_added in backend._sc.get_sessions_by_user(ctc_head):
#if sess_added is self: continue #if sess_added is self: continue
@@ -1267,9 +1267,15 @@ class BackendSession(Session):
contacts = detail.contacts contacts = detail.contacts
updated = False updated = False
display_email = self.backend.util_get_display_email(ctc_head)
if name is not None and isinstance(name, str) and (
name.lower() in (ctc_head.email.lower(), display_email.lower())
or (name.lower().endswith('@crosstalk.im') and self.backend.util_get_uuid_from_email(name) == ctc_head.uuid)
):
name = display_email
if ctc_head.uuid not in contacts: if ctc_head.uuid not in contacts:
contacts[ctc_head.uuid] = Contact(ctc_head, set(), ContactList.Empty, UserStatus(name or ctc_head.email), ContactDetail(_gen_contact_id(detail))) contacts[ctc_head.uuid] = Contact(ctc_head, set(), ContactList.Empty, UserStatus(name or display_email), ContactDetail(_gen_contact_id(detail)))
updated = True updated = True
ctc = contacts[ctc_head.uuid] ctc = contacts[ctc_head.uuid]
@@ -1435,8 +1441,8 @@ They've attached this message, as well:
membership.role = CircleRole.StatePendingOutbound membership.role = CircleRole.StatePendingOutbound
membership.state = CircleState.WaitingResponse membership.state = CircleState.WaitingResponse
membership.inviter_uuid = inviter.uuid membership.inviter_uuid = inviter.uuid
membership.inviter_email = inviter.email membership.inviter_email = backend.util_get_display_email(inviter)
membership.inviter_name = inviter.status.name or inviter.email membership.inviter_name = inviter.status.name or backend.util_get_display_email(inviter)
membership.invite_message = invite_message membership.invite_message = invite_message
self.backend._mark_circle_modified(circle) self.backend._mark_circle_modified(circle)
-125
View File
@@ -1,125 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Webconsole</title>
</head>
<body>
<script>
document.addEventListener('DOMContentLoaded', () => {
new App('{{ wsurl }}');
});
class App {
constructor(wsurl) {
this.ws = new WebSocket(wsurl);
this.ws.onmessage = this._onWSMessage.bind(this);
this.$input = document.getElementById('input');
this.$output = document.getElementById('output');
this.$input.addEventListener('keypress', this._onKeyPress.bind(this));
this.hist = [];
this.histIndex = 0;
}
_onWSMessage(evt) {
this.appendOutput(evt.data, 'out');
}
appendOutput(text, cls) {
const $elm = document.createElement('p');
$elm.textContent = text;
if (cls) $elm.setAttribute('class', cls);
this.$output.appendChild($elm);
this.$output.scrollTop = this.$output.scrollHeight;
}
_onKeyPress(evt) {
if (evt.shiftKey) return;
const k = evt.keyCode;
const $input = this.$input;
if (k == 13) {
const text = $input.value;
$input.value = '';
this.appendOutput(text, 'in');
this.ws.send(text);
this.hist.push(text);
if (this.hist.length > 150) {
this.hist.splice(0, this.hist.length - 100);
}
this.histIndex = this.hist.length;
evt.preventDefault();
return false;
} else if (k == 38) {
this.histIndex -= 1;
if (this.histIndex < 0) {
this.histIndex = this.hist.length - 1;
}
if (this.histIndex >= 0) {
$input.value = this.hist[this.histIndex];
} else {
$input.value = '';
}
evt.preventDefault();
return false;
} else if (k == 40) {
this.histIndex += 1;
if (this.histIndex >= this.hist.length) {
this.histIndex = 0;
}
if (this.histIndex < this.hist.length) {
$input.value = this.hist[this.histIndex];
} else {
$input.value = '';
}
evt.preventDefault();
return false;
}
}
}
</script>
<div id="output"></div>
<textarea id="input"></textarea>
<style>
* {
box-sizing: border-box;
}
body {
margin: 1vh;
background: #999999;
}
#output {
height: 82vh;
background: #DDDDDD;
border: 1px solid #000000;
padding: 0.3em;
font-family: monospace;
white-space: pre-wrap;
overflow: scroll;
}
#input {
height: 15vh;
width: 100%;
}
#output p {
margin: 0em 0em 0.2em;
padding: 0.2em 0.3em;
}
#output .in {
font-weight: bold;
}
#output .in::before {
color: #666666;
content: "\3C \3C \3C ";
}
#output p:hover {
background: #99CC99;
}
</style>
</body>
</html>
-121
View File
@@ -1,121 +0,0 @@
from typing import Dict, Set, Tuple, Any, List, Optional
import asyncio, sys, io, cProfile, pstats, traceback, util.misc
from aiohttp import web
from aiohttp.web import WSMsgType
from core.backend import Backend
from core.http import render
def register(loop: asyncio.AbstractEventLoop, backend: Backend, http_app: web.Application) -> None:
util.misc.add_to_jinja_env(http_app, 'dev', 'dev/tmpl')
http_app['webconsole'] = Webconsole(loop, backend)
http_app.router.add_get('/dev', handle_index)
http_app.router.add_get('/dev/ws', handle_websocket)
async def handle_index(req: web.Request) -> web.Response:
return render(req, 'dev:index.html', { 'wsurl': 'ws://localhost/dev/ws' })
async def handle_websocket(req: web.Request) -> web.StreamResponse:
webconsole: Webconsole = req.app['webconsole']
ws = web.WebSocketResponse()
await ws.prepare(req)
webconsole.websocks.add(ws)
await ws.send_str("Webconsole on.")
async for msg in ws:
type = msg.type
data = msg.data
if type == WSMsgType.ERROR:
print("ws error with exception {}".format(ws.exception()))
continue
if type == WSMsgType.TEXT:
data = data.strip()
if data:
ret = webconsole.run(data)
if ret:
await ws.send_str(ret)
continue
print("ws unknown", type, data[:30])
webconsole.websocks.remove(ws)
return ws
class Webconsole:
__slots__ = ('loop', 'locals', 'objs', 'websocks', 'i')
loop: asyncio.AbstractEventLoop
locals: Dict[str, object]
objs: Dict[object, str]
websocks: Set[web.WebSocketResponse]
i: int
def __init__(self, loop: asyncio.AbstractEventLoop, backend: Backend) -> None:
self.loop = loop
self.locals = {
'_': None,
'be': backend,
'dir': useful_dir,
'dirfull': dir,
'prof': profile,
}
self.objs = {}
self.websocks = set()
self.i = 0
backend._dev = self
def run(self, cmd: str) -> str:
tmp = io.StringIO()
sys.stdout = tmp
try:
self.locals['_'] = exec(compile(cmd + '\n', '<stdin>', 'single'), None, self.locals) # type: ignore
except:
(exctype, excvalue, tb) = sys.exc_info() # type: Tuple[Any, Any, Any]
ret = '\n'.join(traceback.format_exception(exctype, excvalue, tb))
else:
ret = tmp.getvalue()
finally:
sys.stdout = sys.__stdout__
return ret
def connect(self, obj: object) -> None:
varname = 'k{}'.format(self.i)
self.i += 1
self.objs[obj] = varname
self.locals[varname] = obj
msg = "# Connect: `{}`".format(varname)
for ws in self.websocks:
self.loop.create_task(ws.send_str(msg))
def disconnect(self, obj: object) -> None:
varname = self.objs.pop(obj)
msg = "# Disconnect: `{}`".format(varname)
self.locals.pop(varname, None)
for ws in self.websocks:
self.loop.create_task(ws.send_str(msg))
_PROFILE: Optional[cProfile.Profile] = None
def profile(*restrictions: Any) -> None:
global _PROFILE
if _PROFILE is None:
_PROFILE = cProfile.Profile()
_PROFILE.enable()
print("Profiling ON")
return
_PROFILE.disable()
ps = pstats.Stats(_PROFILE).sort_stats('cumulative')
ps.print_stats(*restrictions)
_PROFILE = None
def useful_dir(*args: Any) -> List[str]:
return [
x for x in dir(*args)
if not x.endswith('__')
]
-1
View File
@@ -63,7 +63,6 @@ def register(loop: asyncio.AbstractEventLoop, backend: Backend, registry: Option
backend.add_runner(AIOHTTPRunner(settings.ADMIN_HOST, settings.ADMIN_PORT, app, service = 'Admin')) backend.add_runner(AIOHTTPRunner(settings.ADMIN_HOST, settings.ADMIN_PORT, app, service = 'Admin'))
if not AdminAuth.configured(): if not AdminAuth.configured():
print('[Admin] <Info> ADMIN_KEY is not set, so nobody can sign into the admin panel yet (see settings.py)') print('[Admin] <Info> ADMIN_KEY is not set, so nobody can sign into the admin panel yet (see settings.py)')
print(f'[Admin] <Info> Admin panel on http://{settings.ADMIN_HOST}:{settings.ADMIN_PORT}/')
return app return app
def create_app(backend: Backend, registry: Optional[ClientRegistry]) -> web.Application: def create_app(backend: Backend, registry: Optional[ClientRegistry]) -> web.Application:
+2 -2
View File
@@ -248,7 +248,7 @@ class LegacyCtrl:
handler = self._handler(command) handler = self._handler(command)
if handler is None: if handler is None:
# anything else is acknowledged and dropped, so the client stops resending it # anything else is acknowledged and dropped, so the client stops resending it
self.logger.info('[Client] Unhandled command', hex(command), 'from V{}'.format(self.version)) self.logger.debug('[Client] Unhandled command', hex(command), 'from V{}'.format(self.version))
self.ack(header) self.ack(header)
return return
handler(header, data) handler(header, data)
@@ -483,7 +483,7 @@ class LegacyCtrl:
self._store_offline(target, plain) self._store_offline(target, plain)
return return
except Exception as ex: except Exception as ex:
self.logger.info('[Client] Could not open a chat:', str(ex)) self.logger.debug('[Client] Could not open a chat:', str(ex))
return return
evt.send_when_joined(target.uuid, md) evt.send_when_joined(target.uuid, md)
+3 -3
View File
@@ -65,7 +65,7 @@ class ListenerICQ(asyncio.DatagramProtocol):
def error_received(self, exc: Exception) -> None: def error_received(self, exc: Exception) -> None:
# an ICMP port unreachable from a client that went away; its session times out by itself # an ICMP port unreachable from a client that went away; its session times out by itself
self.logger.info('UDP error:', str(exc)) self.logger.debug('UDP error:', str(exc))
def send(self, packet: bytes, addr: Address) -> None: def send(self, packet: bytes, addr: Address) -> None:
if self.transport is not None: if self.transport is not None:
@@ -77,7 +77,7 @@ class ListenerICQ(asyncio.DatagramProtocol):
try: try:
parsed = wire.parse(packet) parsed = wire.parse(packet)
if parsed is None: if parsed is None:
self.logger.info('Dropped a datagram that is no ICQ packet from', addr[0]) self.logger.debug('Dropped a datagram that is no ICQ packet from', addr[0])
return return
header, data = parsed header, data = parsed
self.logger.debug('[Client]', header, 'from', addr) self.logger.debug('[Client]', header, 'from', addr)
@@ -132,7 +132,7 @@ class ListenerICQ(asyncio.DatagramProtocol):
now = time.monotonic() now = time.monotonic()
for ctrl in list(self.by_uin.values()): for ctrl in list(self.by_uin.values()):
if now - ctrl.last_activity > SESSION_TIMEOUT: if now - ctrl.last_activity > SESSION_TIMEOUT:
ctrl.logger.info('Timed out') ctrl.logger.debug('Timed out')
ctrl.close() ctrl.close()
for addr, noted in list(self.preauth.items()): for addr, noted in list(self.preauth.items()):
if now - noted > PREAUTH_LIFETIME: if now - noted > PREAUTH_LIFETIME:
+8 -8
View File
@@ -246,7 +246,7 @@ class ICQFoodgroup:
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
envelope_tlv = find_tlv(tlvs, 0x0001) envelope_tlv = find_tlv(tlvs, 0x0001)
if envelope_tlv is None or len(envelope_tlv.data) < 2: if envelope_tlv is None or len(envelope_tlv.data) < 2:
self.logger.info('[Client] ICQ__DB_QUERY without its envelope') self.logger.debug('[Client] ICQ__DB_QUERY without its envelope')
return return
# TLV 0x01: u16 (LE) length, u32 UIN, u16 request type, u16 sequence, [u16 meta subtype], request data # TLV 0x01: u16 (LE) length, u32 UIN, u16 request type, u16 sequence, [u16 meta subtype], request data
@@ -258,32 +258,32 @@ class ICQFoodgroup:
request_type = reader.u16() request_type = reader.u16()
seq = reader.u16() seq = reader.u16()
except ValueError: except ValueError:
self.logger.info('[Client] Truncated ICQ__DB_QUERY') self.logger.debug('[Client] Truncated ICQ__DB_QUERY')
return return
query = ICQContext(client, context, message.request_id, seq) query = ICQContext(client, context, message.request_id, seq)
if request_type == ICQRequest.OfflineMessages: if request_type == ICQRequest.OfflineMessages:
self.logger.info('[Client] ICQ__DB_QUERY offline messages') self.logger.debug('[Client] ICQ__DB_QUERY offline messages')
offline_messages(query) offline_messages(query)
elif request_type == ICQRequest.DeleteOfflineMessages: elif request_type == ICQRequest.DeleteOfflineMessages:
self.logger.info('[Client] ICQ__DB_QUERY delete offline messages') self.logger.debug('[Client] ICQ__DB_QUERY delete offline messages')
delete_offline_messages(query) delete_offline_messages(query)
elif request_type == ICQRequest.Meta: elif request_type == ICQRequest.Meta:
try: try:
subtype = reader.u16() subtype = reader.u16()
except ValueError: except ValueError:
return return
self.logger.info('[Client] ICQ__DB_QUERY meta', hex(subtype)) self.logger.debug('[Client] ICQ__DB_QUERY meta', hex(subtype))
handler = META_HANDLERS.get(subtype) handler = META_HANDLERS.get(subtype)
if handler is None: if handler is None:
self.logger.info('[Client] Unsupported ICQ meta request', hex(subtype)) self.logger.debug('[Client] Unsupported ICQ meta request', hex(subtype))
return return
try: try:
handler(query, reader) handler(query, reader)
except ValueError: except ValueError:
self.logger.info('[Client] Malformed ICQ meta request', hex(subtype)) self.logger.debug('[Client] Malformed ICQ meta request', hex(subtype))
else: else:
self.logger.info('[Client] Unknown ICQ__DB_QUERY request type', hex(request_type)) self.logger.debug('[Client] Unknown ICQ__DB_QUERY request type', hex(request_type))
# offline messages # offline messages
+3 -3
View File
@@ -23,14 +23,14 @@ def handle(ctrl: 'LegacyCtrl', header: 'Header', data: bytes) -> None:
subtype = reader.u16() subtype = reader.u16()
handler = HANDLERS.get(subtype) handler = HANDLERS.get(subtype)
if handler is None: if handler is None:
ctrl.logger.info('[Client] Unhandled META_USER request', hex(subtype)) ctrl.logger.debug('[Client] Unhandled META_USER request', hex(subtype))
reply(ctrl, header, subtype, MetaResult.Ok) reply(ctrl, header, subtype, MetaResult.Ok)
return return
ctrl.logger.info('[Client] META_USER', hex(subtype)) ctrl.logger.debug('[Client] META_USER', hex(subtype))
try: try:
handler(ctrl, header, reader) handler(ctrl, header, reader)
except ValueError: except ValueError:
ctrl.logger.info('[Client] Malformed META_USER request', hex(subtype)) ctrl.logger.debug('[Client] Malformed META_USER request', hex(subtype))
def reply(ctrl: 'LegacyCtrl', header: 'Header', subtype: int, result: int, body: bytes = b'') -> None: def reply(ctrl: 'LegacyCtrl', header: 'Header', subtype: int, result: int, body: bytes = b'') -> None:
ctrl.send(Server.MetaUser, LE().u16(subtype).u8(result).raw(body if result == MetaResult.Ok else b'').bytes(), seq2 = header.seq2) ctrl.send(Server.MetaUser, LE().u16(subtype).u8(result).raw(body if result == MetaResult.Ok else b'').bytes(), seq2 = header.seq2)
+36 -36
View File
@@ -81,39 +81,39 @@ class MSIMCtrl:
nc1, nc2 = self.nonce[:32], self.nonce[32:] nc1, nc2 = self.nonce[:32], self.nonce[32:]
# log what we got # log what we got
self.logger.info('Packet email:', email) self.logger.debug('Packet email:', email)
self.logger.info('Packet response:', response) self.logger.debug('Packet response:', response)
self.logger.info('Packet clientver:', clientver) self.logger.debug('Packet clientver:', clientver)
if (uuid := self.backend.util_get_uuid_from_email(email)) is None: if (uuid := self.backend.util_get_uuid_from_email(email)) is None:
self.logger.info('E-mail not found!') self.logger.debug('E-mail not found!')
else: else:
# get our hashed password # get our hashed password
hashed_pwd = self.backend.user_service.msim_get_sha1_password(email) hashed_pwd = self.backend.user_service.msim_get_sha1_password(email)
if hashed_pwd is None: if hashed_pwd is None:
self.logger.info('MySpaceIM frontend-specific password not found!') self.logger.debug('MySpaceIM frontend-specific password not found!')
else: else:
final_hash = hashlib.sha1(b''.join([hashed_pwd, nc2])).digest() final_hash = hashlib.sha1(b''.join([hashed_pwd, nc2])).digest()
rc4_key = final_hash[:16] # we only need the first 128 bits of the result rc4_key = final_hash[:16] # we only need the first 128 bits of the result
self.logger.info('Hashed password:', hashed_pwd.hex(' ')) self.logger.debug('Hashed password:', hashed_pwd.hex(' '))
self.logger.info('Full hash:', final_hash.hex(' ')) self.logger.debug('Full hash:', final_hash.hex(' '))
self.logger.info('RC4 key:', rc4_key.hex(' ')) self.logger.debug('RC4 key:', rc4_key.hex(' '))
arc4 = ARC4(rc4_key) arc4 = ARC4(rc4_key)
blob = arc4.decrypt(response) blob = arc4.decrypt(response)
self.logger.info('RC4 blob data:', blob) self.logger.debug('RC4 blob data:', blob)
seperator = blob.find(bytes(4)) seperator = blob.find(bytes(4))
if seperator != -1: if seperator != -1:
blob_nc1 = blob[:32] blob_nc1 = blob[:32]
blob_email = blob[32:seperator] blob_email = blob[32:seperator]
self.logger.info('nc1 (context):', nc1) self.logger.debug('nc1 (context):', nc1)
self.logger.info('nc1 (request):', blob_nc1) self.logger.debug('nc1 (request):', blob_nc1)
self.logger.info('E-mail (blob):', blob_email) self.logger.debug('E-mail (blob):', blob_email)
if nc1 == blob_nc1 and email == blob_email.decode(): if nc1 == blob_nc1 and email == blob_email.decode():
valid = True valid = True
@@ -127,7 +127,7 @@ class MSIMCtrl:
self.bs = self.backend.login(uuid, self.client, BackendEventHandler(self), option=LoginOption.BootOthers) self.bs = self.backend.login(uuid, self.client, BackendEventHandler(self), option=LoginOption.BootOthers)
# log that they successfully signed in and send reply giving sesskey / user id / username / etc # log that they successfully signed in and send reply giving sesskey / user id / username / etc
self.logger.info(email, "successfully signed-in!") self.logger.debug(email, "successfully signed-in!")
self.send_reply({ self.send_reply({
'lc': 2, 'lc': 2,
'sesskey': self.sesskey, 'sesskey': self.sesskey,
@@ -167,13 +167,13 @@ class MSIMCtrl:
def get_user_by_id(id: int) -> Optional[User]: def get_user_by_id(id: int) -> Optional[User]:
if (uuid := self.backend.util_get_uuid_from_user_id(id)) is None: if (uuid := self.backend.util_get_uuid_from_user_id(id)) is None:
self.logger.info('User ID', id, 'not found!') self.logger.debug('User ID', id, 'not found!')
self.send_persist_error(cmd, dsn, lid, rid, f'User ID {id} not found') self.send_persist_error(cmd, dsn, lid, rid, f'User ID {id} not found')
return None return None
found_user = self.backend._load_user_record(uuid) found_user = self.backend._load_user_record(uuid)
if found_user is None: if found_user is None:
self.logger.info('Unable to find uuid') self.logger.debug('Unable to find uuid')
self.send_persist_error(cmd, dsn, lid, rid, 'Unable to find uuid') self.send_persist_error(cmd, dsn, lid, rid, 'Unable to find uuid')
return None return None
@@ -310,7 +310,7 @@ class MSIMCtrl:
body_dict = unmarshal_msim_dict(body) body_dict = unmarshal_msim_dict(body)
target = body_dict['Target'] target = body_dict['Target']
self.logger.info('Target:', target) self.logger.debug('Target:', target)
self.send_persist_reply(cmd, dsn, lid, rid, { self.send_persist_reply(cmd, dsn, lid, rid, {
'WebTicket': TARGET_HOST 'WebTicket': TARGET_HOST
@@ -318,7 +318,7 @@ class MSIMCtrl:
# 514;0;9 (2^512;0;9) - update contact info # 514;0;9 (2^512;0;9) - update contact info
case (514, 0, 9): case (514, 0, 9):
self.logger.info('Update contact info') self.logger.debug('Update contact info')
# 2;1;16 - undocumented # 2;1;16 - undocumented
# #
@@ -328,7 +328,7 @@ class MSIMCtrl:
self.send_persist_reply(cmd, dsn, lid, rid, '') self.send_persist_reply(cmd, dsn, lid, rid, '')
case _: case _:
self.logger.info(f'Unknown persist command: {cmd};{dsn};{lid}') self.logger.debug(f'Unknown persist command: {cmd};{dsn};{lid}')
def on_connect(self) -> None: def on_connect(self) -> None:
self.send_reply({ self.send_reply({
@@ -352,7 +352,7 @@ class MSIMCtrl:
f = getattr(self, f'_m_{command}') f = getattr(self, f'_m_{command}')
f(m) f(m)
except AttributeError: except AttributeError:
self.logger.info('Invalid command:', command) self.logger.debug('Invalid command:', command)
def send_reply(self, data_pairs: Dict[str, int | str | bytes | bool]) -> None: def send_reply(self, data_pairs: Dict[str, int | str | bytes | bool]) -> None:
self.writer.write(data_pairs) self.writer.write(data_pairs)
@@ -414,11 +414,11 @@ class BackendEventHandler(event.BackendEventHandler):
self.ctrl = ctrl self.ctrl = ctrl
def on_maintenance_message(self, *args: Any, **kwargs: Any) -> None: def on_maintenance_message(self, *args: Any, **kwargs: Any) -> None:
self.ctrl.logger.info('on_maintenance message') self.ctrl.logger.debug('on_maintenance message')
pass pass
def on_maintenance_boot(self) -> None: def on_maintenance_boot(self) -> None:
self.ctrl.logger.info('on_maintenance_boot') self.ctrl.logger.debug('on_maintenance_boot')
pass pass
def on_presence_notification( def on_presence_notification(
@@ -427,69 +427,69 @@ class BackendEventHandler(event.BackendEventHandler):
send_status_on_bl: bool = False, sess_id: Optional[int] = None, send_status_on_bl: bool = False, sess_id: Optional[int] = None,
updated_phone_info: Optional[Dict[str, Any]] = None, updated_phone_info: Optional[Dict[str, Any]] = None,
) -> None: ) -> None:
self.ctrl.logger.info('on_presence_notification') self.ctrl.logger.debug('on_presence_notification')
pass pass
def on_presence_self_notification(self, old_substatus: Substatus, *, update_status: bool = True, def on_presence_self_notification(self, old_substatus: Substatus, *, update_status: bool = True,
update_info: bool = True) -> None: update_info: bool = True) -> None:
self.ctrl.logger.info('on_presence_self_notification') self.ctrl.logger.debug('on_presence_self_notification')
pass pass
def on_chat_invite( def on_chat_invite(
self, chat: Chat, inviter: User, *, circle: bool = False, inviter_id: Optional[str] = None, self, chat: Chat, inviter: User, *, circle: bool = False, inviter_id: Optional[str] = None,
invite_msg: str = '', invite_msg: str = '',
) -> None: ) -> None:
self.ctrl.logger.info('on_chat_invite') self.ctrl.logger.debug('on_chat_invite')
pass pass
def on_declined_chat_invite(self, chat: Chat, circle: bool = False) -> None: def on_declined_chat_invite(self, chat: Chat, circle: bool = False) -> None:
self.ctrl.logger.info('on_declined_chat_invite') self.ctrl.logger.debug('on_declined_chat_invite')
pass pass
def on_added_me(self, user: User, *, adder_id: Optional[str] = None, def on_added_me(self, user: User, *, adder_id: Optional[str] = None,
message: Optional[TextWithData] = None) -> None: message: Optional[TextWithData] = None) -> None:
self.ctrl.logger.info('on_added_me') self.ctrl.logger.debug('on_added_me')
pass pass
def on_removed_me(self, user: User) -> None: def on_removed_me(self, user: User) -> None:
self.ctrl.logger.info('on_removed_me') self.ctrl.logger.debug('on_removed_me')
pass pass
def on_contact_request_denied(self, user_added: User, message: Optional[str], *, def on_contact_request_denied(self, user_added: User, message: Optional[str], *,
contact_id: Optional[str] = None) -> None: contact_id: Optional[str] = None) -> None:
self.ctrl.logger.info('on_contact_request_denied') self.ctrl.logger.debug('on_contact_request_denied')
pass pass
def on_oim_sent(self, oim: OIM) -> None: def on_oim_sent(self, oim: OIM) -> None:
self.ctrl.logger.info('on_oim_sent') self.ctrl.logger.debug('on_oim_sent')
pass pass
def on_login_elsewhere(self, option: LoginOption) -> None: def on_login_elsewhere(self, option: LoginOption) -> None:
self.ctrl.logger.info('on_login_elsewhere') self.ctrl.logger.debug('on_login_elsewhere')
pass pass
def on_circle_invite_revoked(self, chat_id: str) -> None: def on_circle_invite_revoked(self, chat_id: str) -> None:
self.ctrl.logger.info('on_circle_invite_revoked') self.ctrl.logger.debug('on_circle_invite_revoked')
pass pass
def on_accepted_circle_invite(self, circle: Circle) -> None: def on_accepted_circle_invite(self, circle: Circle) -> None:
self.ctrl.logger.info('on_accepted_circle_invite') self.ctrl.logger.debug('on_accepted_circle_invite')
pass pass
def on_circle_updated(self, circle: Circle) -> None: def on_circle_updated(self, circle: Circle) -> None:
self.ctrl.logger.info('on_circle_updated') self.ctrl.logger.debug('on_circle_updated')
pass pass
def on_left_circle(self, circle: Circle) -> None: def on_left_circle(self, circle: Circle) -> None:
self.ctrl.logger.info('on_left_circle') self.ctrl.logger.debug('on_left_circle')
pass pass
def on_circle_role_updated(self, chat_id: str, role: CircleRole) -> None: def on_circle_role_updated(self, chat_id: str, role: CircleRole) -> None:
self.ctrl.logger.info('on_circle_role_updated') self.ctrl.logger.debug('on_circle_role_updated')
pass pass
def on_circle_created(self, circle: Circle) -> None: def on_circle_created(self, circle: Circle) -> None:
self.ctrl.logger.info('on_circle_created') self.ctrl.logger.debug('on_circle_created')
pass pass
def on_close(self) -> None: def on_close(self) -> None:
+8 -8
View File
@@ -1093,7 +1093,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
bs.me_accept_circle_invite(circle, send_events=False) bs.me_accept_circle_invite(circle, send_events=False)
backend.loop.create_task(_dispatch_circle_invite_status(backend, user, circle, False)) backend.loop.create_task(_dispatch_circle_invite_status(backend, user, circle, False))
except error.MemberNotInCircle: except error.MemberNotInCircle:
error_msg = 'User `{email}` does not have membership in `Circle`'.format(email=head.email) error_msg = 'User `{email}` does not have membership in `Circle`'.format(email=backend.util_get_display_email(head))
return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', { return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', {
'cachekey': cachekey, 'cachekey': cachekey,
'host': settings.ADDRESSBOOK_HOST, 'host': settings.ADDRESSBOOK_HOST,
@@ -1101,7 +1101,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
'error': error_msg, 'error': error_msg,
}, status=500) }, status=500)
except error.MemberAlreadyInCircle: except error.MemberAlreadyInCircle:
error_msg = 'User `{email}` already accepted in `Circle`'.format(email=head.email) error_msg = 'User `{email}` already accepted in `Circle`'.format(email=backend.util_get_display_email(head))
return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', { return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', {
'cachekey': cachekey, 'cachekey': cachekey,
'host': settings.ADDRESSBOOK_HOST, 'host': settings.ADDRESSBOOK_HOST,
@@ -1136,7 +1136,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
try: try:
bs.me_invite_user_to_circle(circle, head, invite_message=invite_message) bs.me_invite_user_to_circle(circle, head, invite_message=invite_message)
except error.MemberNotInCircle: except error.MemberNotInCircle:
error_msg = 'User `{email}` does not have membership in `Circle`'.format(email=head.email) error_msg = 'User `{email}` does not have membership in `Circle`'.format(email=backend.util_get_display_email(head))
return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', { return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', {
'cachekey': cachekey, 'cachekey': cachekey,
'host': settings.ADDRESSBOOK_HOST, 'host': settings.ADDRESSBOOK_HOST,
@@ -1144,7 +1144,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
'error': error_msg, 'error': error_msg,
}, status=500) }, status=500)
except error.MemberAlreadyInvitedToCircle: except error.MemberAlreadyInvitedToCircle:
error_msg = 'User `{email}` already invited to `Circle`'.format(email=head.email) error_msg = 'User `{email}` already invited to `Circle`'.format(email=backend.util_get_display_email(head))
return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', { return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', {
'cachekey': cachekey, 'cachekey': cachekey,
'host': settings.ADDRESSBOOK_HOST, 'host': settings.ADDRESSBOOK_HOST,
@@ -1174,7 +1174,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
bs.me_decline_circle_invite(circle, send_events=False) bs.me_decline_circle_invite(circle, send_events=False)
backend.loop.create_task(_dispatch_circle_invite_status(backend, user, circle, False)) backend.loop.create_task(_dispatch_circle_invite_status(backend, user, circle, False))
except error.MemberNotInCircle: except error.MemberNotInCircle:
error_msg = 'User `{email}` does not have membership in `Circle`'.format(email=head.email) error_msg = 'User `{email}` does not have membership in `Circle`'.format(email=backend.util_get_display_email(head))
return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', { return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', {
'cachekey': cachekey, 'cachekey': cachekey,
'host': settings.ADDRESSBOOK_HOST, 'host': settings.ADDRESSBOOK_HOST,
@@ -1182,7 +1182,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
'error': error_msg, 'error': error_msg,
}, status=500) }, status=500)
except error.MemberAlreadyInCircle: except error.MemberAlreadyInCircle:
error_msg = 'User `{email}` already accepted in `Circle`'.format(email=head.email) error_msg = 'User `{email}` already accepted in `Circle`'.format(email=backend.util_get_display_email(head))
return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', { return render(req, 'msn:abservice/ManageWLConnectionResponse.xml', {
'cachekey': cachekey, 'cachekey': cachekey,
'host': settings.ADDRESSBOOK_HOST, 'host': settings.ADDRESSBOOK_HOST,
@@ -1210,7 +1210,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
add_ctc = True add_ctc = True
if add_ctc: if add_ctc:
try: try:
bs.me_contact_add(contact_uuid, models.ContactList.FL, name=head.email) bs.me_contact_add(contact_uuid, models.ContactList.FL, name=backend.util_get_display_email(head))
except error.ContactListIsFull: except error.ContactListIsFull:
return schema_fault(req, 'http://www.msn.com/webservices/AddressBook/ManageWLConnection', 'Contact list is full') return schema_fault(req, 'http://www.msn.com/webservices/AddressBook/ManageWLConnection', 'Contact list is full')
except: except:
@@ -1237,7 +1237,7 @@ def ab_ManageWLConnection(req: web.Request, header: Any, action: Any, bs: Backen
'now': now_str, 'now': now_str,
'user': user, 'user': user,
}) })
def ab_BreakConnection(req: web.Request, header: Any, action: Any, bs: BackendSession) -> web.Response: def ab_BreakConnection(req: web.Request, header: Any, action: Any, bs: BackendSession) -> web.Response:
backend: Backend = req.app['backend'] backend: Backend = req.app['backend']
cachekey = secrets.token_urlsafe(172) cachekey = secrets.token_urlsafe(172)
+2 -2
View File
@@ -91,7 +91,7 @@
{% if ctc.detail.last_name %} {% if ctc.detail.last_name %}
<lastName>{{ ctc.detail.last_name }}</lastName> <lastName>{{ ctc.detail.last_name }}</lastName>
{% endif %} {% endif %}
<passportName>{{ ctc.head.email }}</passportName> <passportName>{{ display_email(ctc.head) }}</passportName>
<IsPassportNameHidden>false</IsPassportNameHidden> <IsPassportNameHidden>false</IsPassportNameHidden>
<displayName>{{ ctc.status.name }}</displayName> <displayName>{{ ctc.status.name }}</displayName>
<puid>{{ puid_format(ctc.head.uuid) }}</puid> <puid>{{ puid_format(ctc.head.uuid) }}</puid>
@@ -198,7 +198,7 @@
</annotations> </annotations>
<contactType>Me</contactType> <contactType>Me</contactType>
<quickName>{{ user.status.name }}</quickName> <quickName>{{ user.status.name }}</quickName>
<passportName>{{ user.email }}</passportName> <passportName>{{ display_email(user) }}</passportName>
<IsPassportNameHidden>false</IsPassportNameHidden> <IsPassportNameHidden>false</IsPassportNameHidden>
<displayName>{{ user.status.name }}</displayName> <displayName>{{ user.status.name }}</displayName>
<puid>{{ puid_format(user.uuid) }}</puid> <puid>{{ puid_format(user.uuid) }}</puid>
@@ -33,7 +33,7 @@
<abInfo> <abInfo>
<ownerPuid>0</ownerPuid> <ownerPuid>0</ownerPuid>
<OwnerCID>{{ cid_format(user.uuid, decimal = True) }}</OwnerCID> <OwnerCID>{{ cid_format(user.uuid, decimal = True) }}</OwnerCID>
<ownerEmail>{{ user.email }}</ownerEmail> <ownerEmail>{{ display_email(user) }}</ownerEmail>
<fDefault>true</fDefault> <fDefault>true</fDefault>
<joinedNamespace>false</joinedNamespace> <joinedNamespace>false</joinedNamespace>
<IsBot>false</IsBot> <IsBot>false</IsBot>
@@ -247,7 +247,7 @@
<abInfo> <abInfo>
<ownerPuid>0</ownerPuid> <ownerPuid>0</ownerPuid>
<OwnerCID>{% if ab_id.startswith('00000000-0000-0000-0009-') %}{{ cid_format(ab_id, decimal = True) }}{% else %}{{ cid_format(user.uuid, decimal = True) }}{% endif %}</OwnerCID> <OwnerCID>{% if ab_id.startswith('00000000-0000-0000-0009-') %}{{ cid_format(ab_id, decimal = True) }}{% else %}{{ cid_format(user.uuid, decimal = True) }}{% endif %}</OwnerCID>
<ownerEmail>{% if ab_id.startswith('00000000-0000-0000-0009-') %}{{ ab_id }}@live.com{% else %}{{ user.email }}{% endif %}</ownerEmail> <ownerEmail>{% if ab_id.startswith('00000000-0000-0000-0009-') %}{{ ab_id }}@live.com{% else %}{{ display_email(user) }}{% endif %}</ownerEmail>
<fDefault>true</fDefault> <fDefault>true</fDefault>
<joinedNamespace>false</joinedNamespace> <joinedNamespace>false</joinedNamespace>
<IsBot>false</IsBot> <IsBot>false</IsBot>
@@ -15,10 +15,10 @@
<contactId>{{ head.uuid }}</contactId> <contactId>{{ head.uuid }}</contactId>
<contactInfo> <contactInfo>
<contactType>LivePending</contactType> <contactType>LivePending</contactType>
<quickName>{{ head.email }}</quickName> <quickName>{{ display_email(head) }}</quickName>
<passportName>{{ head.email }}</passportName> <passportName>{{ display_email(head) }}</passportName>
<IsPassportNameHidden>false</IsPassportNameHidden> <IsPassportNameHidden>false</IsPassportNameHidden>
<displayName>{{ head.email }}</displayName> <displayName>{{ display_email(head) }}</displayName>
<puid>{{ puid_format(user.uuid) }}</puid> <puid>{{ puid_format(user.uuid) }}</puid>
<CID>{{ cid_format(head.uuid, decimal = True) }}</CID> <CID>{{ cid_format(head.uuid, decimal = True) }}</CID>
<IsNotMobileVisible>false</IsNotMobileVisible> <IsNotMobileVisible>false</IsNotMobileVisible>
@@ -22,10 +22,10 @@
<contactId>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}00000000-0000-0000-0009-{{ circle.chat_id }}{% else %}{{ head.uuid }}{% endif %}</contactId> <contactId>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}00000000-0000-0000-0009-{{ circle.chat_id }}{% else %}{{ head.uuid }}{% endif %}</contactId>
<contactInfo> <contactInfo>
<contactType>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}Circle{% elif circle is not none %}{% if circle.memberships[head.uuid].state == CircleState.WaitingResponse or circle.memberships[head.uuid].state == CircleState.Rejected or (circle.memberships[head.uuid].role == CircleRole.Empty or circle.memberships[head.uuid].state == CircleState.Empty) %}LivePending{% else %}Live{% endif %}{% else %}Live{% endif %}</contactType> <contactType>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}Circle{% elif circle is not none %}{% if circle.memberships[head.uuid].state == CircleState.WaitingResponse or circle.memberships[head.uuid].state == CircleState.Rejected or (circle.memberships[head.uuid].role == CircleRole.Empty or circle.memberships[head.uuid].state == CircleState.Empty) %}LivePending{% else %}Live{% endif %}{% else %}Live{% endif %}</contactType>
<quickName>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}circle{% else %}{{ head.email }}{% endif %}</quickName> <quickName>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}circle{% else %}{{ display_email(head) }}{% endif %}</quickName>
<passportName>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}00000000-0000-0000-0009-{{ circle.chat_id.upper() }}@hotmail.com{% else %}{{ head.email }}{% endif %}</passportName> <passportName>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}00000000-0000-0000-0009-{{ circle.chat_id.upper() }}@hotmail.com{% else %}{{ display_email(head) }}{% endif %}</passportName>
<IsPassportNameHidden>false</IsPassportNameHidden> <IsPassportNameHidden>false</IsPassportNameHidden>
<displayName>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}{{ circle.name }}{% else %}{{ head.email }}{% endif %}</displayName> <displayName>{% if circle is not none and ab_id == '00000000-0000-0000-0000-000000000000' %}{{ circle.name }}{% else %}{{ display_email(head) }}{% endif %}</displayName>
<puid>{{ puid_format(user.uuid) }}</puid> <puid>{{ puid_format(user.uuid) }}</puid>
<CID>{% if circle is not none %}{{ cid_format('00000000-0000-0000-0009-' + circle.chat_id, decimal = True) }}{% else %}{{ cid_format(head.uuid, decimal = True) }}{% endif %}</CID> <CID>{% if circle is not none %}{{ cid_format('00000000-0000-0000-0009-' + circle.chat_id, decimal = True) }}{% else %}{{ cid_format(head.uuid, decimal = True) }}{% endif %}</CID>
<IsNotMobileVisible>false</IsNotMobileVisible> <IsNotMobileVisible>false</IsNotMobileVisible>
@@ -30,7 +30,7 @@
<JoinedDate>{{ date_format(contact.head.date_created) }}</JoinedDate> <JoinedDate>{{ date_format(contact.head.date_created) }}</JoinedDate>
<ExpirationDate>0001-01-01T00:00:00</ExpirationDate> <ExpirationDate>0001-01-01T00:00:00</ExpirationDate>
<Changes /> <Changes />
<PassportName>{{ contact.head.email }}</PassportName> <PassportName>{{ display_email(contact.head) }}</PassportName>
<IsPassportNameHidden>false</IsPassportNameHidden> <IsPassportNameHidden>false</IsPassportNameHidden>
<PassportId>0</PassportId> <PassportId>0</PassportId>
<CID>{{ cid_format(contact.head.uuid, decimal = True) }}</CID> <CID>{{ cid_format(contact.head.uuid, decimal = True) }}</CID>
@@ -74,7 +74,7 @@
<JoinedDate>{{ date_format(contact.head.date_created) }}</JoinedDate> <JoinedDate>{{ date_format(contact.head.date_created) }}</JoinedDate>
<ExpirationDate>0001-01-01T00:00:00</ExpirationDate> <ExpirationDate>0001-01-01T00:00:00</ExpirationDate>
<Changes /> <Changes />
<PassportName>{{ contact.head.email }}</PassportName> <PassportName>{{ display_email(contact.head) }}</PassportName>
<IsPassportNameHidden>false</IsPassportNameHidden> <IsPassportNameHidden>false</IsPassportNameHidden>
<PassportId>0</PassportId> <PassportId>0</PassportId>
<CID>{{ cid_format(contact.head.uuid, decimal = True) }}</CID> <CID>{{ cid_format(contact.head.uuid, decimal = True) }}</CID>
@@ -111,7 +111,7 @@
</Handle> </Handle>
<CreatorPuid>0</CreatorPuid> <CreatorPuid>0</CreatorPuid>
<CreatorCID>{{ cid_format(user.uuid, decimal = True) }}</CreatorCID> <CreatorCID>{{ cid_format(user.uuid, decimal = True) }}</CreatorCID>
<CreatorPassportName>{{ user.email }}</CreatorPassportName> <CreatorPassportName>{{ display_email(user) }}</CreatorPassportName>
<CircleAttributes> <CircleAttributes>
<IsPresenceEnabled>false</IsPresenceEnabled> <IsPresenceEnabled>false</IsPresenceEnabled>
<Domain>WindowsLive</Domain> <Domain>WindowsLive</Domain>
+16 -1
View File
@@ -11,7 +11,11 @@ def render(req: web.Request, tmpl_name: str, ctxt: Optional[Dict[str, Any]] = No
else: else:
content_type = 'text/html' content_type = 'text/html'
tmpl = req.app['jinja_env'].get_template(tmpl_name) tmpl = req.app['jinja_env'].get_template(tmpl_name)
content = tmpl.render(**(ctxt or {})) template_context = dict(ctxt or {})
backend = req.app.get('backend')
if backend is not None:
template_context['display_email'] = display_email
content = tmpl.render(**template_context)
return web.Response(status = status, content_type = content_type, text = content) return web.Response(status = status, content_type = content_type, text = content)
async def preprocess_soap(req: web.Request) -> Tuple[Any, Any, Optional[BackendSession], str]: async def preprocess_soap(req: web.Request) -> Tuple[Any, Any, Optional[BackendSession], str]:
@@ -151,6 +155,17 @@ def parse_cookies(cookie_string: Optional[str]) -> Dict[str, Any]:
return cookie_dict return cookie_dict
def display_email(user: Any, fallback: Optional[str] = None) -> str:
if isinstance(user, str):
user = backend.user_service.get(user)
if user is None and fallback:
uuid = backend.user_service.get_uuid(fallback)
if uuid is not None:
user = backend.user_service.get(uuid)
if user is None:
return fallback or ''
return backend.util_get_display_email(user)
async def dispatch_abch(req: web.Request, module: Any, prefix: str) -> web.Response: async def dispatch_abch(req: web.Request, module: Any, prefix: str) -> web.Response:
header, action, bs, _ = await preprocess_soap(req) header, action, bs, _ = await preprocess_soap(req)
if bs is None: if bs is None:
-6
View File
@@ -282,7 +282,6 @@ class MSNPCtrlNS(MSNPCtrl):
if uuid is not None: if uuid is not None:
self.bs = backend.login(uuid, self.client, BackendEventHandler(self.backend.loop, self), option = LoginOption.BootOthers) self.bs = backend.login(uuid, self.client, BackendEventHandler(self.backend.loop, self), option = LoginOption.BootOthers)
token, _ = backend.login_auth_service.create_token('ns/login', [uuid, None], lifetime = 86400) token, _ = backend.login_auth_service.create_token('ns/login', [uuid, None], lifetime = 86400)
print(f"usr_email during MD5 stage S: {usr_email}")
self._auth_final_step(trid, usr_email, token or '', None) self._auth_final_step(trid, usr_email, token or '', None)
return return
@@ -460,7 +459,6 @@ class MSNPCtrlNS(MSNPCtrl):
bs = self.bs bs = self.bs
dialect = self.dialect dialect = self.dialect
print(f"bs: {bs}")
if bs is None: if bs is None:
self.send_reply(Err.AuthFail, trid) self.send_reply(Err.AuthFail, trid)
self.close() self.close()
@@ -471,9 +469,6 @@ class MSNPCtrlNS(MSNPCtrl):
usr_email_lower = (self.usr_email or '').lower() usr_email_lower = (self.usr_email or '').lower()
alias_email = '{}@crosstalk.im'.format(user.username).lower() alias_email = '{}@crosstalk.im'.format(user.username).lower()
print(f"email: {email}")
print(f"attempted email: {attempted_email}")
print(f"self.usr_email: {self.usr_email}")
if usr_email_lower not in (user.email.lower(), alias_email, email.lower()): if usr_email_lower not in (user.email.lower(), alias_email, email.lower()):
self.send_reply(Err.AuthFail, trid) self.send_reply(Err.AuthFail, trid)
self.close() self.close()
@@ -530,7 +525,6 @@ class MSNPCtrlNS(MSNPCtrl):
# self.close() # self.close()
# return # return
else: else:
print(f"args: {args}")
self.send_reply('USR', trid, 'OK', email, *args) self.send_reply('USR', trid, 'OK', email, *args)
(high, low) = uuid_to_high_low(user.uuid) (high, low) = uuid_to_high_low(user.uuid)
+12 -12
View File
@@ -159,7 +159,7 @@ class OSCARCtrl:
entry = take_cookie(cookie_tlv.data) entry = take_cookie(cookie_tlv.data)
if entry is not None and (entry.bs is None or not entry.bs.closed): if entry is not None and (entry.bs is None or not entry.bs.closed):
self.logger.info('found BOS cookie') self.logger.debug('found BOS cookie')
self.multi_conn = entry.multi_conn self.multi_conn = entry.multi_conn
if entry.bs is not None: if entry.bs is not None:
@@ -191,7 +191,7 @@ class OSCARCtrl:
if found: if found:
# NINA also sends OSERVICE__WELL_KNOWN_URLS right after (should we?) # NINA also sends OSERVICE__WELL_KNOWN_URLS right after (should we?)
self.logger.info('[Server] OSERVICE__HOST_ONLINE') self.logger.debug('[Server] OSERVICE__HOST_ONLINE')
msg = SNACMessage(0x0001, 0x0003) msg = SNACMessage(0x0001, 0x0003)
@@ -210,11 +210,11 @@ class OSCARCtrl:
self.bs.front_data['oscar0_icq'] = entry.icq self.bs.front_data['oscar0_icq'] = entry.icq
self.bs.front_data['oscar0_client_id'] = entry.client_id self.bs.front_data['oscar0_client_id'] = entry.client_id
else: else:
self.logger.info('invalid BOS cookie given') self.logger.debug('invalid BOS cookie given')
self.close() self.close()
elif find_tlv(tlvs, 0x0001) is not None: elif find_tlv(tlvs, 0x0001) is not None:
self.logger.info('Using FLAP-level authentication') self.logger.debug('Using FLAP-level authentication')
screen_name_tlv = find_tlv(tlvs, 0x0001) screen_name_tlv = find_tlv(tlvs, 0x0001)
roasted_pw_tlv = find_tlv(tlvs, 0x0002) roasted_pw_tlv = find_tlv(tlvs, 0x0002)
@@ -222,8 +222,8 @@ class OSCARCtrl:
screen_name = screen_name_tlv.data.decode('latin-1') screen_name = screen_name_tlv.data.decode('latin-1')
roasted_pw = roasted_pw_tlv.data if roasted_pw_tlv is not None else b'' roasted_pw = roasted_pw_tlv.data if roasted_pw_tlv is not None else b''
self.logger.info('Screen Name (client-given):', screen_name) self.logger.debug('Screen Name (client-given):', screen_name)
self.logger.info('Password (roasted):', roasted_pw.hex()) self.logger.debug('Password (roasted):', roasted_pw.hex())
context = self.context context = self.context
version = client_version(tlvs) version = client_version(tlvs)
@@ -233,9 +233,9 @@ class OSCARCtrl:
context.backend, screen_name, lambda uuid: context.backend.user_service.login_with_uuid(uuid, password) is not None, context.backend, screen_name, lambda uuid: context.backend.user_service.login_with_uuid(uuid, password) is not None,
) )
if error_code in (LoginError.UnregisteredScreenname, LoginError.ICQUserError): if error_code in (LoginError.UnregisteredScreenname, LoginError.ICQUserError):
self.logger.info('Unregistered screenname') self.logger.debug('Unregistered screenname')
elif error_code == LoginError.IncorrectPassword: elif error_code == LoginError.IncorrectPassword:
self.logger.info('Incorrect password') self.logger.debug('Incorrect password')
self.client = Client('icq' if icq else 'aim', version, self.client.via) self.client = Client('icq' if icq else 'aim', version, self.client.via)
context.client = self.client context.client = self.client
@@ -266,17 +266,17 @@ class OSCARCtrl:
self.logger.error(ex) self.logger.error(ex)
if not found: if not found:
self.logger.info(f'[Client] Unknown SNAC({hex(message.foodgroup)},{hex(message.subgroup)})') self.logger.debug(f'[Client] Unknown SNAC({hex(message.foodgroup)},{hex(message.subgroup)})')
self.logger.info('[Client]', message.data.hex()) self.logger.debug('[Client]', message.data.hex())
# an unanswered request leaves the client waiting on it, so it gets told the SNAC isn't one we know # an unanswered request leaves the client waiting on it, so it gets told the SNAC isn't one we know
if message.subgroup != 0x0001: if message.subgroup != 0x0001:
self.send_snac_error(message.foodgroup, message.request_id, 0x0001) self.send_snac_error(message.foodgroup, message.request_id, 0x0001)
def on_error_frame(self, data: bytes) -> None: def on_error_frame(self, data: bytes) -> None:
self.logger.info('[Client] Recieved error frame with:', data.hex()) self.logger.debug('[Client] Recieved error frame with:', data.hex())
def on_signoff_frame(self, data: bytes) -> None: def on_signoff_frame(self, data: bytes) -> None:
self.logger.info('[Client] Recieved signoff frame') self.logger.debug('[Client] Recieved signoff frame')
self.close() self.close()
def close(self) -> None: def close(self) -> None:
+3 -3
View File
@@ -70,7 +70,7 @@ class ListenerOSCAR(asyncio.Protocol):
if self.buffer[0] != 0x2A: if self.buffer[0] != 0x2A:
# without the marker there's no telling where the next frame starts, so the stream can't be recovered # without the marker there's no telling where the next frame starts, so the stream can't be recovered
self.logger.info('Recieved data without a FLAP start marker, closing connection') self.logger.debug('Recieved data without a FLAP start marker, closing connection')
self.buffer = b'' self.buffer = b''
self.controller.close() self.controller.close()
break break
@@ -103,7 +103,7 @@ class ListenerOSCAR(asyncio.Protocol):
# DATA (always contains a SNAC) # DATA (always contains a SNAC)
case 0x02: case 0x02:
if len(data) < 10: if len(data) < 10:
self.logger.info('Recieved a DATA frame too short to hold a SNAC:', data.hex()) self.logger.debug('Recieved a DATA frame too short to hold a SNAC:', data.hex())
return return
msg = SNACMessage() msg = SNACMessage()
@@ -123,7 +123,7 @@ class ListenerOSCAR(asyncio.Protocol):
pass pass
case _: case _:
self.logger.info('Recieved unknown frame:', str(frame), 'with data:', data.hex()) self.logger.debug('Recieved unknown frame:', str(frame), 'with data:', data.hex())
def _on_close(self) -> None: def _on_close(self) -> None:
if self.transport is not None: if self.transport is not None:
+3 -3
View File
@@ -49,7 +49,7 @@ class AdminFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def info_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def info_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] ADMIN__INFO_QUERY') self.logger.debug('[Client] ADMIN__INFO_QUERY')
user = context.user user = context.user
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
@@ -65,7 +65,7 @@ class AdminFoodgroup:
@Subgroup(0x0004) @Subgroup(0x0004)
def info_change_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def info_change_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] ADMIN__INFO_CHANGE_REQUEST') self.logger.debug('[Client] ADMIN__INFO_CHANGE_REQUEST')
user = context.user user = context.user
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
@@ -99,7 +99,7 @@ class AdminFoodgroup:
@Subgroup(0x0006) @Subgroup(0x0006)
def account_confirm_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def account_confirm_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] ADMIN__ACCT_CONFIRM_REQUEST') self.logger.debug('[Client] ADMIN__ACCT_CONFIRM_REQUEST')
# ADMIN__ACCT_CONFIRM_REPLY: u16 status, then a TLV (empty here); confirmation mails come from the website # ADMIN__ACCT_CONFIRM_REPLY: u16 status, then a TLV (empty here); confirmation mails come from the website
status = CONFIRM_ALREADY_CONFIRMED if getattr(context.user, 'account_verified', False) else CONFIRM_SERVER_ERROR status = CONFIRM_ALREADY_CONFIRMED if getattr(context.user, 'account_verified', False) else CONFIRM_SERVER_ERROR
+3 -3
View File
@@ -33,7 +33,7 @@ class BARTFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def upload_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def upload_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# BART__UPLOAD_QUERY: u16 type, u16 length, the item # BART__UPLOAD_QUERY: u16 type, u16 length, the item
self.logger.info('[Client] BART__UPLOAD_QUERY') self.logger.debug('[Client] BART__UPLOAD_QUERY')
bart_type = message.read_u16() bart_type = message.read_u16()
data = message.read_bytes(message.read_u16()) data = message.read_bytes(message.read_u16())
client.ctrl.backend.loop.create_task(_upload(client, context, message.request_id, bart_type, data)) client.ctrl.backend.loop.create_task(_upload(client, context, message.request_id, bart_type, data))
@@ -41,7 +41,7 @@ class BARTFoodgroup:
@Subgroup(0x0004) @Subgroup(0x0004)
def download_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def download_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# BART__DOWNLOAD_QUERY: string08 whose, u8 command, then the BART ID # BART__DOWNLOAD_QUERY: string08 whose, u8 command, then the BART ID
self.logger.info('[Client] BART__DOWNLOAD_QUERY') self.logger.debug('[Client] BART__DOWNLOAD_QUERY')
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
message.read_u8() message.read_u8()
ids = _read_bart_ids(message.data, 1) ids = _read_bart_ids(message.data, 1)
@@ -52,7 +52,7 @@ class BARTFoodgroup:
@Subgroup(0x0006) @Subgroup(0x0006)
def download2_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def download2_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# BART__DOWNLOAD2_QUERY: string08 whose, u8 count, then that many BART IDs # BART__DOWNLOAD2_QUERY: string08 whose, u8 count, then that many BART IDs
self.logger.info('[Client] BART__DOWNLOAD2_QUERY') self.logger.debug('[Client] BART__DOWNLOAD2_QUERY')
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
count = message.read_u8() count = message.read_u8()
ids = _read_bart_ids(message.data, count) ids = _read_bart_ids(message.data, count)
+2 -2
View File
@@ -15,7 +15,7 @@ class BOSFoodgroup(PDHandlers):
@Subgroup(0x0002) @Subgroup(0x0002)
def rights_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def rights_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] BOS__RIGHTS_QUERY') self.logger.debug('[Client] BOS__RIGHTS_QUERY')
response_msg = SNACMessage(0x0009, 0x0003, 0x0000, message.request_id) response_msg = SNACMessage(0x0009, 0x0003, 0x0000, message.request_id)
response_msg.write_tlvs([ response_msg.write_tlvs([
@@ -24,5 +24,5 @@ class BOSFoodgroup(PDHandlers):
TLV(0x0003, struct.pack('>H', 1000)) # max temp permits user is allowed TLV(0x0003, struct.pack('>H', 1000)) # max temp permits user is allowed
]) ])
self.logger.info('[Server] BOS__RIGHTS_REPLY') self.logger.debug('[Server] BOS__RIGHTS_REPLY')
client.send_snac(response_msg) client.send_snac(response_msg)
+9 -9
View File
@@ -17,7 +17,7 @@ class BUCPFoodgroup:
@Subgroup(0x0006) @Subgroup(0x0006)
def challenge_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def challenge_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] BUCP__CHALLENGE_REQUEST') self.logger.debug('[Client] BUCP__CHALLENGE_REQUEST')
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
screen_name_tlv = find_tlv(tlvs, 0x0001) screen_name_tlv = find_tlv(tlvs, 0x0001)
@@ -38,12 +38,12 @@ class BUCPFoodgroup:
response_msg.write_u16(len(salt)) response_msg.write_u16(len(salt))
response_msg.write_string(salt) response_msg.write_string(salt)
self.logger.info('[Server] BUCP__CHALLENGE_RESPONSE (salt:', salt + ')') self.logger.debug('[Server] BUCP__CHALLENGE_RESPONSE (salt:', salt + ')')
client.send_snac(response_msg) client.send_snac(response_msg)
@Subgroup(0x0002) @Subgroup(0x0002)
def login_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def login_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] BUCP__LOGIN_REQUEST') self.logger.debug('[Client] BUCP__LOGIN_REQUEST')
from ..ctrl import authenticate, client_version, multi_conn_flag from ..ctrl import authenticate, client_version, multi_conn_flag
@@ -57,9 +57,9 @@ class BUCPFoodgroup:
version_str = client_version(tlvs) version_str = client_version(tlvs)
self.logger.info('Screen Name (client-given):', screen_name) self.logger.debug('Screen Name (client-given):', screen_name)
self.logger.info('Client version:', version_str) self.logger.debug('Client version:', version_str)
self.logger.info('Password (hashed):', client_hash) self.logger.debug('Password (hashed):', client_hash)
response_msg = SNACMessage(0x0017, 0x0003, 0x0000, message.request_id) response_msg = SNACMessage(0x0017, 0x0003, 0x0000, message.request_id)
@@ -79,11 +79,11 @@ class BUCPFoodgroup:
uuid, icq, error_code = authenticate(context.backend, screen_name, check) uuid, icq, error_code = authenticate(context.backend, screen_name, check)
if error_code in (LoginError.UnregisteredScreenname, LoginError.ICQUserError): if error_code in (LoginError.UnregisteredScreenname, LoginError.ICQUserError):
self.logger.info('Unregistered screenname') self.logger.debug('Unregistered screenname')
elif error_code == LoginError.IncorrectPassword: elif error_code == LoginError.IncorrectPassword:
self.logger.info('Incorrect password') self.logger.debug('Incorrect password')
else: else:
self.logger.info('Authenticated via', matched.get(uuid)) self.logger.debug('Authenticated via', matched.get(uuid))
context.client = Client('icq' if icq else 'aim', version_str, context.client.via) context.client = Client('icq' if icq else 'aim', version_str, context.client.via)
client.ctrl.client = context.client client.ctrl.client = context.client
+6 -6
View File
@@ -205,7 +205,7 @@ class BuddyFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def rights_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def rights_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] BUDDY_RIGHTS_QUERY') self.logger.debug('[Client] BUDDY_RIGHTS_QUERY')
response_msg = SNACMessage(0x0003, 0x0003, 0x0000, message.request_id) response_msg = SNACMessage(0x0003, 0x0003, 0x0000, message.request_id)
response_msg.write_tlvs([ response_msg.write_tlvs([
@@ -215,26 +215,26 @@ class BuddyFoodgroup:
TLV(0x0004, struct.pack('>H', 160)) # max temp buddies TLV(0x0004, struct.pack('>H', 160)) # max temp buddies
]) ])
self.logger.info('[Server] BUDDY_RIGHTS_REPLY') self.logger.debug('[Server] BUDDY_RIGHTS_REPLY')
client.send_snac(response_msg) client.send_snac(response_msg)
@Subgroup(0x0004) @Subgroup(0x0004)
def add_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def add_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] BUDDY__ADD_BUDDIES') self.logger.debug('[Client] BUDDY__ADD_BUDDIES')
add_buddies(client, context, message) add_buddies(client, context, message)
@Subgroup(0x0005) @Subgroup(0x0005)
def del_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def del_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] BUDDY__DEL_BUDDIES') self.logger.debug('[Client] BUDDY__DEL_BUDDIES')
del_buddies(client, context, message) del_buddies(client, context, message)
@Subgroup(0x000F) @Subgroup(0x000F)
def add_temp_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def add_temp_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# temp buddies only ever last the session, which is all a client-side buddy is here anyway # temp buddies only ever last the session, which is all a client-side buddy is here anyway
self.logger.info('[Client] BUDDY__ADD_TEMP_BUDDIES') self.logger.debug('[Client] BUDDY__ADD_TEMP_BUDDIES')
add_buddies(client, context, message) add_buddies(client, context, message)
@Subgroup(0x0010) @Subgroup(0x0010)
def del_temp_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def del_temp_buddies(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] BUDDY__DEL_TEMP_BUDDIES') self.logger.debug('[Client] BUDDY__DEL_TEMP_BUDDIES')
del_buddies(client, context, message) del_buddies(client, context, message)
+1 -1
View File
@@ -160,7 +160,7 @@ class ChatFoodgroup:
@Subgroup(0x0005) @Subgroup(0x0005)
def channel_msg_tohost(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def channel_msg_tohost(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] CHAT__CHANNEL_MSG_TOHOST') self.logger.debug('[Client] CHAT__CHANNEL_MSG_TOHOST')
ctrl = client.ctrl ctrl = client.ctrl
info = ctrl.room info = ctrl.room
+4 -4
View File
@@ -49,7 +49,7 @@ class ChatNavFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def request_chat_rights(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def request_chat_rights(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] CHAT_NAV__REQUEST_CHAT_RIGHTS') self.logger.debug('[Client] CHAT_NAV__REQUEST_CHAT_RIGHTS')
client.send_snac(nav_info(message.request_id, [ client.send_snac(nav_info(message.request_id, [
TLV(NAV_TLV_MAX_CONCURRENT_ROOMS, struct.pack('>B', MAX_CONCURRENT_ROOMS)), TLV(NAV_TLV_MAX_CONCURRENT_ROOMS, struct.pack('>B', MAX_CONCURRENT_ROOMS)),
TLV(NAV_TLV_EXCHANGE_INFO, exchange_info(EXCHANGE_PRIVATE)), TLV(NAV_TLV_EXCHANGE_INFO, exchange_info(EXCHANGE_PRIVATE)),
@@ -58,7 +58,7 @@ class ChatNavFoodgroup:
@Subgroup(0x0003) @Subgroup(0x0003)
def request_exchange_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def request_exchange_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] CHAT_NAV__REQUEST_EXCHANGE_INFO') self.logger.debug('[Client] CHAT_NAV__REQUEST_EXCHANGE_INFO')
exchange = message.read_u16() exchange = message.read_u16()
if exchange not in (EXCHANGE_PRIVATE, EXCHANGE_PUBLIC): if exchange not in (EXCHANGE_PRIVATE, EXCHANGE_PUBLIC):
client.ctrl.send_snac_error(0x000D, message.request_id, NAV_ERROR_NOT_SUPPORTED) client.ctrl.send_snac_error(0x000D, message.request_id, NAV_ERROR_NOT_SUPPORTED)
@@ -71,7 +71,7 @@ class ChatNavFoodgroup:
@Subgroup(0x0004) @Subgroup(0x0004)
def request_room_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def request_room_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# u16 exchange, string08 cookie, u16 instance, u8 detail level # u16 exchange, string08 cookie, u16 instance, u8 detail level
self.logger.info('[Client] CHAT_NAV__REQUEST_ROOM_INFO') self.logger.debug('[Client] CHAT_NAV__REQUEST_ROOM_INFO')
info = parse_room_info(message.data) info = parse_room_info(message.data)
room = find_room(info['cookie']) if info is not None else None room = find_room(info['cookie']) if info is not None else None
if room is None or room.exchange != info['exchange']: if room is None or room.exchange != info['exchange']:
@@ -82,7 +82,7 @@ class ChatNavFoodgroup:
@Subgroup(0x0008) @Subgroup(0x0008)
def create_room(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def create_room(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# a CHAT__ROOM_INFO_UPDATE layout: u16 exchange, string08 cookie ("create"), u16 instance, u8 detail, TLV block # a CHAT__ROOM_INFO_UPDATE layout: u16 exchange, string08 cookie ("create"), u16 instance, u8 detail, TLV block
self.logger.info('[Client] CHAT_NAV__CREATE_ROOM') self.logger.debug('[Client] CHAT_NAV__CREATE_ROOM')
buf = Buffer(message.data) buf = Buffer(message.data)
try: try:
exchange = buf.read_u16() exchange = buf.read_u16()
+5 -5
View File
@@ -27,7 +27,7 @@ class DirectoryFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def info_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def info_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] DIRECTORY__INFO_QUERY') self.logger.debug('[Client] DIRECTORY__INFO_QUERY')
# the search kind follows from the TLVs: # the search kind follows from the TLVs:
# an e-mail address, an interest keyword, or a first or last name # an e-mail address, an interest keyword, or a first or last name
@@ -52,7 +52,7 @@ class DirectoryFoodgroup:
# ODIR__INFO_REPLY: u16 status, u16 unknown, and with this status nothing else # ODIR__INFO_REPLY: u16 status, u16 unknown, and with this status nothing else
reply.write_u16(SEARCH_NAME_MISSING) reply.write_u16(SEARCH_NAME_MISSING)
reply.write_u16(0) reply.write_u16(0)
self.logger.info('[Server] DIRECTORY__INFO_REPLY') self.logger.debug('[Server] DIRECTORY__INFO_REPLY')
client.send_snac(reply) client.send_snac(reply)
return return
@@ -78,17 +78,17 @@ class DirectoryFoodgroup:
reply.write_u16(len(results)) reply.write_u16(len(results))
for result in results: for result in results:
reply.write_tlv_block(result) reply.write_tlv_block(result)
self.logger.info('[Server] DIRECTORY__INFO_REPLY') self.logger.debug('[Server] DIRECTORY__INFO_REPLY')
client.send_snac(reply) client.send_snac(reply)
@Subgroup(0x0004) @Subgroup(0x0004)
def interests_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def interests_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] DIRECTORY__INTERESTS_QUERY') self.logger.debug('[Client] DIRECTORY__INTERESTS_QUERY')
# we don't yet have an interests directory, so the count stays zero. # we don't yet have an interests directory, so the count stays zero.
response_msg = SNACMessage(0x000F, 0x0005, 0x0000, message.request_id) response_msg = SNACMessage(0x000F, 0x0005, 0x0000, message.request_id)
response_msg.write_u16(1) response_msg.write_u16(1)
response_msg.write_u16(0) response_msg.write_u16(0)
self.logger.info('[Server] DIRECTORY__INTERESTS_LIST') self.logger.debug('[Server] DIRECTORY__INTERESTS_LIST')
client.send_snac(response_msg) client.send_snac(response_msg)
+3 -3
View File
@@ -8,12 +8,12 @@ class EmailFoodgroup:
@Subgroup(0x0006) @Subgroup(0x0006)
def status_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def status_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] EMAIL__STATUS_REQUEST') self.logger.debug('[Client] EMAIL__STATUS_REQUEST')
# unread count. no mail yet, so it stays zero # unread count. no mail yet, so it stays zero
# 0x06 is ALERT__NOTIFY_CAPABILITIES, which takes no reply; answering it with an # 0x06 is ALERT__NOTIFY_CAPABILITIES, which takes no reply; answering it with an
# ALERT__NOTIFY nobody asked for is what used to go back here # ALERT__NOTIFY nobody asked for is what used to go back here
self.logger.info('[Client] Alert capabilities:', message.data.hex()) self.logger.debug('[Client] Alert capabilities:', message.data.hex())
@Subgroup(0x0016) @Subgroup(0x0016)
def activate(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def activate(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] EMAIL__ACTIVATE (no reply expected)') self.logger.debug('[Client] EMAIL__ACTIVATE (no reply expected)')
+36 -36
View File
@@ -581,7 +581,7 @@ def _insert_group(logger: Logger, context: OSCARContext, item: FeedbagItem) -> F
return FeedbagStatus.BadRequest return FeedbagStatus.BadRequest
bs.front_data.setdefault("oscar0_group_id_map", {})[item.group_id] = group.id bs.front_data.setdefault("oscar0_group_id_map", {})[item.group_id] = group.id
logger.info("[Client] Added group:", item.name) logger.debug("[Client] Added group:", item.name)
attrs = [tlv for tlv in item.attributes if tlv.type != FeedbagAttributes.Order] attrs = [tlv for tlv in item.attributes if tlv.type != FeedbagAttributes.Order]
if attrs: if attrs:
@@ -607,7 +607,7 @@ def _insert_buddy(logger: Logger, context: OSCARContext, item: FeedbagItem) -> F
return FeedbagStatus.BadLoginID return FeedbagStatus.BadLoginID
contact_user = names.resolve_user(context.backend, item.name) contact_user = names.resolve_user(context.backend, item.name)
if contact_user is None or contact_user is context.user: if contact_user is None or contact_user is context.user:
logger.info("[Client] Unknown buddy:", item.name) logger.debug("[Client] Unknown buddy:", item.name)
return FeedbagStatus.BadLoginID return FeedbagStatus.BadLoginID
contact_uuid = contact_user.uuid contact_uuid = contact_user.uuid
key = contact_user.username.lower() key = contact_user.username.lower()
@@ -663,14 +663,14 @@ def _insert_buddy(logger: Logger, context: OSCARContext, item: FeedbagItem) -> F
# whatever this client called the buddy (a UIN, a differently spaced screen name) is what it'll hear about them as # whatever this client called the buddy (a UIN, a differently spaced screen name) is what it'll hear about them as
names.remember(bs, contact_user, item.name) names.remember(bs, contact_user, item.name)
names.store_alias(bs, contact_user, item.name) names.store_alias(bs, contact_user, item.name)
logger.info("[Client] Added buddy:", item.name) logger.debug("[Client] Added buddy:", item.name)
return FeedbagStatus.Success return FeedbagStatus.Success
def _insert_list_entry(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus: def _insert_list_entry(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus:
is_permit = (item.class_id == FeedbagClass.Permit) is_permit = (item.class_id == FeedbagClass.Permit)
status = FeedbagStatus(int(pd_add(context, item.name, permit = is_permit))) status = FeedbagStatus(int(pd_add(context, item.name, permit = is_permit)))
if status == FeedbagStatus.Success: if status == FeedbagStatus.Success:
logger.info("[Client] Added {} entry:".format('permit' if is_permit else 'deny'), item.name) logger.debug("[Client] Added {} entry:".format('permit' if is_permit else 'deny'), item.name)
return status return status
def _insert_generic(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus: def _insert_generic(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus:
@@ -695,7 +695,7 @@ def _insert_generic(logger: Logger, context: OSCARContext, item: FeedbagItem) ->
if item.class_id == FeedbagClass.PdInfo: if item.class_id == FeedbagClass.PdInfo:
_apply_pd_mode(context, attrs) _apply_pd_mode(context, attrs)
logger.info("[Client] Stored item of class", hex(item.class_id)) logger.debug("[Client] Stored item of class", hex(item.class_id))
return FeedbagStatus.Success return FeedbagStatus.Success
@@ -725,7 +725,7 @@ def _update_group(logger: Logger, context: OSCARContext, item: FeedbagItem) -> F
except Exception: except Exception:
return FeedbagStatus.BadRequest return FeedbagStatus.BadRequest
_rename_group_keys(store, old_key, item.name.lower()) _rename_group_keys(store, old_key, item.name.lower())
logger.info("[Client] Renamed group to:", item.name) logger.debug("[Client] Renamed group to:", item.name)
attrs = [tlv for tlv in item.attributes if tlv.type != FeedbagAttributes.Order] attrs = [tlv for tlv in item.attributes if tlv.type != FeedbagAttributes.Order]
gattrs = store.setdefault('gattrs', {}) gattrs = store.setdefault('gattrs', {})
@@ -771,7 +771,7 @@ def _update_buddy(logger: Logger, context: OSCARContext, item: FeedbagItem) -> F
battrs[key] = _attrs_to_json(list(item.attributes)) battrs[key] = _attrs_to_json(list(item.attributes))
else: else:
battrs.pop(key, None) battrs.pop(key, None)
logger.info("[Client] Updated buddy:", item.name) logger.debug("[Client] Updated buddy:", item.name)
return FeedbagStatus.Success return FeedbagStatus.Success
def _update_list_entry(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus: def _update_list_entry(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus:
@@ -833,7 +833,7 @@ def _delete_group(logger: Logger, context: OSCARContext, item: FeedbagItem) -> F
for k in [k for k, v in mapping.items() if v == group.id]: for k in [k for k, v in mapping.items() if v == group.id]:
del mapping[k] del mapping[k]
_drop_group_keys(store, group.name.lower()) _drop_group_keys(store, group.name.lower())
logger.info("[Client] Removed group:", item.name) logger.debug("[Client] Removed group:", item.name)
return FeedbagStatus.Success return FeedbagStatus.Success
def _delete_buddy(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus: def _delete_buddy(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus:
@@ -872,14 +872,14 @@ def _delete_buddy(logger: Logger, context: OSCARContext, item: FeedbagItem) -> F
except Exception: except Exception:
return FeedbagStatus.BadRequest return FeedbagStatus.BadRequest
logger.info("[Client] Removed buddy:", item.name) logger.debug("[Client] Removed buddy:", item.name)
return FeedbagStatus.Success return FeedbagStatus.Success
def _delete_list_entry(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus: def _delete_list_entry(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus:
is_permit = (item.class_id == FeedbagClass.Permit) is_permit = (item.class_id == FeedbagClass.Permit)
status = FeedbagStatus(int(pd_remove(context, item.name, permit = is_permit))) status = FeedbagStatus(int(pd_remove(context, item.name, permit = is_permit)))
if status == FeedbagStatus.Success: if status == FeedbagStatus.Success:
logger.info("[Client] Removed {} entry:".format('permit' if is_permit else 'deny'), item.name) logger.debug("[Client] Removed {} entry:".format('permit' if is_permit else 'deny'), item.name)
return status return status
def _delete_generic(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus: def _delete_generic(logger: Logger, context: OSCARContext, item: FeedbagItem) -> FeedbagStatus:
@@ -897,7 +897,7 @@ class FeedbagFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def rights_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def rights_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__RIGHTS_QUERY") self.logger.debug("[Client] FEEDBAG__RIGHTS_QUERY")
response_msg = SNACMessage(0x0013, 0x0003) response_msg = SNACMessage(0x0013, 0x0003)
@@ -948,28 +948,28 @@ class FeedbagFoodgroup:
TLV(0x000E, struct.pack(">H", 32)) # max smart groups TLV(0x000E, struct.pack(">H", 32)) # max smart groups
]) ])
self.logger.info("[Server] FEEDBAG__RIGHTS_REPLY") self.logger.debug("[Server] FEEDBAG__RIGHTS_REPLY")
client.send_snac(response_msg) client.send_snac(response_msg)
@Subgroup(0x0004) @Subgroup(0x0004)
def query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__QUERY") self.logger.debug("[Client] FEEDBAG__QUERY")
try: try:
items = get_items(context) items = get_items(context)
last_update = _sync_modified(context, items) last_update = _sync_modified(context, items)
except Exception as ex: except Exception as ex:
self.logger.error(ex) self.logger.error(ex)
self.logger.info("[Server] FEEDBAG__ERR") self.logger.debug("[Server] FEEDBAG__ERR")
send_feedbag_error(client, message.request_id, FeedbagError.BuddyListUnavailable) send_feedbag_error(client, message.request_id, FeedbagError.BuddyListUnavailable)
return return
self.logger.info("[Server] FEEDBAG__REPLY") self.logger.debug("[Server] FEEDBAG__REPLY")
_send_feedbag_reply(client, message.request_id, items, last_update) _send_feedbag_reply(client, message.request_id, items, last_update)
@Subgroup(0x0005) @Subgroup(0x0005)
def query_if_modified(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def query_if_modified(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__QUERY_IF_MODIFIED") self.logger.debug("[Client] FEEDBAG__QUERY_IF_MODIFIED")
# 66 51 29 47 00 0D # 66 51 29 47 00 0D
# #
@@ -978,15 +978,15 @@ class FeedbagFoodgroup:
cached_feedbag_timestamp = message.read_u32() cached_feedbag_timestamp = message.read_u32()
cached_feedbag_num_items = message.read_u16() cached_feedbag_num_items = message.read_u16()
self.logger.info("[Client] Cached feedbag timestamp:", cached_feedbag_timestamp) self.logger.debug("[Client] Cached feedbag timestamp:", cached_feedbag_timestamp)
self.logger.info("[Client] Cached feedbag items num:", cached_feedbag_num_items) self.logger.debug("[Client] Cached feedbag items num:", cached_feedbag_num_items)
try: try:
current_items = get_items(context) current_items = get_items(context)
last_update = _sync_modified(context, current_items) last_update = _sync_modified(context, current_items)
except Exception as ex: except Exception as ex:
self.logger.error(ex) self.logger.error(ex)
self.logger.info("[Server] FEEDBAG__ERR") self.logger.debug("[Server] FEEDBAG__ERR")
send_feedbag_error(client, message.request_id, FeedbagError.BuddyListUnavailable) send_feedbag_error(client, message.request_id, FeedbagError.BuddyListUnavailable)
return return
@@ -996,15 +996,15 @@ class FeedbagFoodgroup:
response_msg.write_u32(last_update) response_msg.write_u32(last_update)
response_msg.write_u16(len(current_items)) response_msg.write_u16(len(current_items))
self.logger.info("[Server] FEEDBAG__REPLY_NOT_MODIFIED") self.logger.debug("[Server] FEEDBAG__REPLY_NOT_MODIFIED")
client.send_snac(response_msg) client.send_snac(response_msg)
else: else:
self.logger.info("[Server] FEEDBAG__REPLY") self.logger.debug("[Server] FEEDBAG__REPLY")
_send_feedbag_reply(client, message.request_id, current_items, last_update) _send_feedbag_reply(client, message.request_id, current_items, last_update)
@Subgroup(0x0007) @Subgroup(0x0007)
def use(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def use(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__USE") self.logger.debug("[Client] FEEDBAG__USE")
bs = context.bs bs = context.bs
# from here on the stored buddy list is the one this client runs on # from here on the stored buddy list is the one this client runs on
@@ -1023,15 +1023,15 @@ class FeedbagFoodgroup:
# stubs because I cba to implement more of feedbag rn # stubs because I cba to implement more of feedbag rn
@Subgroup(0x0011) @Subgroup(0x0011)
def start_cluster(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def start_cluster(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__START_CLUSTER (not implemented)") self.logger.debug("[Client] FEEDBAG__START_CLUSTER (not implemented)")
@Subgroup(0x0012) @Subgroup(0x0012)
def end_cluster(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def end_cluster(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__END_CLUSTER (not implemented)") self.logger.debug("[Client] FEEDBAG__END_CLUSTER (not implemented)")
@Subgroup(0x0008) @Subgroup(0x0008)
def insert_item(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def insert_item(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__INSERT_ITEM") self.logger.debug("[Client] FEEDBAG__INSERT_ITEM")
bs = context.bs bs = context.bs
before = bs.me_visibility_snapshot() before = bs.me_visibility_snapshot()
@@ -1061,7 +1061,7 @@ class FeedbagFoodgroup:
context.backend._mark_modified(context.user) context.backend._mark_modified(context.user)
bs.me_visibility_changed(before) bs.me_visibility_changed(before)
self.logger.info("[Server] FEEDBAG__STATUS") self.logger.debug("[Server] FEEDBAG__STATUS")
_send_feedbag_status(client, message.request_id, statuses) _send_feedbag_status(client, message.request_id, statuses)
# the buddy has to be in the client's list before its arrival means anything, so this goes after the STATUS # the buddy has to be in the client's list before its arrival means anything, so this goes after the STATUS
@@ -1072,7 +1072,7 @@ class FeedbagFoodgroup:
@Subgroup(0x0009) @Subgroup(0x0009)
def update_item(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def update_item(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__UPDATE_ITEM") self.logger.debug("[Client] FEEDBAG__UPDATE_ITEM")
bs = context.bs bs = context.bs
before = bs.me_visibility_snapshot() before = bs.me_visibility_snapshot()
@@ -1099,7 +1099,7 @@ class FeedbagFoodgroup:
context.backend._mark_modified(context.user) context.backend._mark_modified(context.user)
bs.me_visibility_changed(before) bs.me_visibility_changed(before)
self.logger.info("[Server] FEEDBAG__STATUS") self.logger.debug("[Server] FEEDBAG__STATUS")
_send_feedbag_status(client, message.request_id, statuses) _send_feedbag_status(client, message.request_id, statuses)
for item in bart_items: for item in bart_items:
@@ -1107,7 +1107,7 @@ class FeedbagFoodgroup:
@Subgroup(0x000A) @Subgroup(0x000A)
def delete_item(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def delete_item(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__DELETE_ITEM") self.logger.debug("[Client] FEEDBAG__DELETE_ITEM")
bs = context.bs bs = context.bs
before = bs.me_visibility_snapshot() before = bs.me_visibility_snapshot()
@@ -1134,13 +1134,13 @@ class FeedbagFoodgroup:
context.backend._mark_modified(context.user) context.backend._mark_modified(context.user)
bs.me_visibility_changed(before) bs.me_visibility_changed(before)
self.logger.info("[Server] FEEDBAG__STATUS") self.logger.debug("[Server] FEEDBAG__STATUS")
_send_feedbag_status(client, message.request_id, statuses) _send_feedbag_status(client, message.request_id, statuses)
@Subgroup(0x0014) @Subgroup(0x0014)
def pre_authorize_buddy(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def pre_authorize_buddy(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# FEEDBAG__PRE_AUTHORIZE_BUDDY: string08 who, string16 message, u16 flags; they may add us without asking # FEEDBAG__PRE_AUTHORIZE_BUDDY: string08 who, string16 message, u16 flags; they may add us without asking
self.logger.info("[Client] FEEDBAG__PRE_AUTHORIZE_BUDDY") self.logger.debug("[Client] FEEDBAG__PRE_AUTHORIZE_BUDDY")
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
text = _read_string16(message) text = _read_string16(message)
target = names.resolve_user(context.backend, name) target = names.resolve_user(context.backend, name)
@@ -1154,7 +1154,7 @@ class FeedbagFoodgroup:
@Subgroup(0x0018) @Subgroup(0x0018)
def request_authorize_to_host(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def request_authorize_to_host(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# FEEDBAG__REQUEST_AUTHORIZE_TO_HOST: string08 who, string16 reason, u16 unknown # FEEDBAG__REQUEST_AUTHORIZE_TO_HOST: string08 who, string16 reason, u16 unknown
self.logger.info("[Client] FEEDBAG__REQUEST_AUTHORIZE_TO_HOST") self.logger.debug("[Client] FEEDBAG__REQUEST_AUTHORIZE_TO_HOST")
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
reason = _read_string16(message) reason = _read_string16(message)
target = names.resolve_user(context.backend, name) target = names.resolve_user(context.backend, name)
@@ -1166,7 +1166,7 @@ class FeedbagFoodgroup:
@Subgroup(0x001A) @Subgroup(0x001A)
def respond_authorize_to_host(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def respond_authorize_to_host(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# FEEDBAG__RESPOND_AUTHORIZE_TO_HOST: string08 who, u8 accepted, string16 reason # FEEDBAG__RESPOND_AUTHORIZE_TO_HOST: string08 who, u8 accepted, string16 reason
self.logger.info("[Client] FEEDBAG__RESPOND_AUTHORIZE_TO_HOST") self.logger.debug("[Client] FEEDBAG__RESPOND_AUTHORIZE_TO_HOST")
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
accepted = message.read_u8() if len(message) > 0 else 0 accepted = message.read_u8() if len(message) > 0 else 0
reason = _read_string16(message) reason = _read_string16(message)
@@ -1180,7 +1180,7 @@ class FeedbagFoodgroup:
@Subgroup(0x0016) @Subgroup(0x0016)
def remove_me(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def remove_me(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info("[Client] FEEDBAG__REMOVE_ME") self.logger.debug("[Client] FEEDBAG__REMOVE_ME")
# xx byte length of the uin string # xx byte length of the uin string
# xx .. string remote client uin string # xx .. string remote client uin string
@@ -1213,9 +1213,9 @@ class FeedbagFoodgroup:
try: try:
context.bs._remove_from_list(owner, head, lst, None) context.bs._remove_from_list(owner, head, lst, None)
except Exception: except Exception:
self.logger.info("[Server] FEEDBAG__REMOVE_ME could not clear", lst.name, "between", owner.username, "and", head.username) self.logger.debug("[Server] FEEDBAG__REMOVE_ME could not clear", lst.name, "between", owner.username, "and", head.username)
self.logger.info(context.user.username, "removed themselves from", target_user.username + "'s Buddy List") self.logger.debug(context.user.username, "removed themselves from", target_user.username + "'s Buddy List")
def _read_string16(message: SNACMessage) -> str: def _read_string16(message: SNACMessage) -> str:
if len(message) < 2: if len(message) < 2:
+26 -26
View File
@@ -84,12 +84,12 @@ class ICBMFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def add_paramenters(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def add_paramenters(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] ICBM__ADD_PARAMENTERS (not implemented)') self.logger.debug('[Client] ICBM__ADD_PARAMENTERS (not implemented)')
self.logger.info('[Client]', message.data.hex()) self.logger.debug('[Client]', message.data.hex())
@Subgroup(0x0004) @Subgroup(0x0004)
def parameter_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def parameter_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] ICBM__PARAMENTER_QUERY') self.logger.debug('[Client] ICBM__PARAMENTER_QUERY')
response_msg = SNACMessage(0x0004, 0x0005, 0x0000, message.request_id) response_msg = SNACMessage(0x0004, 0x0005, 0x0000, message.request_id)
@@ -109,7 +109,7 @@ class ICBMFoodgroup:
response_msg.write_u16(999) # maxDestinationEvil response_msg.write_u16(999) # maxDestinationEvil
response_msg.write_u32(0) # minInterICBMInterval response_msg.write_u32(0) # minInterICBMInterval
self.logger.info('[Server] ICBM__PARAMENTER_REPLY') self.logger.debug('[Server] ICBM__PARAMENTER_REPLY')
client.send_snac(response_msg) client.send_snac(response_msg)
@Subgroup(0x0006) @Subgroup(0x0006)
@@ -119,19 +119,19 @@ class ICBMFoodgroup:
receiver = message.read_bytes(message.read_u8()).decode('latin-1') receiver = message.read_bytes(message.read_u8()).decode('latin-1')
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
self.logger.info('[Client] ICBM__CHANNEL_MSG_TOHOST') self.logger.debug('[Client] ICBM__CHANNEL_MSG_TOHOST')
self.logger.info('[Client] Cookie:', cookie) self.logger.debug('[Client] Cookie:', cookie)
self.logger.info('[Client] Channel:', hex(channel)) self.logger.debug('[Client] Channel:', hex(channel))
self.logger.info('[Client] Message receiver:', receiver) self.logger.debug('[Client] Message receiver:', receiver)
for tlv in tlvs: for tlv in tlvs:
self.logger.info('[Client] TLV', hex(tlv.type), '-', tlv.data) self.logger.debug('[Client] TLV', hex(tlv.type), '-', tlv.data)
send = _Send(client, context, message, cookie, channel, receiver, tlvs) send = _Send(client, context, message, cookie, channel, receiver, tlvs)
target = names.resolve_user(context.backend, receiver) target = names.resolve_user(context.backend, receiver)
if target is None or not names.representable(target): if target is None or not names.representable(target):
self.logger.info('[Client] Unknown receiver:', receiver) self.logger.debug('[Client] Unknown receiver:', receiver)
send.error(ICBMError.NotLoggedOn) send.error(ICBMError.NotLoggedOn)
return return
names.remember(context.bs, target, receiver) names.remember(context.bs, target, receiver)
@@ -148,13 +148,13 @@ class ICBMFoodgroup:
if channel == ICBMChannel.AOLIM: if channel == ICBMChannel.AOLIM:
im_data_tlv = find_tlv(tlvs, ICBMTag.ImData) im_data_tlv = find_tlv(tlvs, ICBMTag.ImData)
if im_data_tlv is None: if im_data_tlv is None:
self.logger.info('[Client] Missing IM data TLV') self.logger.debug('[Client] Missing IM data TLV')
return return
text = parse_im_text(im_data_tlv.data) text = parse_im_text(im_data_tlv.data)
if text is None: if text is None:
self.logger.info('[Client] Missing IM text TLV inside IM data') self.logger.debug('[Client] Missing IM text TLV inside IM data')
return return
self.logger.info('[Client] Message text:', text) self.logger.debug('[Client] Message text:', text)
if names.is_icq_session(context.bs) and not looks_like_html(text): if names.is_icq_session(context.bs) and not looks_like_html(text):
# ICQ sends plain text, where AIM sends HTML # ICQ sends plain text, where AIM sends HTML
send.text(text, plain_to_html(text)) send.text(text, plain_to_html(text))
@@ -166,16 +166,16 @@ class ICBMFoodgroup:
data_tlv = find_tlv(tlvs, ICBMTag.Data) data_tlv = find_tlv(tlvs, ICBMTag.Data)
parsed = parse_icq_message(data_tlv.data) if data_tlv is not None else None parsed = parse_icq_message(data_tlv.data) if data_tlv is not None else None
if parsed is None: if parsed is None:
self.logger.info('[Client] Malformed channel 4 message') self.logger.debug('[Client] Malformed channel 4 message')
return return
send.icq(*parsed) send.icq(*parsed)
else: else:
self.logger.info('[Client] Unsupported channel:', hex(channel)) self.logger.debug('[Client] Unsupported channel:', hex(channel))
send.error(ICBMError.NotSupportedByHost) send.error(ICBMError.NotSupportedByHost)
@Subgroup(0x0008) @Subgroup(0x0008)
def evil_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def evil_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] ICBM__EVIL_REQUEST') self.logger.debug('[Client] ICBM__EVIL_REQUEST')
# u16 send as (0: as yourself, 1: anonymously), string08 who # u16 send as (0: as yourself, 1: anonymously), string08 who
send_as = message.read_u16() send_as = message.read_u16()
@@ -211,7 +211,7 @@ class ICBMFoodgroup:
reply = SNACMessage(0x0004, 0x0009, 0x0000, message.request_id) reply = SNACMessage(0x0004, 0x0009, 0x0000, message.request_id)
reply.write_u16(delta) reply.write_u16(delta)
reply.write_u16(new_level) reply.write_u16(new_level)
self.logger.info('[Server] ICBM__EVIL_REPLY') self.logger.debug('[Server] ICBM__EVIL_REPLY')
client.send_snac(reply) client.send_snac(reply)
@Subgroup(0x000B) @Subgroup(0x000B)
@@ -222,7 +222,7 @@ class ICBMFoodgroup:
channel = message.read_u16() channel = message.read_u16()
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
rest = message.data rest = message.data
self.logger.info('[Client] ICBM__CLIENT_ERR to', name) self.logger.debug('[Client] ICBM__CLIENT_ERR to', name)
target = names.resolve_user(context.backend, name) target = names.resolve_user(context.backend, name)
if target is None or _blocks(context.backend, target, context.user): if target is None or _blocks(context.backend, target, context.user):
@@ -239,7 +239,7 @@ class ICBMFoodgroup:
@Subgroup(0x0010) @Subgroup(0x0010)
def offline_retrieve(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def offline_retrieve(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] ICBM__OFFLINE_RETRIEVE') self.logger.debug('[Client] ICBM__OFFLINE_RETRIEVE')
# ICBM__OFFLINE_RETRIEVE_REPLY ends the batch; it has no body # ICBM__OFFLINE_RETRIEVE_REPLY ends the batch; it has no body
deliver_stored_messages(client.ctrl, then = lambda: client.send_snac(SNACMessage(0x0004, 0x0017, 0x0000, message.request_id))) deliver_stored_messages(client.ctrl, then = lambda: client.send_snac(SNACMessage(0x0004, 0x0017, 0x0000, message.request_id)))
@@ -250,16 +250,16 @@ class ICBMFoodgroup:
receiver = message.read_bytes(message.read_u8()).decode('latin-1') receiver = message.read_bytes(message.read_u8()).decode('latin-1')
event = message.read_u16() event = message.read_u16()
self.logger.info('[Client] ICBM__CLIENT_EVENT') self.logger.debug('[Client] ICBM__CLIENT_EVENT')
self.logger.info('[Client] Receiver:', receiver, '| Event:', hex(event)) self.logger.debug('[Client] Receiver:', receiver, '| Event:', hex(event))
if channel != ICBMChannel.AOLIM: if channel != ICBMChannel.AOLIM:
self.logger.info('[Client] Unsupported channel:', hex(channel)) self.logger.debug('[Client] Unsupported channel:', hex(channel))
return return
receiver_user = names.resolve_user(context.backend, receiver) receiver_user = names.resolve_user(context.backend, receiver)
if receiver_user is None: if receiver_user is None:
self.logger.info('[Client] Unknown receiver:', receiver) self.logger.debug('[Client] Unknown receiver:', receiver)
return return
receiver_uuid = receiver_user.uuid receiver_uuid = receiver_user.uuid
@@ -269,7 +269,7 @@ class ICBMFoodgroup:
elif event in (ICBMEvent.Finished, ICBMEvent.Typed, ICBMEvent.Closed): elif event in (ICBMEvent.Finished, ICBMEvent.Typed, ICBMEvent.Closed):
msg_type = MessageType.TypingDone msg_type = MessageType.TypingDone
else: else:
self.logger.info('[Client] Unknown event type:', hex(event)) self.logger.debug('[Client] Unknown event type:', hex(event))
return return
# a typing notification only goes to a conversation that's already there # a typing notification only goes to a conversation that's already there
@@ -317,7 +317,7 @@ class _Send:
receiver = self.receiver.encode('latin-1', errors = 'replace') receiver = self.receiver.encode('latin-1', errors = 'replace')
ack.write_u8(len(receiver)) ack.write_u8(len(receiver))
ack.write_bytes(receiver) ack.write_bytes(receiver)
self.client.ctrl.logger.info('[Server] ICBM__HOST_ACK') self.client.ctrl.logger.debug('[Server] ICBM__HOST_ACK')
self.client.send_snac(ack) self.client.send_snac(ack)
def text(self, plain: str, html: str, *, icq: Optional[Tuple[int, int, str]] = None) -> None: def text(self, plain: str, html: str, *, icq: Optional[Tuple[int, int, str]] = None) -> None:
@@ -347,7 +347,7 @@ class _Send:
self.error(ICBMError.NotLoggedOn) self.error(ICBMError.NotLoggedOn)
return return
except Exception as ex: except Exception as ex:
ctrl.logger.info('[Client] Could not create private chat:', str(ex)) ctrl.logger.debug('[Client] Could not create private chat:', str(ex))
self.error(ICBMError.NotLoggedOn) self.error(ICBMError.NotLoggedOn)
return return
+8 -8
View File
@@ -243,7 +243,7 @@ class ICQFoodgroup:
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
envelope_tlv = find_tlv(tlvs, 0x0001) envelope_tlv = find_tlv(tlvs, 0x0001)
if envelope_tlv is None or len(envelope_tlv.data) < 2: if envelope_tlv is None or len(envelope_tlv.data) < 2:
self.logger.info('[Client] ICQ__DB_QUERY without its envelope') self.logger.debug('[Client] ICQ__DB_QUERY without its envelope')
return return
# TLV 0x01: u16 (LE) length, u32 UIN, u16 request type, u16 sequence, [u16 meta subtype], request data # TLV 0x01: u16 (LE) length, u32 UIN, u16 request type, u16 sequence, [u16 meta subtype], request data
@@ -255,32 +255,32 @@ class ICQFoodgroup:
request_type = reader.u16() request_type = reader.u16()
seq = reader.u16() seq = reader.u16()
except ValueError: except ValueError:
self.logger.info('[Client] Truncated ICQ__DB_QUERY') self.logger.debug('[Client] Truncated ICQ__DB_QUERY')
return return
query = ICQContext(client, context, message.request_id, seq) query = ICQContext(client, context, message.request_id, seq)
if request_type == ICQRequest.OfflineMessages: if request_type == ICQRequest.OfflineMessages:
self.logger.info('[Client] ICQ__DB_QUERY offline messages') self.logger.debug('[Client] ICQ__DB_QUERY offline messages')
offline_messages(query) offline_messages(query)
elif request_type == ICQRequest.DeleteOfflineMessages: elif request_type == ICQRequest.DeleteOfflineMessages:
self.logger.info('[Client] ICQ__DB_QUERY delete offline messages') self.logger.debug('[Client] ICQ__DB_QUERY delete offline messages')
delete_offline_messages(query) delete_offline_messages(query)
elif request_type == ICQRequest.Meta: elif request_type == ICQRequest.Meta:
try: try:
subtype = reader.u16() subtype = reader.u16()
except ValueError: except ValueError:
return return
self.logger.info('[Client] ICQ__DB_QUERY meta', hex(subtype)) self.logger.debug('[Client] ICQ__DB_QUERY meta', hex(subtype))
handler = META_HANDLERS.get(subtype) handler = META_HANDLERS.get(subtype)
if handler is None: if handler is None:
self.logger.info('[Client] Unsupported ICQ meta request', hex(subtype)) self.logger.debug('[Client] Unsupported ICQ meta request', hex(subtype))
return return
try: try:
handler(query, reader) handler(query, reader)
except ValueError: except ValueError:
self.logger.info('[Client] Malformed ICQ meta request', hex(subtype)) self.logger.debug('[Client] Malformed ICQ meta request', hex(subtype))
else: else:
self.logger.info('[Client] Unknown ICQ__DB_QUERY request type', hex(request_type)) self.logger.debug('[Client] Unknown ICQ__DB_QUERY request type', hex(request_type))
# offline messages # offline messages
+1 -1
View File
@@ -10,4 +10,4 @@ class InviteFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def request_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def request_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# "invite a friend to AIM" (an e-mail address and a message); nothing is sent out # "invite a friend to AIM" (an e-mail address and a message); nothing is sent out
self.logger.info('[Client] INVITE__REQUEST_QUERY (not sent)') self.logger.debug('[Client] INVITE__REQUEST_QUERY (not sent)')
+12 -12
View File
@@ -118,7 +118,7 @@ class LocateFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def client_versions(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def client_versions(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] LOCATE__RIGHTS_QUERY') self.logger.debug('[Client] LOCATE__RIGHTS_QUERY')
response_msg = SNACMessage(0x0002, 0x0003, 0x0000, message.request_id) response_msg = SNACMessage(0x0002, 0x0003, 0x0000, message.request_id)
@@ -145,12 +145,12 @@ class LocateFoodgroup:
TLV(0x0005, struct.pack('>H', 0x0080)) # unknown TLV(0x0005, struct.pack('>H', 0x0080)) # unknown
]) ])
self.logger.info('[Server] LOCATE__RIGHTS_REPLY') self.logger.debug('[Server] LOCATE__RIGHTS_REPLY')
client.send_snac(response_msg) client.send_snac(response_msg)
@Subgroup(0x0004) @Subgroup(0x0004)
def set_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def set_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] LOCATE__SET_INFO') self.logger.debug('[Client] LOCATE__SET_INFO')
bs = context.bs bs = context.bs
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
@@ -200,7 +200,7 @@ class LocateFoodgroup:
# u16 type (LOCATE_TYPE_*), string08 who # u16 type (LOCATE_TYPE_*), string08 who
query_type = message.read_u16() query_type = message.read_u16()
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
self.logger.info('[Client] LOCATE__USER_INFO_QUERY for', name, '(type', hex(query_type) + ')') self.logger.debug('[Client] LOCATE__USER_INFO_QUERY for', name, '(type', hex(query_type) + ')')
user_info_reply(client, context, message, query_type, name) user_info_reply(client, context, message, query_type, name)
@Subgroup(0x0015) @Subgroup(0x0015)
@@ -208,12 +208,12 @@ class LocateFoodgroup:
# the same query with a u32 type # the same query with a u32 type
query_type = message.read_u32() query_type = message.read_u32()
name = message.read_bytes(message.read_u8()).decode('latin-1') name = message.read_bytes(message.read_u8()).decode('latin-1')
self.logger.info('[Client] LOCATE__USER_INFO_QUERY2 for', name, '(type', hex(query_type) + ')') self.logger.debug('[Client] LOCATE__USER_INFO_QUERY2 for', name, '(type', hex(query_type) + ')')
user_info_reply(client, context, message, query_type & 0xFFFF, name) user_info_reply(client, context, message, query_type & 0xFFFF, name)
@Subgroup(0x0009) @Subgroup(0x0009)
def set_dir_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def set_dir_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] LOCATE__SET_DIR_INFO') self.logger.debug('[Client] LOCATE__SET_DIR_INFO')
# a TLV per ODIR field; whatever is sent replaces what was there # a TLV per ODIR field; whatever is sent replaces what was there
store = dir_info(context.user) store = dir_info(context.user)
@@ -225,15 +225,15 @@ class LocateFoodgroup:
# LOCATE__SET_DIR_REPLY: u16 result, 1 for success # LOCATE__SET_DIR_REPLY: u16 result, 1 for success
reply = SNACMessage(0x0002, 0x000A, 0x0000, message.request_id) reply = SNACMessage(0x0002, 0x000A, 0x0000, message.request_id)
reply.write_u16(0x0001) reply.write_u16(0x0001)
self.logger.info('[Server] LOCATE__SET_DIR_REPLY') self.logger.debug('[Server] LOCATE__SET_DIR_REPLY')
client.send_snac(reply) client.send_snac(reply)
@Subgroup(0x000B) @Subgroup(0x000B)
def get_dir_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def get_dir_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] LOCATE__GET_DIR_INFO') self.logger.debug('[Client] LOCATE__GET_DIR_INFO')
screen_name = message.read_bytes(message.read_u8()).decode('latin-1') screen_name = message.read_bytes(message.read_u8()).decode('latin-1')
self.logger.info('[Client] Getting info for:', screen_name) self.logger.debug('[Client] Getting info for:', screen_name)
# Response from NINA's servers: # Response from NINA's servers:
# == # ==
@@ -253,12 +253,12 @@ class LocateFoodgroup:
tlvs = dir_tlvs(target) + tlvs tlvs = dir_tlvs(target) + tlvs
response_msg.write_tlv_block(tlvs) response_msg.write_tlv_block(tlvs)
self.logger.info('[Server] LOCATE__GET_DIR_REPLY') self.logger.debug('[Server] LOCATE__GET_DIR_REPLY')
client.send_snac(response_msg) client.send_snac(response_msg)
@Subgroup(0x000F) @Subgroup(0x000F)
def set_keyword_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def set_keyword_info(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] LOCATE__SET_KEYWORD_INFO') self.logger.debug('[Client] LOCATE__SET_KEYWORD_INFO')
# up to five interests, TLV 0x0B each # up to five interests, TLV 0x0B each
interests = [tlv.data.decode('latin-1') for tlv in unmarshal_tlvs(message.data) if tlv.type == DIR_INTEREST] interests = [tlv.data.decode('latin-1') for tlv in unmarshal_tlvs(message.data) if tlv.type == DIR_INTEREST]
@@ -268,5 +268,5 @@ class LocateFoodgroup:
# LOCATE__SET_KEYWORD_REPLY: u16, 1 # LOCATE__SET_KEYWORD_REPLY: u16, 1
reply = SNACMessage(0x0002, 0x0010, 0x0000, message.request_id) reply = SNACMessage(0x0002, 0x0010, 0x0000, message.request_id)
reply.write_u16(0x0001) reply.write_u16(0x0001)
self.logger.info('[Server] LOCATE__SET_KEYWORD_REPLY') self.logger.debug('[Server] LOCATE__SET_KEYWORD_REPLY')
client.send_snac(reply) client.send_snac(reply)
+28 -28
View File
@@ -108,7 +108,7 @@ class OSERVICEFoodgroup:
@Subgroup(0x0017) @Subgroup(0x0017)
def client_versions(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def client_versions(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__CLIENT_VERSIONS') self.logger.debug('[Client] OSERVICE__CLIENT_VERSIONS')
versions = {} versions = {}
while len(message) >= 4: while len(message) >= 4:
@@ -122,7 +122,7 @@ class OSERVICEFoodgroup:
response_msg.write_u16(foodgroup) response_msg.write_u16(foodgroup)
response_msg.write_u16(version) response_msg.write_u16(version)
self.logger.info('[Server] OSERVICE__HOST_VERSIONS') self.logger.debug('[Server] OSERVICE__HOST_VERSIONS')
client.send_snac(response_msg) client.send_snac(response_msg)
if getattr(settings, 'OSCAR_MOTD_ENABLED', False): if getattr(settings, 'OSCAR_MOTD_ENABLED', False):
@@ -130,12 +130,12 @@ class OSERVICEFoodgroup:
motd = SNACMessage(0x0001, 0x0013) motd = SNACMessage(0x0001, 0x0013)
motd.write_u16(0x0004) motd.write_u16(0x0004)
motd.write_tlv(TLV(0x000B, getattr(settings, 'OSCAR_MOTD_TEXT', 'Welcome to CrossTalk!'))) motd.write_tlv(TLV(0x000B, getattr(settings, 'OSCAR_MOTD_TEXT', 'Welcome to CrossTalk!')))
self.logger.info('[Server] OSERVICE__MOTD') self.logger.debug('[Server] OSERVICE__MOTD')
client.send_snac(motd) client.send_snac(motd)
@Subgroup(0x0002) @Subgroup(0x0002)
def client_ready(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def client_ready(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__CLIENT_READY') self.logger.debug('[Client] OSERVICE__CLIENT_READY')
ctrl = client.ctrl ctrl = client.ctrl
if ctrl.is_service: if ctrl.is_service:
@@ -169,7 +169,7 @@ class OSERVICEFoodgroup:
msg = SNACMessage(0x000B, 0x0002) msg = SNACMessage(0x000B, 0x0002)
msg.write_u16(MIN_STATS_REPORT_INTERVAL) msg.write_u16(MIN_STATS_REPORT_INTERVAL)
self.logger.info('[Server] STATS__SET_MIN_REPORT_INTERVAL') self.logger.debug('[Server] STATS__SET_MIN_REPORT_INTERVAL')
client.send_snac(msg) client.send_snac(msg)
# authorization requests and answers that came in while this account wasn't on ICQ # authorization requests and answers that came in while this account wasn't on ICQ
@@ -184,23 +184,23 @@ class OSERVICEFoodgroup:
@Subgroup(0x0006) @Subgroup(0x0006)
def rate_params_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def rate_params_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__RATE_PARAMS_QUERY') self.logger.debug('[Client] OSERVICE__RATE_PARAMS_QUERY')
oservice_version = getattr(client.ctrl, 'versions', {}).get(0x0001, 1) oservice_version = getattr(client.ctrl, 'versions', {}).get(0x0001, 1)
response_msg = SNACMessage(0x0001, 0x0007, 0x0000, message.request_id, build_rate_params(oservice_version)) response_msg = SNACMessage(0x0001, 0x0007, 0x0000, message.request_id, build_rate_params(oservice_version))
self.logger.info('[Server] OSERVICE__RATE_PARAMS_REPLY') self.logger.debug('[Server] OSERVICE__RATE_PARAMS_REPLY')
client.send_snac(response_msg) client.send_snac(response_msg)
@Subgroup(0x0008) @Subgroup(0x0008)
def rate_params_sub_add(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def rate_params_sub_add(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__RATE_PARAMS_SUB_ADD (not implemented)') self.logger.debug('[Client] OSERVICE__RATE_PARAMS_SUB_ADD (not implemented)')
# since i don't have rate limits properly implemented *yet*, i won't do anything here # since i don't have rate limits properly implemented *yet*, i won't do anything here
@Subgroup(0x000E) @Subgroup(0x000E)
def user_info_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def user_info_query(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__USER_INFO_QUERY') self.logger.debug('[Client] OSERVICE__USER_INFO_QUERY')
date_created = context.bs.user.date_created date_created = context.bs.user.date_created
date_login = context.bs.user.date_login date_login = context.bs.user.date_login
@@ -210,25 +210,25 @@ class OSERVICEFoodgroup:
date_login_unix = int(calendar.timegm(date_login.timetuple())) if date_login else 0 date_login_unix = int(calendar.timegm(date_login.timetuple())) if date_login else 0
session_len = int(now.timestamp()) - date_login_unix if date_login else 0 session_len = int(now.timestamp()) - date_login_unix if date_login else 0
self.logger.info('Date created:', date_created) self.logger.debug('Date created:', date_created)
self.logger.info('Date created (UNIX time):', date_created_unix) self.logger.debug('Date created (UNIX time):', date_created_unix)
self.logger.info('Date logged in:', date_login or 'Never') self.logger.debug('Date logged in:', date_login or 'Never')
self.logger.info('Date logged in (UNIX time):', date_login_unix) self.logger.debug('Date logged in (UNIX time):', date_login_unix)
self.logger.info('Current time:', int(now.timestamp())) self.logger.debug('Current time:', int(now.timestamp()))
self.logger.info('Session length:', session_len) self.logger.debug('Session length:', session_len)
self.logger.info('Client IP:', client.get_ip()) self.logger.debug('Client IP:', client.get_ip())
# OSERVICE__USERINFO: displayId, warning level, then the OSERVICE__USER_INFO_TAGS block # OSERVICE__USERINFO: displayId, warning level, then the OSERVICE__USER_INFO_TAGS block
response_msg = build_self_info(context.bs) response_msg = build_self_info(context.bs)
response_msg.request_id = message.request_id response_msg.request_id = message.request_id
self.logger.info('[Server] OSERVICE__USER_INFO_UPDATE') self.logger.debug('[Server] OSERVICE__USER_INFO_UPDATE')
client.send_snac(response_msg) client.send_snac(response_msg)
#if settings.OSCAR_MOTD_ENABLED: #if settings.OSCAR_MOTD_ENABLED:
# self.logger.info('[Server] OSERVICE__MOTD') # self.logger.debug('[Server] OSERVICE__MOTD')
# motd = SNACMessage(0x0001, 0x0013, 0x0000, 0x0000) # motd = SNACMessage(0x0001, 0x0013, 0x0000, 0x0000)
# motd.write_u8(4) # motd.write_u8(4)
# motd.write_u8(0) # filler # motd.write_u8(0) # filler
@@ -237,14 +237,14 @@ class OSERVICEFoodgroup:
@Subgroup(0x0011) @Subgroup(0x0011)
def idle_notification(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def idle_notification(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__IDLE_NOTIFICATION') self.logger.debug('[Client] OSERVICE__IDLE_NOTIFICATION')
idle_time = message.read_u32() idle_time = message.read_u32()
if idle_time == 0: if idle_time == 0:
self.logger.info(context.bs.user.username, 'is no longer idle') self.logger.debug(context.bs.user.username, 'is no longer idle')
context.bs.front_data.pop('oscar0_idle_since', None) context.bs.front_data.pop('oscar0_idle_since', None)
else: else:
self.logger.info(context.bs.user.username, 'has been idle for', str(idle_time), 'seconds') self.logger.debug(context.bs.user.username, 'has been idle for', str(idle_time), 'seconds')
context.bs.front_data['oscar0_idle_since'] = time.time() - idle_time context.bs.front_data['oscar0_idle_since'] = time.time() - idle_time
# contacts need a fresh arrival so the idle time in the userinfo gets refreshed on their end # contacts need a fresh arrival so the idle time in the userinfo gets refreshed on their end
@@ -257,16 +257,16 @@ class OSERVICEFoodgroup:
def set_privacy_flags(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def set_privacy_flags(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# u32 flags: 0x01 lets others see idle time, 0x02 the member since date; nothing here hides either yet # u32 flags: 0x01 lets others see idle time, 0x02 the member since date; nothing here hides either yet
flags = message.read_u32() if len(message) >= 4 else 0 flags = message.read_u32() if len(message) >= 4 else 0
self.logger.info('[Client] OSERVICE__SET_PRIVACY_FLAGS', hex(flags)) self.logger.debug('[Client] OSERVICE__SET_PRIVACY_FLAGS', hex(flags))
@Subgroup(0x0016) @Subgroup(0x0016)
def noop(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def noop(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# a keep-alive; there is no reply # a keep-alive; there is no reply
self.logger.info('[Client] OSERVICE__NOOP') self.logger.debug('[Client] OSERVICE__NOOP')
@Subgroup(0x001E) @Subgroup(0x001E)
def set_user_info_fields(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def set_user_info_fields(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__SET_USERINFO_FIELDS') self.logger.debug('[Client] OSERVICE__SET_USERINFO_FIELDS')
bs = context.bs bs = context.bs
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
@@ -279,7 +279,7 @@ class OSERVICEFoodgroup:
if (status_tlv := find_tlv(tlvs, 0x0006)) is not None and len(status_tlv.data) >= 4: if (status_tlv := find_tlv(tlvs, 0x0006)) is not None and len(status_tlv.data) >= 4:
status = struct.unpack('>L', status_tlv.data[:4])[0] status = struct.unpack('>L', status_tlv.data[:4])[0]
bs.front_data['oscar0_icq_status'] = status bs.front_data['oscar0_icq_status'] = status
self.logger.info('[Client] Status:', hex(status)) self.logger.debug('[Client] Status:', hex(status))
# before OSERVICE__CLIENT_READY this is only what the client wants to come online as # before OSERVICE__CLIENT_READY this is only what the client wants to come online as
if bs.front_data.get('oscar0_ready'): if bs.front_data.get('oscar0_ready'):
substatus = substatus_from_icq_status(status) substatus = substatus_from_icq_status(status)
@@ -293,16 +293,16 @@ class OSERVICEFoodgroup:
@Subgroup(0x001F) @Subgroup(0x001F)
def probe_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def probe_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
# some ICQ clients probe a connection before using it; OSERVICE__PROBE_ACK has no body # some ICQ clients probe a connection before using it; OSERVICE__PROBE_ACK has no body
self.logger.info('[Client] OSERVICE__PROBE_REQ') self.logger.debug('[Client] OSERVICE__PROBE_REQ')
client.send_snac(SNACMessage(0x0001, 0x0020, 0x0000, message.request_id)) client.send_snac(SNACMessage(0x0001, 0x0020, 0x0000, message.request_id))
@Subgroup(0x0004) @Subgroup(0x0004)
def service_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def service_request(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] OSERVICE__SERVICE_REQUEST') self.logger.debug('[Client] OSERVICE__SERVICE_REQUEST')
foodgroup = message.read_u16() foodgroup = message.read_u16()
tlvs = unmarshal_tlvs(message.data) tlvs = unmarshal_tlvs(message.data)
self.logger.info('[Client] Foodgroup:', hex(foodgroup)) self.logger.debug('[Client] Foodgroup:', hex(foodgroup))
if foodgroup not in REQUESTABLE_SERVICES: if foodgroup not in REQUESTABLE_SERVICES:
# OSERVICE__ERR, service unavailable # OSERVICE__ERR, service unavailable
+8 -8
View File
@@ -185,11 +185,11 @@ class PDHandlers:
@Subgroup(0x0004) @Subgroup(0x0004)
def set_group_permit_mask(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def set_group_permit_mask(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] PD__SET_GROUP_PERMIT_MASK') self.logger.debug('[Client] PD__SET_GROUP_PERMIT_MASK')
# xx xx xx xx dword group permission mask # xx xx xx xx dword group permission mask
mask = message.read_u32() mask = message.read_u32()
self.logger.info('[Client] Mask:', hex(mask)) self.logger.debug('[Client] Mask:', hex(mask))
before = context.bs.me_visibility_snapshot() before = context.bs.me_visibility_snapshot()
set_pd_mask(context, mask) set_pd_mask(context, mask)
@@ -198,27 +198,27 @@ class PDHandlers:
@Subgroup(0x0005) @Subgroup(0x0005)
def add_perm_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def add_perm_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] PD__ADD_PERM_LIST_ENTRIES') self.logger.debug('[Client] PD__ADD_PERM_LIST_ENTRIES')
_apply_entries(context, message, permit = True, add = True) _apply_entries(context, message, permit = True, add = True)
@Subgroup(0x0006) @Subgroup(0x0006)
def del_perm_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def del_perm_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] PD__DEL_PERM_LIST_ENTRIES') self.logger.debug('[Client] PD__DEL_PERM_LIST_ENTRIES')
_apply_entries(context, message, permit = True, add = False) _apply_entries(context, message, permit = True, add = False)
@Subgroup(0x0007) @Subgroup(0x0007)
def add_deny_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def add_deny_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] PD__ADD_DENY_LIST_ENTRIES') self.logger.debug('[Client] PD__ADD_DENY_LIST_ENTRIES')
_apply_entries(context, message, permit = False, add = True) _apply_entries(context, message, permit = False, add = True)
@Subgroup(0x0008) @Subgroup(0x0008)
def del_deny_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def del_deny_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] PD__DEL_DENY_LIST_ENTRIES') self.logger.debug('[Client] PD__DEL_DENY_LIST_ENTRIES')
_apply_entries(context, message, permit = False, add = False) _apply_entries(context, message, permit = False, add = False)
@Subgroup(0x000A) @Subgroup(0x000A)
def add_temp_permit_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def add_temp_permit_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] PD__ADD_TEMP_PERMIT_LIST_ENTRIES') self.logger.debug('[Client] PD__ADD_TEMP_PERMIT_LIST_ENTRIES')
# temp permits only live as long as the session, so they stay out of the persisted lists # temp permits only live as long as the session, so they stay out of the persisted lists
temp_permits = context.bs.front_data.setdefault('oscar0_temp_permits', set()) temp_permits = context.bs.front_data.setdefault('oscar0_temp_permits', set())
@@ -229,7 +229,7 @@ class PDHandlers:
@Subgroup(0x000B) @Subgroup(0x000B)
def del_temp_permit_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def del_temp_permit_list_entries(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] PD__DEL_TEMP_PERMIT_LIST_ENTRIES') self.logger.debug('[Client] PD__DEL_TEMP_PERMIT_LIST_ENTRIES')
temp_permits = context.bs.front_data.setdefault('oscar0_temp_permits', set()) temp_permits = context.bs.front_data.setdefault('oscar0_temp_permits', set())
for name in _read_entries(message): for name in _read_entries(message):
-3
View File
@@ -11,7 +11,4 @@ def popup_display(self, alert_url: Optional[str], alert_txt: str):
response_msg = SNACMessage(0x0008, 0x0002, 0x0000, 0x00000000) response_msg = SNACMessage(0x0008, 0x0002, 0x0000, 0x00000000)
response_msg.write_bytes(system_message(alert_url, alert_txt)) response_msg.write_bytes(system_message(alert_url, alert_txt))
# TODO: pipe to ctrl.send_snac()
print('TLVs:', unmarshal_tlvs(response_msg.data))
#client.send_snac(response_msg)
return response_msg return response_msg
+2 -2
View File
@@ -9,9 +9,9 @@ class StatsFoodgroup:
@Subgroup(0x0003) @Subgroup(0x0003)
def report_events(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def report_events(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] STATS__REPORT_EVENTS') self.logger.debug('[Client] STATS__REPORT_EVENTS')
# we don't really care for the info in the SNAC message's body for now, so just send # we don't really care for the info in the SNAC message's body for now, so just send
# a STATS__REPORT_ACK # a STATS__REPORT_ACK
self.logger.info('[Server] STATS__REPORT_ACK') self.logger.debug('[Server] STATS__REPORT_ACK')
client.send_snac(SNACMessage(0x000B, 0x0004)) client.send_snac(SNACMessage(0x000B, 0x0004))
+3 -3
View File
@@ -16,7 +16,7 @@ class UserLookupFoodgroup:
@Subgroup(0x0002) @Subgroup(0x0002)
def find_by_email(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None: def find_by_email(self, client: OSCARClient, context: OSCARContext, message: SNACMessage) -> None:
self.logger.info('[Client] USER_LOOKUP__FIND_BY_EMAIL') self.logger.debug('[Client] USER_LOOKUP__FIND_BY_EMAIL')
# the SNAC body is the address itself; only people listed in the member directory can be found by it # the SNAC body is the address itself; only people listed in the member directory can be found by it
email = message.data.decode('latin-1').strip('\x00').strip() email = message.data.decode('latin-1').strip('\x00').strip()
@@ -29,11 +29,11 @@ class UserLookupFoodgroup:
if not users: if not users:
msg = SNACMessage(0x000A, 0x0001, 0x0000, message.request_id) msg = SNACMessage(0x000A, 0x0001, 0x0000, message.request_id)
msg.write_u16(LOOKUP_ERROR_NO_MATCH) msg.write_u16(LOOKUP_ERROR_NO_MATCH)
self.logger.info('[Server] USER_LOOKUP__ERR') self.logger.debug('[Server] USER_LOOKUP__ERR')
client.send_snac(msg) client.send_snac(msg)
return return
reply = SNACMessage(0x000A, 0x0003, 0x0000, message.request_id) reply = SNACMessage(0x000A, 0x0003, 0x0000, message.request_id)
reply.write_tlvs([TLV(LOOKUP_TLV_SCREEN_NAME, names.name_for(context.bs, user)) for user in users]) reply.write_tlvs([TLV(LOOKUP_TLV_SCREEN_NAME, names.name_for(context.bs, user)) for user in users])
self.logger.info('[Server] USER_LOOKUP__FIND_REPLY') self.logger.debug('[Server] USER_LOOKUP__FIND_REPLY')
client.send_snac(reply) client.send_snac(reply)
+19 -19
View File
@@ -113,7 +113,7 @@ class BackendEventHandler(event.BackendEventHandler):
self.ctrl = ctrl self.ctrl = ctrl
def on_maintenance_message(self, *args: Any, **kwargs: Any) -> None: def on_maintenance_message(self, *args: Any, **kwargs: Any) -> None:
self.ctrl.logger.info("on_maintenance message dispatched") self.ctrl.logger.debug("on_maintenance message dispatched")
message = "CrossTalk will be down for maintenance soon. Now is a good time to wrap up any conversations." message = "CrossTalk will be down for maintenance soon. Now is a good time to wrap up any conversations."
if args[1] is not None and args[1] > 0: if args[1] is not None and args[1] > 0:
message = """CrossTalk will be down for maintenance in around {} minute(s). \ message = """CrossTalk will be down for maintenance in around {} minute(s). \
@@ -121,7 +121,7 @@ Now is a good time to wrap up any conversations.""".format(args[1])
self.ctrl.send_snac(popup_display(self, "https://crosstalk.im/maintenance", message)) self.ctrl.send_snac(popup_display(self, "https://crosstalk.im/maintenance", message))
def on_client_alert(self, alert: Alert) -> bool: def on_client_alert(self, alert: Alert) -> bool:
self.ctrl.logger.info("on_client_alert dispatched") self.ctrl.logger.debug("on_client_alert dispatched")
self.ctrl.send_snac(popup_display(self, alert.url or '', alert.plain())) self.ctrl.send_snac(popup_display(self, alert.url or '', alert.plain()))
return True return True
@@ -147,10 +147,10 @@ Now is a good time to wrap up any conversations.""".format(args[1])
send_status_on_bl: bool = False, sess_id: Optional[int] = None, send_status_on_bl: bool = False, sess_id: Optional[int] = None,
updated_phone_info: Optional[Dict[str, Any]] = None, updated_phone_info: Optional[Dict[str, Any]] = None,
) -> None: ) -> None:
self.ctrl.logger.info('on_presence_notification dispatched') self.ctrl.logger.debug('on_presence_notification dispatched')
self.ctrl.logger.info('update_status:', update_status) self.ctrl.logger.debug('update_status:', update_status)
self.ctrl.logger.info('update_info_other:', update_info_other) self.ctrl.logger.debug('update_info_other:', update_info_other)
self.ctrl.logger.info('status:', ctc.status.substatus.name) self.ctrl.logger.debug('status:', ctc.status.substatus.name)
# don't want updates from users with invalid usernames # don't want updates from users with invalid usernames
if not names.representable(ctc.head): if not names.representable(ctc.head):
@@ -158,7 +158,7 @@ Now is a good time to wrap up any conversations.""".format(args[1])
# don't want any non-status updates # don't want any non-status updates
if not update_status: if not update_status:
self.ctrl.logger.info('fell into update_status check') self.ctrl.logger.debug('fell into update_status check')
return return
# presence only starts flowing once the client says it's ready for it (OSERVICE__CLIENT_READY), and only for # presence only starts flowing once the client says it's ready for it (OSERVICE__CLIENT_READY), and only for
@@ -169,21 +169,21 @@ Now is a good time to wrap up any conversations.""".format(args[1])
try: try:
ctc.compute_visible_status(self.bs.user) ctc.compute_visible_status(self.bs.user)
self.ctrl.logger.info('sending presence notif') self.ctrl.logger.debug('sending presence notif')
self.ctrl.send_snac(build_presence_notif(ctc, self.ctrl.backend, self.bs)) self.ctrl.send_snac(build_presence_notif(ctc, self.ctrl.backend, self.bs))
except Exception as ex: except Exception as ex:
self.ctrl.logger.error(ex) self.ctrl.logger.error(ex)
def on_presence_self_notification(self, old_substatus: Substatus, *, update_status: bool = True, def on_presence_self_notification(self, old_substatus: Substatus, *, update_status: bool = True,
update_info: bool = True) -> None: update_info: bool = True) -> None:
self.ctrl.logger.info('on_presence_self_notification') self.ctrl.logger.debug('on_presence_self_notification')
pass pass
def on_chat_invite( def on_chat_invite(
self, chat: Chat, inviter: User, *, circle: bool = False, inviter_id: Optional[str] = None, self, chat: Chat, inviter: User, *, circle: bool = False, inviter_id: Optional[str] = None,
invite_msg: str = '', invite_msg: str = '',
) -> None: ) -> None:
self.ctrl.logger.info('on_chat_invite') self.ctrl.logger.debug('on_chat_invite')
if chat is None: if chat is None:
chat = self.ctrl.backend.chat_create() chat = self.ctrl.backend.chat_create()
chat.add_id('oscar0', chat.ids['main']) chat.add_id('oscar0', chat.ids['main'])
@@ -199,12 +199,12 @@ Now is a good time to wrap up any conversations.""".format(args[1])
return return
def on_declined_chat_invite(self, chat: Chat, circle: bool = False) -> None: def on_declined_chat_invite(self, chat: Chat, circle: bool = False) -> None:
self.ctrl.logger.info('on_declined_chat_invite') self.ctrl.logger.debug('on_declined_chat_invite')
pass pass
def on_added_me(self, user: User, *, adder_id: Optional[str] = None, def on_added_me(self, user: User, *, adder_id: Optional[str] = None,
message: Optional[TextWithData] = None) -> None: message: Optional[TextWithData] = None) -> None:
self.ctrl.logger.info('on_added_me') self.ctrl.logger.debug('on_added_me')
if not names.representable(user): if not names.representable(user):
return return
@@ -222,23 +222,23 @@ Now is a good time to wrap up any conversations.""".format(args[1])
send_icq_system_message(self.ctrl, user, ICQMessageType.Added, '') send_icq_system_message(self.ctrl, user, ICQMessageType.Added, '')
def on_removed_me(self, user: User) -> None: def on_removed_me(self, user: User) -> None:
self.ctrl.logger.info('on_removed_me') self.ctrl.logger.debug('on_removed_me')
pass pass
def on_contact_request_denied(self, user_added: User, message: Optional[str], *, def on_contact_request_denied(self, user_added: User, message: Optional[str], *,
contact_id: Optional[str] = None) -> None: contact_id: Optional[str] = None) -> None:
self.ctrl.logger.info('on_contact_request_denied') self.ctrl.logger.debug('on_contact_request_denied')
pass pass
def on_oim_sent(self, oim: OIM) -> None: def on_oim_sent(self, oim: OIM) -> None:
self.ctrl.logger.info('on_oim_sent') self.ctrl.logger.debug('on_oim_sent')
# an offline message only gets stored while its recipient can't be reached, so a session that hears about one # an offline message only gets stored while its recipient can't be reached, so a session that hears about one
# (signed on invisible, say) gets it straight away, like the YMSG frontend does # (signed on invisible, say) gets it straight away, like the YMSG frontend does
from ..foodgroups.icbm import deliver_offline_messages from ..foodgroups.icbm import deliver_offline_messages
deliver_offline_messages(self.ctrl, [oim]) deliver_offline_messages(self.ctrl, [oim])
def on_login_elsewhere(self, option: LoginOption) -> None: def on_login_elsewhere(self, option: LoginOption) -> None:
self.ctrl.logger.info('on_login_elsewhere') self.ctrl.logger.debug('on_login_elsewhere')
self.ctrl.signoff(DISCONNECT_NEW_LOGIN) self.ctrl.signoff(DISCONNECT_NEW_LOGIN)
self.ctrl.close() self.ctrl.close()
return return
@@ -304,16 +304,16 @@ def login(logger: Logger,
if error_code is None and user.suspended: if error_code is None and user.suspended:
error_code = LoginError.Suspended error_code = LoginError.Suspended
logger.info(screen_name, 'tried to sign on but is suspended!') logger.debug(screen_name, 'tried to sign on but is suspended!')
# and check if the user has verified their e-mail address # and check if the user has verified their e-mail address
#if error_code is None and not user.verified_to_login: #if error_code is None and not user.verified_to_login:
# error_code = LoginError.EmailNotVerified # error_code = LoginError.EmailNotVerified
# #
# logger.info(screen_name, 'tried to sign on but has not verified their e-mail address!') # logger.debug(screen_name, 'tried to sign on but has not verified their e-mail address!')
if error_code is None: if error_code is None:
logger.info(screen_name, 'signed on successfully!') logger.debug(screen_name, 'signed on successfully!')
# generate BOS cookie and add it to array # generate BOS cookie and add it to array
client_id_tlv = find_tlv(tlvs, 0x0003) client_id_tlv = find_tlv(tlvs, 0x0003)
+8 -8
View File
@@ -26,7 +26,7 @@ class ChatEventHandler(event.ChatEventHandler):
self._pending = [] self._pending = []
def on_participant_joined(self, cs_other: 'ChatSession', first_pop: bool, initial_join: bool) -> None: def on_participant_joined(self, cs_other: 'ChatSession', first_pop: bool, initial_join: bool) -> None:
self.ctrl.logger.info('on_participant_joined') self.ctrl.logger.debug('on_participant_joined')
still_pending = [] still_pending = []
for (target_uuid, data) in self._pending: for (target_uuid, data) in self._pending:
if cs_other.user.uuid == target_uuid: if cs_other.user.uuid == target_uuid:
@@ -36,7 +36,7 @@ class ChatEventHandler(event.ChatEventHandler):
self._pending = still_pending self._pending = still_pending
def on_participant_left(self, cs_other: 'ChatSession', last_pop: bool) -> None: def on_participant_left(self, cs_other: 'ChatSession', last_pop: bool) -> None:
self.ctrl.logger.info('on_participant_left') self.ctrl.logger.debug('on_participant_left')
# once the other side is gone this chat can't reach them again (they'd be invited to a new one), so it's let go # once the other side is gone this chat can't reach them again (they'd be invited to a new one), so it's let go
if any(cs is not self.cs for cs in self.cs.chat.get_roster()): if any(cs is not self.cs for cs in self.cs.chat.get_roster()):
return return
@@ -49,17 +49,17 @@ class ChatEventHandler(event.ChatEventHandler):
def on_chat_invite_declined(self, chat: 'Chat', invitee: User, *, invitee_id: Optional[str] = None, def on_chat_invite_declined(self, chat: 'Chat', invitee: User, *, invitee_id: Optional[str] = None,
message: Optional[str] = None, circle: bool = False) -> None: message: Optional[str] = None, circle: bool = False) -> None:
self.ctrl.logger.info('on_chat_invite_declined') self.ctrl.logger.debug('on_chat_invite_declined')
def on_chat_updated(self) -> None: def on_chat_updated(self) -> None:
self.ctrl.logger.info('on_chat_updated') self.ctrl.logger.debug('on_chat_updated')
def on_chat_roster_updated(self) -> None: def on_chat_roster_updated(self) -> None:
self.ctrl.logger.info('on_chat_roster_updated') self.ctrl.logger.debug('on_chat_roster_updated')
def on_participant_status_updated(self, cs_other: 'ChatSession', first_pop: bool, initial: bool, def on_participant_status_updated(self, cs_other: 'ChatSession', first_pop: bool, initial: bool,
old_substatus: Substatus) -> None: old_substatus: Substatus) -> None:
self.ctrl.logger.info('on_participant_status_updated') self.ctrl.logger.debug('on_participant_status_updated')
def on_message(self, data: MessageData) -> None: def on_message(self, data: MessageData) -> None:
if data.sender is self.bs.user: if data.sender is self.bs.user:
@@ -72,8 +72,8 @@ class ChatEventHandler(event.ChatEventHandler):
self.ctrl.send_snac(messagedata_to_icbm_event(data, self.bs)) self.ctrl.send_snac(messagedata_to_icbm_event(data, self.bs))
return return
elif data.type is MessageType.Chat: elif data.type is MessageType.Chat:
self.ctrl.logger.info('Got a message from', data.sender.username, 'saying:') self.ctrl.logger.debug('Got a message from', data.sender.username, 'saying:')
self.ctrl.logger.info((data.text or '').encode()) self.ctrl.logger.debug((data.text or '').encode())
# an OSCAR sender's own message cookie travels with the message, so acks and replies line up on both ends; anything # an OSCAR sender's own message cookie travels with the message, so acks and replies line up on both ends; anything
# else gets a fresh one, since clients take a repeated cookie for a repeated message # else gets a fresh one, since clients take a repeated cookie for a repeated message
self.ctrl.send_snac(messagedata_to_icbm(data.front_cache.get('icbm_cookie') or gen_cookie(), data, self.bs)) self.ctrl.send_snac(messagedata_to_icbm(data.front_cache.get('icbm_cookie') or gen_cookie(), data, self.bs))
+1 -1
View File
@@ -211,7 +211,7 @@ def _toc_chat_invite(ctrl, args: list[str]) -> None:
@command('toc_get_info') @command('toc_get_info')
def _toc_get_info(ctrl, args: list[str]) -> None: def _toc_get_info(ctrl, args: list[str]) -> None:
if args: if args:
ctrl.logger.info('[Client] toc_get_info for', args[0], '(no profile service configured)') ctrl.logger.debug('[Client] toc_get_info for', args[0], '(no profile service configured)')
@command('toc_set_info') @command('toc_set_info')
def _toc_set_info(ctrl, args: list[str]) -> None: def _toc_set_info(ctrl, args: list[str]) -> None:
+1 -1
View File
@@ -65,7 +65,7 @@ class TOCCtrl:
handler = COMMANDS.get(parts[0]) handler = COMMANDS.get(parts[0])
if handler is None: if handler is None:
self.logger.info('[Client] Unknown TOC command:', parts[0]) self.logger.debug('[Client] Unknown TOC command:', parts[0])
return return
handler(self, parts[1:]) handler(self, parts[1:])
+1 -1
View File
@@ -69,7 +69,7 @@ class ListenerTOC(asyncio.Protocol):
case 0x05: case 0x05:
pass pass
case _: case _:
self.logger.info('Recieved unknown FLAP channel:', str(channel)) self.logger.debug('Recieved unknown FLAP channel:', str(channel))
self.buffer = self.buffer[length + 6:] self.buffer = self.buffer[length + 6:]
+1 -1
View File
@@ -235,7 +235,7 @@ class YMSGCtrlPager(YMSGCtrlBase):
token = qs['d'][0] token = qs['d'][0]
if not token: if not token:
self.logger.info('Could not extract token from T cookie') self.logger.debug('Could not extract token from T cookie')
authresp_error = int(YMSGStatus.Bad) authresp_error = int(YMSGStatus.Bad)
else: else:
tpl = self.backend.login_auth_service.get_token('ymsg/cookie', token) tpl = self.backend.login_auth_service.get_token('ymsg/cookie', token)
+2 -1
View File
@@ -73,12 +73,13 @@ ENABLE_FRONT_MSIM = False
CF_REALTIME_API_KEY = '' CF_REALTIME_API_KEY = ''
FORCE_HOSTS_UPDATE = False FORCE_HOSTS_UPDATE = False
STRESS_TEST_ACTIVE = False STRESS_TEST_ACTIVE = False
ENABLE_NAT_RELAY = True ENABLE_NAT_RELAY = False
# Frontend-specific settings # Frontend-specific settings
YAHOOHELPER_MSG = "CHANGE ME" YAHOOHELPER_MSG = "CHANGE ME"
YMSG_TOKEN_LIFETIME = 86400 YMSG_TOKEN_LIFETIME = 86400
OSCAR_MOTD_ENABLED = False OSCAR_MOTD_ENABLED = False
OSCAR_MOTD_TEXT = "CHANGE ME"
ICQ_LEGACY_PORT = 4000 ICQ_LEGACY_PORT = 4000
# hand V5 clients each other's IP address and port for direct connections (file transfers, chat); off, it stays private # hand V5 clients each other's IP address and port for direct connections (file transfers, chat); off, it stays private
ICQ_DIRECT_CONNECTIONS = False ICQ_DIRECT_CONNECTIONS = False