sorz / moproxy

A transparent TCP to SOCKSv5/HTTP proxy on Linux written in Rust.
MIT License
223 stars 35 forks source link

Idea: text/plain output for lynx/curl #3

Closed ryanerwin closed 4 years ago

ryanerwin commented 5 years ago

It's great that I can run keep a tab open with the current moproxy status, but it would be even better to easily grab to optionally grab this status from the command line.

When you look at this window: image

Most of the same output would make sense in the console. Perhaps if the User-agent is Lynx or Curl, you could just output the same chart in plain text, and if we want to keep it refreshed, we can just run watch it whenever we start to see problems.

sorz commented 5 years ago

Done. It will output plaintext if the user-agent is curl/lynx, or the Accept header is text/plain. I'd say that it's a pleasure to run & watch the watch curl -s! Thanks.

ryanerwin commented 5 years ago

Awesome! This is fantastic!

 ❯ curl -s http://localhost:8080
 moproxy (0.2.5) is running. 14s
 ↑ 0 bps ↓ 0 bps
 +-------------------------+-------+---------+-----+-----+----+------+----+
 | Server                  | Score | Delay   | CUR | TTL | Up | Down | ↑↓ |
 | Server1-Hong-Kong       |   784 |  784 ms |   0 |   0 |    |      |    |
 | Server2-Singapore       |   938 |  938 ms |   0 |   0 |    |      |    |
 | Server3-Singapore       |  1655 | 1655 ms |   0 |   0 |    |      |    |
 | Server4-Tokyo           |     - |       - |   0 |   0 |    |      |    |
 +-------------------------+-------+---------+-----+-----+----+------+----+

(note I manually changed the server names in vim before posting, thus the extra spacing)

BTW, Sorry to get way off topic but I've been debating learning golang or rust... I see this is implemented in rust so I'm assuming you recommend rust. Long ago I wrote a lot of Perl and later Ruby, and a lot of shell scripts, but always wanted to learn a really fast compiled language. I dabbled in Java but didn't enjoy something so verbose... What are the best books or tutorials that you read about Rust?

sorz commented 5 years ago

The book and Rust by Example? Their official tutorials & document are pretty good.