shadowsocks/shadowsocks-restful-api

Traffic for single port?

jibon57 opened this issue · 9 comments

Thanks for you great work :). How to get traffic for single port instated of calling for all?

Thanks for your question. There is no api for getting traffic of a single port.

I cannot think of a use scenario for this api. You can always get traffic for a port from the traffic for all ports.

Would you please justify the need for such an api?

If there is a valid reason to show the necessity of such an api, I am happy to add it.

@Eggham thanks for your reply. Actually I am creating a component for Joomla using this API. I want to show traffic usage for each user when they will access their panel. At present I will need to call all the ports' traffic but need only one. I know it's possible to run in a loop to get that particular port but will be better if can get for single.

@jibon57 Thanks for your reply. The traffic data provided by the shadowsocks-restful-api is retrieved from shadowsocks-libev. The traffic data does not survive shadowsocks-libev restart. Hence it is recommended to write some logic at a higher level to persist the data into a database and let user request from the database.

You may try shadowsocks-hub or shadowsocks-hub-api.

@Eggham thanks again for response. Actually I want to use this one for Joomla & that one already has DB feature.

The traffic data provided by the shadowsocks-restful-api is retrieved from shadowsocks-libev

That mean I will need to create some cron job to retrieve the traffic from shadowsocks & update the DB... right?

@Eggham, Another question. If I use shadowsocks-hub-api, what will be happen if user cross the bandwidth limit? Will they get disconnected?

@jibon57 Yes. If a user's total usage across all accounts from a product is greater than the traffic specified in the product, then all the accounts will get disconnected and deleted.

That mean I will need to create some cron job to retrieve the traffic from shadowsocks & update the DB... right?

That's right. You should periodically retrieve traffic for all ports from shadowsocks-restful-api and update the database (e.g. once a few minutes). Otherwise, you may loose some traffic data.

Thanks @Eggham for your suggestions. I have created one component for Joomla. You are welcome to check it out ;) from here: https://github.com/jibon57/com_shadowsocks

@jibon57 Interesting! I will take some time to have a close look. Thank you!