zu1k / nali

An offline tool for querying IP geographic information and CDN provider. 一个查询IP地理信息和CDN服务提供商的离线终端工具.
https://github.com/zu1k/nali
MIT License
3.76k stars 340 forks source link

Compatible with mtr and possibly other tui programs #134

Open zu1k opened 2 years ago

zu1k commented 2 years ago

This was previously discussed at https://github.com/zu1k/nali/pull/133, we still have some problems with mtr compatibility.

The following content is copied from #133 posted by @mzz2017 :


After the fix PR https://github.com/zu1k/nali/pull/132, we found that in different mtr display modes, nali still has exceptions.

To reproduce it, try:

> mtr baidu.com | nali
# and then press d to switch the display mode

At the beginning, we fixed it by scanning control runes (rune<0x20). Although it fixed the most problems, we found there was also some abnormal cursor jitter.

Finally, we think we shouldn't use bufio because it uses cache to delay reads. We should unblock as soon as the write finish on the other side of the pipe ends, and return the read result, process it and print it on the screen, which is what our PR does.


Currently we have the following problems:

mzz2017 commented 2 years ago

Additional info: We can see linux pipe size by command ulimit -a. By default, it is 8*512byte=4k.