-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: we should not use bufio and to keep read and write behavior consistent #133
Conversation
Does this cause an IP to be split into two processing so that it cannot be identified? |
I do not know the application scenarios that print the half of an IP and then print the remain later. |
|
I generate a random txt file with (32*1024-2) bytes, then append 2 IPs.
We can see the first IP |
tr -dc A-Za-z0-9 </dev/urandom | head -c 32766 > a.txt
echo "" >> a.txt
echo 1.2.3.4 >> a.txt
echo 5.6.7.8 >> a.txt
cat a.txt | ./nali |
I knew this problem. Golang use 4KB buffer to read from the file descriptor, and it is reasonable. If you insist on it, we can cache several bytes for the next read. |
Confirmed that this issue also exists in the nodejs version (nali-cli), since the nodejs version uses a similar implementation. |
Full domain has a 253 chars limit. IPv4 has 4 chars and IPv6 16 chars. |
Or if you do not consider about the performance, we can also fallback to scan control chars. |
Looks like mtr using tui causes these issues, tui is not suitable to be piped, so I think it is a better choice to add a display method suitable for pipe to mtr. |
If we scan control chars, there is another problem. If the input program does not print the control char (like \r, \n and EOF), we will block on it. |
This is the desired behavior, as if grep would do the same. |
We all know grep scans rows. So it works as expected. |
nali is designed to scan lines too. |
OK. nodejs nali-cli performs as this PR. I think an argument is better, right? |
I think maybe we can add a param to specifically compatible with tui. |
It is not easy to handle tui. In addition to various control characters, it is also necessary to consider whether the original structure will be destroyed, especially some components of tui originally limited the length, and adding ip geo info will cause dislocation. |
What do you think about that I would try to fix the problem mentioned above by cache strategy. And we can see if it will be acceptable. |
You are right. We can only try to do it. It cannot be perfect. |
Or you can describe your caching strategy first, and we can first discuss whether it will introduce other issues, then we make a decision. |
It's pleasure to discuss with you. What about tonight? Sorry for that I have something to do now. |
I wonder if the cursor jitter you described earlier are caused by a |
I will check the email notification regularly, you can discuss at any time, this is unlimited. |
I will create an issue, let's discuss there, so that others can search and participate. |
I will close this for long time no reply, if there are new developments, please discuss them in the issue. |
After the fix PR #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.Thanks co-debbuger @cubercsl