forked from fortuna/ss-example
-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat(caddy): persist replay cache across config reloads #212
Merged
Merged
Changes from all commits
Commits
Show all changes
221 commits
Select commit
Hold shift + click to select a range
1b82d33
Create a new config format so we can expand listener configuration fo…
sbruens a4c2007
Remove unused `fakeAddr`.
sbruens 72b27d7
Split `startPort` up between TCP and UDP.
sbruens fddfc57
Use listeners to configure TCP and/or UDP services as needed.
sbruens c1ee12f
Remove commented out line.
sbruens 354301e
Use `ElementsMatch` to compare the services irrespective of element o…
sbruens 751d164
Do not ignore the `keys` field if `services` is used as well.
sbruens 6297304
Add some more tests for failure scenarios and empty files.
sbruens 0ac0a72
Remove unused `GetPort()`.
sbruens 794f860
Move `ResolveAddr` to config.go.
sbruens 01b7e8a
Remove use of `net.Addr` type.
sbruens 87a1565
Pull listener creation into its own function.
sbruens 51a13a7
Move listener validation/creation to `config.go`.
sbruens f8d7aa5
Use a custom type for listener type.
sbruens 1952036
Fix accept handler.
sbruens 7212265
Add doc comment.
sbruens 6e2068d
Fix tests still supplying the port.
sbruens 7114434
Move old config parsing to `loadConfig`.
sbruens 1b2dd42
Lowercase `readConfig`.
sbruens 4ce06f0
Use `Config` suffix for config types.
sbruens 8660032
Remove the IP version specifiers from the `newListener` config handling.
sbruens 26b9100
refactor: remove use of port in proving metric
sbruens 1b8e903
Fix tests.
sbruens 442b927
Merge branch 'sbruens/absorb-port' into sbruens/proxy
sbruens 4216ce3
Add a TODO comment to allow short-form direct listener config.
sbruens 35c828d
Make legacy key config name consistent with type.
sbruens 1322f2d
Move config validation out of the `loadConfig` function.
sbruens adc11f2
Remove unused port from bad merge.
sbruens 3084dfd
Add comment describing keys.
sbruens 7e5aae5
Move validation of listeners to config's `Validate()` function.
sbruens b136c79
Introduce a `NetworkAdd` to centralize parsing and creation of listen…
sbruens 4bf9c27
Use `net.ListenConfig` to listen.
sbruens b7bb65b
Simplify how we create new listeners.
sbruens af3ca31
Do not use `io.Closer`.
sbruens fc72593
Use an inline error check.
sbruens b24a339
Use shared listeners and packet connections.
sbruens 3bc76bc
Close existing listeners once the new ones are serving.
sbruens f71b13d
Elevate failure to stop listeners to `ERROR` level.
sbruens 6893e2a
Merge remote-tracking branch 'origin/master' into sbruens/proxy
sbruens 32cc180
Be more lenient in config validation to allow empty listeners or keys.
sbruens 640f80f
Ensure the address is an IP address.
sbruens 22638c7
Use `yaml.v3`.
sbruens 2631b87
Move file reading back to `main.go`.
sbruens d76efd2
Do not embed the `net.Listener` type.
sbruens b8c5ab8
Use a `Service` object to abstract away some of the complex logic of …
sbruens 5ac0f46
Fix how we deal with legacy services.
sbruens 1f097be
Remove commented out lines.
sbruens 80b25b1
Use `tcp` and `udp` types for direct listeners.
sbruens 2070d40
Use a `ListenerManager` instead of globals to manage listener state.
sbruens eacfa0e
Add validation check that no two services have the same listener.
sbruens dc1075a
Use channels to notify shared listeners they need to stop acceoting.
sbruens 2a343e2
Pass TCP timeout to service.
sbruens e58b79d
Move go routine call up.
sbruens c7465fb
Allow inserting single elements directly into the cipher list.
sbruens 43fa0d6
Add the concept of a listener set to track existing listeners and clo…
sbruens cf9b7d2
Refactor how we create listeners.
sbruens ae7f41d
Update comments.
sbruens 120db8e
`go mod tidy`.
sbruens 5cbeb54
Merge branch 'sbruens/shared-listeners' into sbruens/proxy
sbruens d705603
refactor: don't link the TCP handler to a specific listener
sbruens 2fb4a6b
Merge branch 'sbruens/remove-listener-dependency' into sbruens/shared…
sbruens d2ef46e
Protect new cipher handling methods with mutex.
sbruens ab07400
Move `listeners.go` under `/service`.
sbruens 71d7140
Use callback instead of passing in key and manager.
sbruens 9dfa4e2
Move config start into a go routine for easier cleanup.
sbruens 0a63f5c
Make a `StreamListener` type.
sbruens f018d17
Rename `closeFunc` to `onCloseFunc`.
sbruens 4295c45
Rename `globalListener`.
sbruens e6963f6
Don't track usage in the shared listeners.
sbruens 7113f02
Add `getAddr()` to avoid some duplicate code.
sbruens e4d679f
Move listener set creation out of the inner function.
sbruens be5f9b0
Remove `PushBack()` from `CipherList`.
sbruens 343e412
Move listener set to `main.go`.
sbruens 7f86ff1
Close the accept channel with an atomic value.
sbruens e80b2c5
Update comment.
sbruens b1428ed
Address review comments.
sbruens 1c16de8
Close before deleting key.
sbruens ebc7053
`server.Stop()` does not return a value
sbruens 67fc7fb
Add a comment for `StreamListener`.
sbruens 7a15e7d
Do not delete the listener from the manager until the last user has c…
sbruens 499829e
Consolidate usage counting inside a `listenAddress` type.
sbruens f165dbd
Remove `atomic.Value`.
sbruens 2a2420a
Add some missing comments.
sbruens 8178d78
Merge branch 'master' into sbruens/shared-listeners
sbruens cccba1a
address review comments
sbruens da4ccaa
Add type guard for `sharedListener`.
sbruens d47f612
Stop the existing config in a goroutine.
sbruens a928e2c
Add a TODO to wait for all handlers to be stopped.
sbruens 98cc3a0
Run `stopConfig` in a goroutine in `Stop()` as well.
sbruens 48d0931
Create a `TCPListener` that implements a `StreamListener`.
sbruens 2dec847
Track close functions instead of the entire listener, which is not ne…
sbruens ab22e47
Delegate usage tracking to a reference counter.
sbruens 3c2a3ef
Remove the `Get()` method from `refCount`.
sbruens 5e282f1
Return immediately.
sbruens 547e9e6
Rename `shared` to `virtual` as they are not actually shared.
sbruens c6774c8
Simplify `listenAddr`.
sbruens df2f9d0
Fix use of the ref count.
sbruens c678372
Add simple test case for early closing of stream listener.
sbruens e41abab
Add tests for creating stream listeners.
sbruens b626a1c
Merge branch 'sbruens/shared-listeners' into sbruens/proxy
sbruens f9432d2
Create handlers on demand.
sbruens 6b11f4f
Refactor create methods.
sbruens 3e03394
Merge branch 'sbruens/shared-listeners' into sbruens/proxy
sbruens fe8bbdd
Address review comments.
sbruens 36a0a1d
Use a mutex to ensure another user doesn't acquire a new closer while…
sbruens aeb2652
Move mutex up.
sbruens 8873b10
Manage the ref counting next to the listener creation.
sbruens 899d13d
Do the lazy initialization inside an anonymous function.
sbruens 80e5d49
Fix concurrent access to `acceptCh` and `closeCh`.
sbruens aa00f2e
Use `/` in key instead of `-`.
sbruens e658b90
Return error from stopping listeners.
sbruens fede4d8
Use channels to ensure `virtualPacketConn`s get closed.
sbruens 4730d74
Add more test cases for packet listeners.
sbruens 30bbdfa
Merge branch 'sbruens/shared-listeners' into sbruens/proxy
sbruens 458cf41
Only log errors from stopping old configs.
sbruens 81bf20e
Remove the `closed` field from the virtual listeners.
sbruens 53b1e96
Remove the `RefCount`.
sbruens 8f9f1ea
Implement channel-based packet read for virtual connections.
sbruens 1ac265d
Use a done channel.
sbruens f5afdcb
Merge branch 'sbruens/shared-listeners' into sbruens/proxy
sbruens 1538a9a
Set listeners and `onCloseFunc`'s to nil when closing.
sbruens 4df0b9f
Set `onCloseFunc`'s to nil when closing.
sbruens 16feaf9
Fix race condition.
sbruens 288b88b
Add some benchmarks for listener manager.
sbruens de64b8a
Add structure logging with `slog`.
sbruens 38602b5
Structure forgotten log.
sbruens 56c7b11
Another forgotten log.
sbruens 27e28c7
Remove IPInfo logic from TCP and UDP handling into the metrics collec…
sbruens 8df1dd3
Refactor metrics into separate collectors.
sbruens e6334e1
Rename some types to remove `Collector` suffix.
sbruens 1565ab5
Use an LRU cache to manage the ipInfos for Prometheus metrics.
sbruens d80ba6a
Use `nil` instead of `context.TODO()`.
sbruens 30a285e
Use `LogAttrs` for `debug...()` log functions.
sbruens 2748d55
Merge branch 'sbruens/slog' into sbruens/metrics
sbruens 5233167
Update logging in `metrics.go`.
sbruens 2f5077e
Merge branch 'master' into sbruens/metrics
sbruens feb30b6
Fix another race condition.
sbruens b74f5a0
Revert renaming.
sbruens dcc99f6
Replace LRU cache with a simpler map that expires unused items.
sbruens 26c4624
Move `SetBuildInfo()` call up.
sbruens 80fe8d3
refactor: change `outlineMetrics` to implement the `prometheus.Collec…
sbruens 18ad469
Merge branch 'sbruens/prom-collectors' into sbruens/metrics
sbruens d688dd9
Merge branch 'master' into sbruens/shared-listeners
sbruens c702159
Merge branch 'sbruens/shared-listeners' into sbruens/proxy
sbruens e509d86
Address review comments.
sbruens 2c57ad3
Merge branch 'sbruens/prom-collectors' into sbruens/metrics
sbruens 9399e95
Refactor collectors so the connections/associations keep track of the…
sbruens 573d5f2
Merge branch 'master' into sbruens/prom-collectors
sbruens c7df66d
Merge branch 'sbruens/prom-collectors' into sbruens/metrics
sbruens dcc47cf
Address review comments.
sbruens f7fb25d
Make metrics interfaces for bytes consistently use `int64`.
sbruens e9739b8
Merge branch 'master' into sbruens/proxy
sbruens cf5a676
Add license header.
sbruens 0a8fbd0
Merge branch 'master' into sbruens/metrics
sbruens 3becca2
Merge branch 'master' into sbruens/proxy
sbruens c5937b5
Merge branch 'sbruens/metrics' into sbruens/caddy2
sbruens 0e55a6f
Support multi-module workspaces so we can develop Caddy and ss-server…
sbruens 74d3c67
Rename `Collector` to `Metrics`.
sbruens 3b02104
Merge branch 'sbruens/metrics' into sbruens/caddy2
sbruens 0f12feb
Merge branch 'master' into sbruens/caddy2
sbruens 7c061e4
Move service creation into the service package so it can be re-used b…
sbruens 76e320e
Ignore custom Caddy binary.
sbruens 469a18b
Merge branch 'master' into sbruens/caddy
sbruens e80ccc3
refactor: create re-usable service that can be re-used by Caddy
sbruens 6e330fa
Remove need to return errors in opt functions.
sbruens 2738b45
Move the service into `shadowsocks.go`.
sbruens 2270f6c
Merge branch 'sbruens/service' into sbruens/caddy
sbruens 8935465
Add Caddy module with app and handler.
sbruens 2073a27
Refactor metrics to not share with Caddy.
sbruens 0dfafcb
Set Prometheus metrics handler.
sbruens e2cc62f
Catch already registered collectors instead of using `once.Sync`.
sbruens 654e0e9
refactor: pass in logger to service so caller can control logs
sbruens 3b6c873
Merge branch 'sbruens/logger' into sbruens/caddy
sbruens be43e84
Fix test.
sbruens bca42a0
Add `--watch` flag to README.
sbruens 62206c8
Remove changes moved to another PR.
sbruens d284612
Remove arguments from `Logger()`.
sbruens 04faca2
Use `slog` instead of `zap`.
sbruens 46e2f66
Log error in `Provision()` instead of `defineMetrics()`.
sbruens a32378e
Do not panic on bad metrics registrations.
sbruens f2b1b6f
Check if the cast to `OutlineApp` is ok.
sbruens ac98ed9
Remove `version` from the config.
sbruens 40ff316
Use `outline_` prefix for Caddy metrics.
sbruens f998612
Remove unused `NatTimeoutSec` config option.
sbruens e6686d1
Move initialization of handlers to the constructor.
sbruens 1259af8
Pass a `list.List` instead of a `CipherList`.
sbruens 3a64e35
Rename `SSServer` to `OutlineServer`.
sbruens 39da61b
refactor: make connection metrics optional
sbruens 28cc6c7
Merge branch 'master' into sbruens/logger
sbruens 48796e1
Make setting the logger a setter function.
sbruens 68c095f
Merge branch 'master' into sbruens/service
sbruens 9d126f9
Revert "Pass a `list.List` instead of a `CipherList`."
sbruens 213903d
Create noop metrics if nil.
sbruens e5e8549
Revert some more changes.
sbruens 724260e
Use a noop metrics struct if no metrics provided.
sbruens 655c3cc
Add noop implementation for `ShadowsocksConnMetrics`.
sbruens 7480f3c
Merge branch 'sbruens/service' into sbruens/logger
sbruens fd04a2b
Move logger arg.
sbruens aa3f70f
Merge branch 'sbruens/service' into sbruens/logger
sbruens c2bae13
Resolve nil metrics.
sbruens e336213
Merge branch 'sbruens/optional-metrics' into sbruens/service
sbruens 00d9b84
Merge branch 'sbruens/service' into sbruens/logger
sbruens 24d97f9
Merge branch 'master' into sbruens/service
sbruens 082859f
Merge branch 'sbruens/service' into sbruens/logger
sbruens d3e6027
Set logger explicitly to `noopLogger` in service creation.
sbruens 12de843
Merge branch 'sbruens/logger' into sbruens/caddy
sbruens bb19080
Address review comments.
sbruens 7d8892c
Set `noopLogger` in `NewShadowsocksStreamAuthenticator()` if nil.
sbruens f6dd019
Merge branch 'master' into sbruens/logger
sbruens 53ddc31
Fix logger reference.
sbruens 44563eb
Merge branch 'master' into sbruens/logger
sbruens c98d9d7
Merge branch 'sbruens/logger' into sbruens/caddy
sbruens 6463406
Add TODO comment to persist replay cache.
sbruens 72c635c
Remove use of zap.
sbruens 5321705
feat: persist replay cache across config reloads
sbruens a13ab28
Update comment.
sbruens be65ae3
Merge branch 'master' into sbruens/replaycache
sbruens d435603
Fix bad merge and don't use a global.
sbruens ecb636b
Address review comments.
sbruens 8209056
Update tests.
sbruens efd2ea3
Add more context to error message.
sbruens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fortuna I already merged a bit too fast, but just wanted to point out this specific change I made as part of not actively shrinking the maps in the
Resize()
method. This is needed, otherwise we'll never shrink maps that were resized down.