Repository navigation
How to count traffic usage of different users #2011
Description
Activity
Shadowsocks-rust Config
Here is my Shadowsocks-rust config file (desensitized){ "servers": [ { "server": "0.0.0.0", "server_port": 23000, "password": "tCQVWysYldR8D4AkOf4AfGgmy1x9q2yoQJP/qYhjko8=", "method": "2022-blake3-chacha20-poly1305" }, { "server": "0.0.0.0", "server_port": 23001, "password": "BoJ+dzSxqQntCCpsgRGhPHlh4JvzV+m6H4VLf+dU/Ks=", "method": "2022-blake3-chacha20-poly1305" } ] }It seems that Shadowsocks does not support configuring different users on the same port, and no relevant configuration was found (however, this seems to be a requirement of TCP, one port corresponds to one service)
Shadowsocks Manager Config
I don't know why shadowsocks sends stats periodically instead of preparing data and waiting for client requests. This is counterintuitive. I wasted a lot of time because of this.Here is my Shadowsocks-rust entrypoint file
#!/bin/sh apk add jq STATS_FILE='/var/log/shadowsocks/stats' mkdir -p /var/log/shadowsocks echo user-stats-file: /var/log/shadowsocks/stats echo '{}' > ${STATS_FILE} ssserver --manager-addr 127.0.0.1:8080 & while :; do response=`nc -u -w 10 -l -p 8080 | head -n 1 | grep -v timeout ` obj=`echo ${response} | cut -d ':' -f 2- ` jq -c --argjson obj "${obj}" ". + $obj" < ${STATS_FILE} > ${STATS_FILE}.update && mv ${STATS_FILE}.update ${STATS_FILE} done
When you need to request data:
docker compose exec -it shadowsocks cat /var/log/shadowsocks/statsBecause the method of creating a new file is used, it cannot be exposed using --volume (folders can be exposed)
Another strange thing is that I don't know why the data returned every 10 seconds is a certain port, not all. I can't get the latest data in time by writing it this way. I can only merge the data myself.
There is another very strange thing, I don't know why I have to restart the udp server over and over again. If I use the same udp server, I can only get the first data, like this
nc -u -l -p 8080 | xargs -I{} echo {}It seems that Shadowsocks does not support configuring different users on the same port
Use
2022-blake3-aes-128-gcmor2022-blake3-aes-256-gcminstead.#1626 (comment) The REST API should work much better for you.
Related: #1626 .
@database64128 Thanks for your reply.
I also want to ask a question. My judgment is that low-performance devices (mobile phones) use chacha20, and high-performance devices (computers) use aes. Is this true?@JuTemp Prefer AES-based ciphers unless the CPU does not have AES instructions. Modern ARM64 processors have AES instructions, so you'll get higher throughput with lower energy use with AES-GCM compared to ChaCha20-Poly1305.