irc: Add special case localhost for hostname
patch 6a0451271e91ed7c081a631b49780c0f3ed761e7
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat Feb 12 03:02:43 CET 2022
* irc: Add special case localhost for hostname
use FQDN if possible instead of simple hostname
hunk ./irc.py 52
- self.hostname = socket.gethostname()
+ self.hostname = socket.getfqdn()
hunk ./irc.py 289
- if not target or target == self.hostname:
+ if not target or target == self.gethostname(user):
hunk ./irc.py 304
- await self.reply_command(user, SRV, 'PONG', (self.hostname, payload))
+ await self.reply_command(user, SRV, 'PONG', (self.gethostname(user), payload))
hunk ./irc.py 323
- usr.address, self.hostname, usr.irc_nick, op, usr.irc_realname
+ usr.address, self.gethostname(user), usr.irc_nick, op, usr.irc_realname
hunk ./irc.py 335
- await self.reply_code(user, 'RPL_WHOISSERVER', (real_ni, self.hostname))
+ await self.reply_code(user, 'RPL_WHOISSERVER', (real_ni, self.gethostname(user)))
hunk ./irc.py 349
- server = self.hostname if usr.stream else 'Telegram'
+ server = self.gethostname(user) if usr.stream else 'Telegram'
hunk ./irc.py 359
- if not tgt or tgt == self.hostname or tgt in self.users.keys():
- await self.reply_code(user, 'RPL_VERSION', (VERSION, self.hostname))
+ if not tgt or tgt == self.gethostname(user) or tgt in self.users.keys():
+ await self.reply_code(user, 'RPL_VERSION', (VERSION, self.gethostname(user)))
hunk ./irc.py 432
- prefix = self.hostname if prfx == SRV else prfx.get_irc_mask()
+ prefix = self.gethostname(user) if prfx == SRV else prfx.get_irc_mask()
hunk ./irc.py 445
- stri = ':{} {} {} {}'.format(self.hostname, num, nick, rest)
+ stri = ':{} {} {} {}'.format(self.gethostname(user), num, nick, rest)
hunk ./irc.py 447
- stri = ':{} {} {} :{}'.format(self.hostname, num, user.irc_nick, tail)
+ stri = ':{} {} {} :{}'.format(self.gethostname(user), num, user.irc_nick, tail)
hunk ./irc.py 452
- await self.reply_code(user, 'RPL_YOURHOST', (self.hostname, VERSION))
+ await self.reply_code(user, 'RPL_YOURHOST', (self.gethostname(user), VERSION))
hunk ./irc.py 454
- await self.reply_code(user, 'RPL_MYINFO', (self.hostname, VERSION))
+ await self.reply_code(user, 'RPL_MYINFO', (self.gethostname(user), VERSION))
hunk ./irc.py 460
- await self.reply_code(user, 'RPL_MOTDSTART', (self.hostname,))
+ await self.reply_code(user, 'RPL_MOTDSTART', (self.gethostname(user),))
hunk ./irc.py 567
+ def gethostname(self, user):
+ return 'localhost' if user.from_localhost else self.hostname
+
hunk ./irc.py 574
+ self.from_localhost = True if address[0].split('.')[0] == '127' else False