Restructure and add library target #394
Merged
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.
Summary
This PR essentially splits
src/main.rs
into three files:src/lib.rs
- code that takes the config structs and launches tunnelssrc/config.rs
-Client
andServer
config structswstunnel-cli/src/main.rs
- code specific to CLI operationCargo project structure changes
I've made the root Cargo project (the library) a workspace, and added a
wstunnel-cli
binary subpackage to this workspace. It depends on the root library, with theclap
feature enabled.This
clap
feature on the root library project adds the clap dependency and enables clap attributes onClient
andServer
inconfig.rs
. This is because clap functionality will not be needed for most usages of the library.In order to build/run the CLI from the root of this repo, you need to run
cargo run --package wstunnel-cli
. I've updated the README accordingly.Library usage
Client
orServer
struct with all of the required fields specified.wstunnel::run_client
orwstunnel::run_server
.run_client
will stop when all of the tunnels it spawns stop)Problems
I'm not sure what to do about the stdio listener. I've left the code for launching an stdio tunnel in
lib.rs
with all of the other protocol types, but it of course doesn't make sense inside the library.All of the tests still pass, and I verified that the demo in the README still works.
This will break #393
Fixes #286