> 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.
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:
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:
If we use
io.Copy
to replacebufio
, there will be potential IP truncation and the IP will not be recognized. https://github.com/zu1k/nali/pull/133#issuecomment-1216061342 @mzz2017 mentioned that some kind of cache could be added to solve this. https://github.com/zu1k/nali/pull/133#issuecomment-1216066702If we continue to use
bufio
, we may need to add additional control character scans to solve the cursor jitter problem in tui. https://github.com/zu1k/nali/pull/133#issuecomment-1216067498Maybe we can add an arg like
--mode tui
to specifically be compatible with tui programs like mtr. https://github.com/zu1k/nali/pull/133#issuecomment-1216076370The current scanning method is to splite text by
\n
and\r
characters, but when encountering super-long input without newline characters, nali will freeze. https://github.com/zu1k/nali/pull/133#issuecomment-1216071360