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

Initialize saltfilter on demand #189

Merged
merged 4 commits into from
Oct 2, 2020
Merged

Initialize saltfilter on demand #189

merged 4 commits into from
Oct 2, 2020

Conversation

fortuna
Copy link

@fortuna fortuna commented Sep 30, 2020

This fixes the problem of allocating a lot of unnecessary memory on clients.

@fortuna
Copy link
Author

fortuna commented Sep 30, 2020

cc: @alalama @bemasc

@fortuna
Copy link
Author

fortuna commented Sep 30, 2020

@riobard, would you mind reviewing this?

@riobard
Copy link

riobard commented Oct 1, 2020

@fortuna Could you please isolate the singleton use case to the internal package for now? I don't feel comfortable with exporting its implementation details. Ideally all call sites of internal.Add and internal.Test should stay untouched, and you can simply change internal.init to internal.InitFilter and manually initialize the filter somehow.

Maybe we should dump all ENV VARs and make them command line flags instead? Sorry I'm on a road trip right now, please correct me if there's any misunderstanding.

And thanks a lot for this PR! :)

@fortuna
Copy link
Author

fortuna commented Oct 1, 2020

I've restored the original internal interface and reverted all call sites. Does that address your concern?

I didn't change to manual initialization because that may break callers. It's still on-demand.

@fortuna
Copy link
Author

fortuna commented Oct 1, 2020

My view on flags and ENV: those should all live in binaries, not libraries. Libraries should provide ways to inject parameters, so that each caller can tweak to their needs. For example, in outline-ss-server, we inject a salt generator: https://github.com/Jigsaw-Code/outline-ss-server/blob/ac58257355e60b06f8d00d22128a7dd85cbde3e1/shadowsocks/stream.go#L45
This way client and server can behave differently. We actually need that, since the server uses signed salts.

@riobard
Copy link

riobard commented Oct 2, 2020

Let's make the change for now, and I'll think about how to properly fix it once I finish the road trip.

@riobard riobard merged commit 75d4327 into shadowsocks:master Oct 2, 2020
@fortuna
Copy link
Author

fortuna commented Oct 2, 2020

To clarify a point made at #165 (comment), the filter is an issue not only for using the code as a library, but also for the go-shadowsocks2 client. Having replay protection on the client is overkill.

xiahaijiao pushed a commit to xiahaijiao/go-shadowsocks2 that referenced this pull request Jan 10, 2024
Initialize saltfilter on demand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants