Skip to content
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

Is it possible to precompile for mips and mipsel? #5

Open
christaikobo opened this issue Aug 20, 2022 · 5 comments
Open

Is it possible to precompile for mips and mipsel? #5

christaikobo opened this issue Aug 20, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@christaikobo
Copy link

First of all, thanks for this project, great work!

It seems that the binary files size is quite small.

I am thinking about running these on a router if possible.

@zephyrchien
Copy link
Owner

Unfortunately not, If you need tls support. Because rustls depends on ring, which does not compile on mips.

I'm going to add build options to disable tls support, and add openssl as alternative tls backend.

@zephyrchien zephyrchien added the enhancement New feature or request label Aug 20, 2022
@christaikobo
Copy link
Author

christaikobo commented Aug 20, 2022

Thanks for the swift response!

Also, I am having trouble understanding mask mode, can you please explain quickly the pros and cons of each mode? And, will mask mode be compatible with v2ray-plugin client? Thank you!

@zephyrchien
Copy link
Owner

A websocket client will mask(xor) its data with a 32bit key, and send the key together with data. The receiver(server/middleware) will obtain the key, and unmask(xor) the data.

mode here only affects how the masking key is generated, so theorily kaminaric could communicate with any other websocket server, whatever mode you use.

According to rfc6455,

When preparing a masked frame, the client MUST pick a fresh masking
key from the set of allowed 32-bit values. The masking key needs to
be unpredictable; thus, the masking key MUST be derived from a strong
source of entropy, and the masking key for a given frame MUST NOT
make it simple for a server/proxy to predict the masking key for a
subsequent frame.

Please consider mode=standard as standard bahavior.

For mode=fix, the key will not be regenerated unless there comes another connection, so that a few CPU cycles could be saved(this is meaningless, tbh), please do not use this mode.

For mode=skip, it is a dirty(?) hack invented by me. With a key = 0x00..0(32bit), the mask(xor) operation does nothing, and could be skipped. Our server(kaminaris) will also skip unmasking when receiving an empty key. Other servers will do xor
(data, 0x00..0) as normal
, which leads to the same result but costs more CPU cycles.

In conclusion, if you prefer a more standard implementation, please use mode=standard; if you prefer performance, please use mode=skip. I personally prefer the later, this is why I set it as the default mode.

@zephyrchien
Copy link
Owner

On the other hand, when I was developing lightws, the underlying library of kaminari, which implements the websocket protocol(rfc6455) at the beginning there was only mode=skip, while mode=fix and mode=standard are added later.

The main reason is that the Write trait takes an immutable buffer reference, where there is no way to mask it unless I bring in some unsafe code which will break rust's borrowing rules and should be carefully used. The clever solution is simply skip this step:). For more implementation details, read lightws's document, if you are interested.

@christaikobo
Copy link
Author

Wow, really appreciate the detailed explanation!

So I guess there is not much of a difference in terms of circumventing censorship between mask modes. It is really just down to implementing rfc6455.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants