Skip to content

Commit 0a513dc

Browse files
committed
explain the statusbar + fix 3 bugs:
* wizard got stuck confirming previous config if only telnet or nc * join_priv_chan loaded the status channel in a way that caused hilights * pushworker could die because a client's active chan was not present in user.chans; nice symptom of a race somewhere orz (fixed at least one of them where /part could skip unsetting old_active_chan and /a tried to jump back into it; maybe that was it)
1 parent 14b27fe commit 0a513dc

8 files changed

Lines changed: 66 additions & 18 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ technical:
4141
* message input with readline-like editing (arrow-left/right, home/end, backspace)
4242
* history of sent messages (arrow-up/down)
4343
* bandwidth-conservative (push/pop lines instead of full redraws; scroll-regions)
44-
* fast enough; 1'000 clients @ 700 msgs/sec
44+
* fast enough; 600 clients @ 750 msgs/sec, or 1'000 cli @ 350 msg/s
4545

4646
## windows clients
4747

@@ -74,6 +74,7 @@ if you enable TLS with `-tpt 2424` (telnet) and/or `-tpn 1515` (netcat) you can
7474

7575
* `telnet-ssl -zssl -zsecure -zcacert=r0c.crt r0c.int 2424`
7676
* `socat -,raw,echo=0 openssl:r0c.int:1515,cafile=cert.crt`
77+
* `socat -,raw,echo=0 openssl:127.0.0.1:1515,verify=0`
7778
* `stty -icanon; ncat --ssl --ssl-trustfile r0c.crt -v r0c.int 1515`
7879
* `stty -icanon; openssl s_client -CAfile ~/.r0c/cert.crt -nbio -connect r0c.int:1515`
7980
* windows: [powershell client](https://github.com/9001/r0c/blob/master/clients/powershell.ps1) with port `+1515` (the `+` enables TLS)
@@ -129,7 +130,7 @@ iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 531 -j REDIRECT --to-port 1
129130

130131
# documentation
131132

132-
not really but there is a [list of commands](docs/help-commands.md) and a [list of hotkeys](docs/help-hotkeys.md)
133+
not really but there is a [list of commands](docs/help-commands.md) and a [list of hotkeys](docs/help-hotkeys.md), and also [UI demystified](docs/help-ui.md)
133134

134135
## protips
135136

docs/help-topics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
|-|-|
44
| `/help intro` | the quickstart guide
55
| `/help about` | about r0c
6+
| `/help ui` | user interface
67
| `/help commands` | list of commands
78
| `/help hotkeys` | list of hotkeys

docs/help-ui.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# the statusbar
2+
3+
was loosely inspired by irssi and looks something like this:
4+
5+
`192939 1: #g(5) h:2 a:2,3 ed, ned, ame, same, sam`
6+
7+
* according to the server, the UTC time is `19:29:39`
8+
9+
* you are in window `1` (the first channel you joined), which is channel `#g`, which has `5` users
10+
11+
* `h:2` you were hilighted (your name was mentioned) in window `2`; use the command **`/2`** or just press **`CTRL-E`** which takes you to the channel with the most important happening
12+
13+
* `a:2,3` activity in windows `2` and `3` which you haven't seen
14+
15+
* the 5 users in `#g`, sorted by when they last said soemthing

r0c/chat.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ def __init__(self, user, nchan, alias=None):
7373
self.lock_to_bottom = True
7474
self.vis = [] # type: list[VisMessage] # visible messages
7575

76+
def __unicode__(self):
77+
return u"UChannel <%s> @ <%s>" % (self.user, self.nchan)
78+
79+
def __str__(self):
80+
return "UChannel <%s> @ <%s>" % (self.user, self.nchan)
81+
82+
def __repr__(self):
83+
return "UChannel(%r, %r, %r)" % (self.user, self.nchan, self.alias)
84+
7685
def update_activity_flags(self, set_last_read=False, last_nchan_msg=0):
7786
if not last_nchan_msg and self.nchan.msgs:
7887
last_nchan_msg = self.nchan.msgs[-1].sno

r0c/ivt100.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,22 @@ def delayed_drop():
841841
# switch to new channel,
842842
# storing the last viewed message for notification purposes
843843
if self.user.new_active_chan:
844+
usr = self.user
845+
if usr.new_active_chan not in usr.chans:
846+
t = "new_active_chan (%s) not in user.chans (%s |%d|)"
847+
Util.whoops(t % (usr.new_active_chan, usr, len(usr.chans)))
848+
usr.new_active_chan = usr.chans[0]
849+
844850
if self.user.active_chan:
845851
self.user.active_chan.update_activity_flags(True)
846852

847-
self.user.old_active_chan = self.user.active_chan
853+
# print(" /w: %s %s" % (usr.active_chan, usr.new_active_chan))
854+
855+
if usr.active_chan in usr.chans:
856+
usr.old_active_chan = usr.active_chan
857+
else:
858+
usr.old_active_chan = None
859+
848860
self.user.active_chan = self.user.new_active_chan
849861
self.user.active_chan.update_activity_flags(True)
850862
self.user.new_active_chan = None
@@ -2169,7 +2181,9 @@ def conf_wizard(self, growth):
21692181

21702182
elif u"n" in text:
21712183
self.default_config()
2184+
old_nick = self.user.nick
21722185
self.user.set_rand_nick()
2186+
print(" regen nick: %s %s" % (old_nick, self.user.nick))
21732187
if not self.check_correct_iface("qwer_prompt"):
21742188
return
21752189

@@ -2599,11 +2613,9 @@ def u8(tx):
25992613
self.world.cserial += 1
26002614

26012615
def check_correct_iface(self, next_stage):
2602-
if not self.host.other_if:
2603-
return True
2604-
26052616
self.wizard_stage = next_stage
2606-
if self.iface_confirmed:
2617+
2618+
if self.iface_confirmed or not self.host.other_if:
26072619
return True
26082620

26092621
self.iface_confirmed = True

r0c/user.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ def exec_cmd(self, cmd_str):
385385
)
386386
return
387387

388+
print(" join: %s %s" % (arg, self.nick))
388389
nchan = self.world.join_pub_chan(self, arg[1:]).nchan
389390
# this is in charge of activating the new channel,
390391
# rapid part/join will crash us without this
@@ -401,6 +402,9 @@ def exec_cmd(self, cmd_str):
401402
)
402403
return
403404

405+
ac = self.active_chan
406+
ch_name = "#" + ac.nchan.name if ac.nchan.name else ac.alias
407+
print(" part: %s %s" % (ch_name, self.nick))
404408
self.world.part_chan(self.active_chan)
405409
# this is in charge of activating the new channel,
406410
# rapid part/join will crash us without this
@@ -447,6 +451,7 @@ def exec_cmd(self, cmd_str):
447451
)
448452
return
449453

454+
print(" /msg: %s %s" % (self.nick, arg1))
450455
uchan = self.world.join_priv_chan(self, arg1)
451456
self.new_active_chan = uchan
452457
self.world.send_chan_msg(self.nick, uchan.nchan, arg2)
@@ -625,6 +630,12 @@ def exec_cmd(self, cmd_str):
625630
# self.new_active_chan.nchan.get_name()))
626631
else:
627632
print("cannot jump, no hilights or prev chan")
633+
return
634+
635+
if self.new_active_chan not in self.chans:
636+
t = "/a tried to new_active_chan (%s) not in self.chans (%s |%d|)"
637+
Util.whoops(t % (self.new_active_chan, self, len(self.chans)))
638+
self.new_active_chan = self.chans[0]
628639

629640
self.client.need_full_redraw = True
630641
self.client.refresh(False)
@@ -813,18 +824,16 @@ def exec_cmd(self, cmd_str):
813824
self.client.save_config()
814825

815826
elif cmd == u"ey":
827+
t = u"Hilight on @all / @everyone enabled. Disable with /en"
816828
self.client.atall = True
817-
self.world.send_chan_msg(
818-
u"--", inf, u"Hilight on @all / @everyone enabled. Disable with /en", False
819-
)
829+
self.world.send_chan_msg(u"--", inf, t, False)
820830
self.build_nick_re()
821831
self.client.save_config()
822832

823833
elif cmd == u"en":
834+
t = u"Hilight on @all / @everyone disabled. Enable with /en"
824835
self.client.atall = False
825-
self.world.send_chan_msg(
826-
u"--", inf, u"Hilight on @all / @everyone disabled. Enable with /en", False
827-
)
836+
self.world.send_chan_msg(u"--", inf, t, False)
828837
self.build_nick_re()
829838
self.client.save_config()
830839

r0c/world.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ def join_priv_chan(self, user, alias):
296296
if uchan is None:
297297
nchan = Chat.NChannel(None, u"DM with [[uch_a]]")
298298
self.priv_ch.append(nchan)
299-
uchan = self.join_chan_obj(user, nchan)
300-
uchan.alias = alias
299+
uchan = self.join_chan_obj(user, nchan, alias)
301300
return uchan
302301

303302
"""

test/stress.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
#
3030

3131
NUM_CLIENTS = 1
32-
NUM_CLIENTS = 320
32+
NUM_CLIENTS = 512
3333
NUM_PER_MPW = 32
3434

3535
# CHANNELS = ['#1']
3636
CHANNELS = ["#1", "#2", "#3", "#4"]
3737

3838
EVENT_DELAY = 0.01
3939
EVENT_DELAY = 0.005
40-
EVENT_DELAY = 1
40+
EVENT_DELAY = 3
4141
# EVENT_DELAY = None
4242

4343
ITERATIONS = 1000000
@@ -380,6 +380,7 @@ def jump_channels(self):
380380
chance = [10, 5, 4, 18]
381381
chance = [10, 3, 2, 30]
382382
chance = [10, 30, 2, 130]
383+
chance = [10, 30, 2, 330]
383384

384385
for n in range(len(chance) - 1):
385386
chance[n + 1] += chance[n]
@@ -657,6 +658,7 @@ def __init__(self, port, behavior, cmd_q, stat_q, n1):
657658
n = NUM_PER_MPW * n1 + n2
658659
c = Client(self, self.port, self.behavior, stat_q, n)
659660
self.clients.append(c)
661+
time.sleep(0.2)
660662

661663
def run(self):
662664
while self.cmd_q.empty():
@@ -761,6 +763,6 @@ def signal_handler(self, signal, frame):
761763

762764

763765
# (1x) rm -rf log/chan/{1,2,3,4,a} log/pm/ && timeout 110 python3 -u -m r0c --bench | tee bench
764-
# (3x) cd ~/dev/r0c/test/ && ./run-stress.sh 2323
766+
# (2x) cd ~/dev/r0c/test/ && ./run-stress.sh 2323
765767
# grep -E '^[0-9]{6} [0-9]{9}' bench
766768
# ps auxwww | awk '/python3[ ]stress.py[ ]2323/{print$2}' | xargs kill

0 commit comments

Comments
 (0)