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

Added client to rs-tftpd #22

Merged
merged 1 commit into from
Jul 1, 2024
Merged

Added client to rs-tftpd #22

merged 1 commit into from
Jul 1, 2024

Conversation

Blenderwizard
Copy link
Contributor

Implements #21

Add a TFTP client, enabled with the client feature: Example: cargo build --features client

The client supports TFTP Option Extension as defined by RFC 2347

A user can set the following options:

and the client automatically sets the Transfer Size Option RFC 2349

Client CLI options:

TFTP Client

Usage: tftpd client [OPTIONS] <-f | --file> <File>

Options:
  -i, --ip-address <IP ADDRESS> Ip address of the server (default: 127.0.0.1)
  -p, --port <PORT>             Port of the server (default: 69)
  -b, --blocksize <number>      Sets the blocksize (default: 512)
  -w, --windowsize <number>     Sets the windowsize (default: 1)
  -t, --timeout <seconds>       Sets the timeout in seconds (default: 5)
  -u, --upload                  Sets the client to upload mode, Ignores all previous download flags
  -d, --download                Set the client to download mode, Invalidates all previous upload flags
  -f, --file                    Local file to upload if in upload mode. Name of the remote file if in download mode
  -sd, --save-directory <DIRECTORY>     Set the directory to save files when in Download Mode (default: the directory setting)
  -h, --help                    Print help information

Server CLI options (ONLY WHEN CLIENT FEATURE IS ENABLED):

TFTP Server Daemon

Usage: tftpd server [OPTIONS]

Options:
  -i, --ip-address <IP ADDRESS> Set the ip address of the server (default: 127.0.0.1)
  -p, --port <PORT>             Set the listening port of the server (default: 69)
  -d, --directory <DIRECTORY>   Set the serving directory (default: current working directory)
  -rd, --receive-directory <DIRECTORY>  Set the directory to receive files to (default: the directory setting)
  -sd, --send-directory <DIRECTORY>     Set the directory to send files from (default: the directory setting)
  -s, --single-port             Use a single port for both sending and receiving (default: false)
  -r, --read-only               Refuse all write requests, making the server read-only (default: false)
  --duplicate-packets <NUM>     Duplicate all packets sent from the server (default: 0)
  --overwrite                   Overwrite existing files (default: false)
  -h, --help                    Print help information

@Blenderwizard Blenderwizard marked this pull request as draft June 27, 2024 10:00
@altugbakan
Copy link
Owner

From an overview this looks great! I liked how you used the feature flags so there’s almost no code overhead.

I see that you’ve opened this as a draft, but it looks ready for review. Do you want me to review this?

@Blenderwizard
Copy link
Contributor Author

I asked some people from my work to take a look, but If you want to review I can remove the draft.

@altugbakan
Copy link
Owner

Yeah no worries, I will check it when it’s ready to review.

Copy link

@rlendenmann rlendenmann left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. just some small improvements in the log ouput.

src/client.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
@Blenderwizard Blenderwizard marked this pull request as ready for review June 27, 2024 14:21
Copy link
Owner

@altugbakan altugbakan left a comment

Choose a reason for hiding this comment

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

Hey! Everything overall looks great, I have just some comments about the code style and some copy-paste errors.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/client.rs Outdated Show resolved Hide resolved
src/client.rs Outdated Show resolved Hide resolved
src/client.rs Outdated Show resolved Hide resolved
src/client_config.rs Outdated Show resolved Hide resolved
src/client_config.rs Outdated Show resolved Hide resolved
src/client_config.rs Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/packet.rs Outdated Show resolved Hide resolved
@Blenderwizard
Copy link
Contributor Author

That should be all of your requested changes.

@altugbakan
Copy link
Owner

altugbakan commented Jul 1, 2024

LGTM!

@altugbakan altugbakan merged commit fb3a684 into altugbakan:main Jul 1, 2024
2 checks passed
@altugbakan altugbakan mentioned this pull request Jul 1, 2024

To connect the client to a tftp server running on IP address `127.0.0.1`, read-only, on port `1234` and download a file named `example.file`
```bash
tftpd client example.file -i 0.0.0.0 -p 1234 -d
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would have been cleaner to just add a new binary to the Cargo.toml

[[bin]]
name = "tftpc"
path = "src/client_main.rs"
required-features = ["client"]

[[bin]]
name = "tftpd"
path = "src/main.rs"

Copy link
Owner

Choose a reason for hiding this comment

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

Would you like to open a new PR for this? We can merge it in before doing a new release.

@tardyp tardyp mentioned this pull request Jul 1, 2024
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.

4 participants