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 TFTP blocksize flag: #369

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ FLAGS
-syslog-enabled [syslog] enable Syslog server(receiver) (default "true")
-ipxe-script-patch [tftp/http] iPXE script fragment to patch into served iPXE binaries served via TFTP or HTTP
-tftp-addr [tftp] local IP:Port to listen on for iPXE TFTP binary requests (default "172.17.0.2:69")
-tftp-block-size [tftp] TFTP block size a value between 512 (the default block size for TFTP) and 65456 (the max size a UDP packet payload can be) (default "512")
-tftp-enabled [tftp] enable iPXE TFTP binary server) (default "true")
-tftp-timeout [tftp] iPXE TFTP binary server requests timeout (default "5s")
```
Expand Down
1 change: 1 addition & 0 deletions cmd/smee/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func tftpFlags(c *config, fs *flag.FlagSet) {
fs.StringVar(&c.tftp.bindAddr, "tftp-addr", detectPublicIPv4(":69"), "[tftp] local IP:Port to listen on for iPXE TFTP binary requests")
fs.DurationVar(&c.tftp.timeout, "tftp-timeout", time.Second*5, "[tftp] iPXE TFTP binary server requests timeout")
fs.StringVar(&c.tftp.ipxeScriptPatch, "ipxe-script-patch", "", "[tftp/http] iPXE script fragment to patch into served iPXE binaries served via TFTP or HTTP")
fs.IntVar(&c.tftp.blockSize, "tftp-block-size", 512, "[tftp] TFTP block size a value between 512 (the default block size for TFTP) and 65456 (the max size a UDP packet payload can be)")
}

func ipxeHTTPBinaryFlags(c *config, fs *flag.FlagSet) {
Expand Down
8 changes: 5 additions & 3 deletions cmd/smee/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func TestParser(t *testing.T) {
bindAddr: "192.168.2.4:514",
},
tftp: tftp{
enabled: true,
timeout: 5 * time.Second,
bindAddr: "192.168.2.4:69",
blockSize: 512,
enabled: true,
timeout: 5 * time.Second,
bindAddr: "192.168.2.4:69",
},
ipxeHTTPBinary: ipxeHTTPBinary{
enabled: true,
Expand Down Expand Up @@ -111,6 +112,7 @@ FLAGS
-syslog-enabled [syslog] enable Syslog server(receiver) (default "true")
-ipxe-script-patch [tftp/http] iPXE script fragment to patch into served iPXE binaries served via TFTP or HTTP
-tftp-addr [tftp] local IP:Port to listen on for iPXE TFTP binary requests (default "%[1]v:69")
-tftp-block-size [tftp] TFTP block size a value between 512 (the default block size for TFTP) and 65456 (the max size a UDP packet payload can be) (default "512")
-tftp-enabled [tftp] enable iPXE TFTP binary server) (default "true")
-tftp-timeout [tftp] iPXE TFTP binary server requests timeout (default "5s")
`, defaultIP)
Expand Down
14 changes: 8 additions & 6 deletions cmd/smee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ type syslogConfig struct {
}

type tftp struct {
enabled bool
bindAddr string
timeout time.Duration
blockSize int
enabled bool
ipxeScriptPatch string
timeout time.Duration
}

type ipxeHTTPBinary struct {
Expand Down Expand Up @@ -144,10 +145,11 @@ func main() {
tftpServer.EnableTFTPSinglePort = true
if ip, err := netip.ParseAddrPort(cfg.tftp.bindAddr); err == nil {
tftpServer.TFTP = ipxedust.ServerSpec{
Disabled: false,
Addr: ip,
Timeout: cfg.tftp.timeout,
Patch: []byte(cfg.tftp.ipxeScriptPatch),
Disabled: false,
Addr: ip,
Timeout: cfg.tftp.timeout,
Patch: []byte(cfg.tftp.ipxeScriptPatch),
BlockSize: cfg.tftp.blockSize,
}
// start the ipxe binary tftp server
log.Info("starting tftp server", "bind_addr", cfg.tftp.bindAddr)
Expand Down
Loading