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

Add two new CLI flags to set the host side TCP interface and port #18

Merged
merged 1 commit into from
Nov 18, 2023

Conversation

jhodapp
Copy link
Member

@jhodapp jhodapp commented Nov 18, 2023

Description

This PR adds two new CLI flags to set the host side TCP interface and port to listen on for incoming client connections. Sets the default port to 4000.

GitHub Issue: N/A

Changes

  • Adds CLI flag -i as String to set the host side TCP interface address
  • Adds CLI flag -p as u16 to set the host side TCP port

Testing Strategy

Run the following:
--> cargo run -- -t 2 -p 3000 -i 127.0.0.1

and observe that the server outputs an INFO log line showing:
--> [INFO] Server starting... listening for connections on http://127.0.0.1:3000

Concerns

None

@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Nov 18, 2023
@jhodapp jhodapp self-assigned this Nov 18, 2023
@jhodapp jhodapp requested a review from calebbourg November 18, 2023 20:22
… listen on for incoming client connections. Sets the default port to 4000
@jhodapp jhodapp force-pushed the change_default_tcp_server_port_to_4000 branch from e11fa07 to d007f0c Compare November 18, 2023 20:24
@@ -14,16 +14,16 @@ mod router;

pub async fn init_server(app_state: AppState) -> Result<()> {
// These will probably come from app_state.config (command line)
let host = "127.0.0.1";
let port = 3000;
let host = app_state.config.interface.as_ref().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we need the as_ref here?

Copy link
Member Author

@jhodapp jhodapp Nov 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unwrap() consumes the value otherwise which causes rustc to complain about the ownership move farther down in the code on line 27.

@jhodapp jhodapp merged commit 21b3187 into main Nov 18, 2023
4 checks passed
@jhodapp jhodapp deleted the change_default_tcp_server_port_to_4000 branch February 24, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants