-
Notifications
You must be signed in to change notification settings - Fork 557
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
Proposal: Multi-user support in Shadowsocks protocol #128
Comments
I don't think Previous discussions suggest that we do authentication on the first chunk with different keys, to identify the user based on the success key. As long as you don't need to support thousands of users on one port, this approach should work well without modifying the protocol. One possible optimization is also discussed before that we can cache the success key for the source IP, which would save most of computation. To prevent potential DDOS attack, the IP tries too many times with authentication failure should be blocked. |
Embedding
I believe it is common to support thousands of users on a single server for commercial use. |
I think that's exactly what we'd like to avoid from the very beginning. It makes no sense to provide commercial service based on shadowsocks. And unfortunately it's illegal in some place. 😞 BTW, @fortuna from Jigsaw is trying the similar authentication based multi-user-single-port idea here: https://github.com/fortuna/ss-example/blob/master/server.go#L40. With the optimization mentioned above, even thousands of active users should not be a problem. |
The code currently at https://github.com/fortuna/ss-example is a prototype. In practice, I haven't seen any issues as is with a small number of users. It's still unclear to me what the overhead will be with over 100 or 1000 users. But I can see how that can be a problem and a cache just like @madeye proposed should be good enough. |
FYI, my experimental server is now at https://github.com/Jigsaw-Code/outline-ss-server and supports any combination of user and port, in a config-driven way. It's backward-compatible: existing clients can connect to it just fine. It runs one process on the server, and can be updated with SIGHUP without interrupting existing connections. I haven't implemented the suggested optimizations yet, but in a server with 100 access keys I did not find the the cipher finding to have a significant impact on performance (worst case 10-20ms extra connection time). |
Background
Shadowsocks protocol doesn't support multi-user as designed. To support multi-user on a single port, a naive approach on Shadowsocks server is to try to decode the incoming connection with all users' key, until one key succeeds. This way is quite time consuming when user base is large.
Here is a proposal to balance server work load and compatibility of existing protocol.
Proposal
A: Define UserID as uint16, which can be serialized into a two-byte sequence.
B: Define a function fa(user)=>UserID. fa should generate an unique UserID for each user, but collision may be accepted.
C: When SS client generates IV (salt) for a connection, say byte[0...31]:
D: When SS server receives an incoming connection. It tries to decode IV with the same fb.
Advantage
Disadvantage
Suggested Functions
The text was updated successfully, but these errors were encountered: