Read only the http header#28
Conversation
|
Hi @flx5, thanks for taking the time to contribute. I've been taking some time off but I'll look at this later this week. |
|
No worries. I've just realized that this branch also includes a few other changes (sorry about that):
If those are problematic for you I guess I can try to create patch files for each of those. Also a bit of background about why the change to reading the http request: The unpatched version read the following (on XCP-ng 8.2): The To fix this only the http header should be read from the connection before passing the connection on to the vnc client. I haven't figured out how to avoid unbuffered reading though. Wrapping the connection in a bufio reader probably won't work because then the buffer contains the version string and the vnc client once again won't be capable of reading it directly from the tls connection. |
|
I took a longer break than expected, but I'm getting back on things this week and will review this soon. Apologies for the long delay. Your contribution is very much appreciated! |
|
Apologies once again but I've actually taken a look at your code this time :) @flx5 can we please split the firmware changes outside of this PR? It will be easier to review that way. As for the unbuffered reading, we should be able to accomplish that with Reader.Peek and Reader.ReadString. I've written this example below that compiles, but is untested. Please give that approach a try |
| ui.Say(fmt.Sprintf("Received response: %s", builder.String())) | ||
|
|
||
| vncClient, err := vnc.Client(tlsConn, &vnc.ClientConfig{Exclusive: true}) | ||
| vncClient, err := vnc.Client(tlsConn, &vnc.ClientConfig{Exclusive: false}) |
There was a problem hiding this comment.
Did you notice any bad behavior with the previous setting?
| @@ -10,13 +10,11 @@ import ( | |||
| "log" | |||
There was a problem hiding this comment.
Can you remove the /* Heavily borrowed from builder/quemu/step_type_boot_command.go */ comment at the top of this file? That shouldn't be the case now that we are using the bootcommand package :)
| // Look for \r\n\r\n sequence. Everything after the HTTP Header is for the vnc client. | ||
|
|
||
| builder := strings.Builder{} | ||
| buffer := make([]byte, 1) |
There was a problem hiding this comment.
Added a comment elsewhere with a git diff that shows how to avoid the unbuffered reading without consuming the buffer. Please give that a try.
I extracted the changes as-is from vatesfr#28.
* added local DVD install example * Added a commented example of a centos8 build * Update goreleaser with the packer template * Don't run unit test on goreleaser * Another fix * Add github workflow on release * Use go 1.14 * Add github workflow to master for #10: * Use go 1.16 * Use go 1.16 * Adjust goreleaser file to align with upstream and update docs about go1.16 upgrade * Update release version in main.go * Add v prefix to version number * Remove prerelease suffix * Fix issues with ubuntu example * Moved some files around ind docs/ * removed centos8 json example and kickstart * Updated examples/readme.md for the ubuntu example * Replace conn master host > instance host * Update step_type_boot_command.go * Update step_type_boot_command.go * Add documentation for the network_names configuration option * Use consistent naming for variable types * Add a shared vm cleanup struct and function and ensure that the wait for ip step uses it * Update go.mod to reflect currently supported go version * Update docs on and remove it from the examples in favor of the default behavior * Added a commented example of a centos8 build * removed centos8 json example and kickstart * Updated examples/readme.md for the ubuntu example * Added the packer init block to the local and netinstall centos example * Added packer init and explanation to the commented example * updated the example readme * Added packer init to Examples.md * Update the Ubuntu example to hcl and packer init * Removed the ubuntu specific section from examples/readme * Add github workflow to master for #10: * Use go 1.16 * Update goreleaser with the packer template * Don't run unit test on goreleaser * Another fix * Use go 1.14 * Use go 1.16 * Adjust goreleaser file to align with upstream and update docs about go1.16 upgrade * Update release version in main.go * Add v prefix to version number * Remove prerelease suffix * Fix issues with ubuntu example * Replace conn master host > instance host * Update step_type_boot_command.go * Update step_type_boot_command.go * Add documentation for the network_names configuration option * Use consistent naming for variable types * Add a shared vm cleanup struct and function and ensure that the wait for ip step uses it * Update go.mod to reflect currently supported go version * Update docs on and remove it from the examples in favor of the default behavior * Moved some files around ind docs/ * added centos8-netinstall * added local DVD install example * Added a commented example of a centos8 build * removed centos8 json example and kickstart * added centos8-netinstall * updated examples/README.md to refekt current state * added local DVD install example * Added a commented example of a centos8 build * Moved some files around ind docs/ * Added a commented example of a centos8 build * removed centos8 json example and kickstart * Updated examples/readme.md for the ubuntu example * Added the packer init block to the local and netinstall centos example * Added packer init and explanation to the commented example * updated the example readme * Added packer init to Examples.md * Update the Ubuntu example to hcl and packer init * added centos8-netinstall * added local DVD install example * Added a commented example of a centos8 build * removed centos8 json example and kickstart * Updated examples/readme.md for the ubuntu example * Removed the ubuntu specific section from examples/readme * Use go 1.14 * Add documentation for the network_names configuration option * Use consistent naming for variable types * Moved some files around ind docs/ * Changed all examples to 'version = ">= v0.3.2"' * Removed kickstart from Commented-Example.md * Moved explanation of the centos example into the pkr file * removed shutdown_command from all examples * Update to latest Ubuntu image * Revert "Use go 1.14" This reverts commit 1743373. This has slid by while rebasing * Removed old lines of documentation * Updated the variable description of centos8-netinstall and centos8-local * Workaround for problems with the Ubuntu template * Removed shutdown_timeout to be in line with master * Removed centos-example deleted: docs/builders/iso/Commented-Example.md deleted: examples/centos/centos8-example.pkr.hcl deleted: examples/http/centos8/ks-centos8-example.cfg * Update set up instructions to include packer init * Small dependency refresh on Xen API client Signed-off-by: Ringo De Smet <ringo@de-smet.name> * More reliable cloud-init startup * add example of needed cloud-config * update ubuntu example to use floppy_files for cloud-config * Fix XenServer tools guest IP address resolution * Add Xen guest utilities to ubuntu user-data example * Remove unused files * Update README.md * feat: Make firmware configurable I extracted the changes as-is from vatesfr#28. * Add goreleaser config back * Upgrade packer-plugin-sdk to v0.3.0 and update release process and go version accordingly * Add missing Makefile * add step to remove disks param from other-config * Update the ubuntu example to use an available 20.04 iso and proper clone_template default * Remove hashicorps gpg github action to one that doesn't collide with GitHub's gpg agent * Ensure gpg github action has parameters passed properly (cherry picked from commit 2b2ba8540d1acfa0884e8db1367b32495bc39259) * Update the ubuntu example to be resilient to ISO releases * Update the correct README doc with the packer 1.8 requirement * Revert "Update the ubuntu example to be resilient to ISO releases" * Prevent ISO used in iso builder from being uploaded if it already exists * Update ubuntu example to be resilient to upstream minor releases * Refactor template name to use a map lookup on Ubuntu version * Use 30 GiB root volume * Fixing main md links and doc links * Fixing main md links and doc links * Fixing main md links and doc links * Fixing main md links and doc links * s/SrName/SrISOName Signed-off-by: AtaxyaNetwork <contact@ataxya.net> * Get the tests compiling again. Looks like the consts got moved into common * Capture actual errors from Prepare Solves TestBuilderPrepare_InvalidKey failing, since we weren't capturing it's errors before. * Remove iso_checksum_type checks This aligns the Xenserver plugin to being a bit more inline with what Packer > 1.6.0 is expecting, since packer now simply ignores the iso_checksum_type (it's supposed to error out but that code path isn't working right now because we don't set PluginType in the configs. The unit tests have been altered to reflect this reality. Note that this isn't a comprehensive change; the config still has the inert ISOChecksumType, and there's probably a laundry list of other things that needs to be looked at, For now though, we have working unit tests again. Documentation from SDK has been aligned for iso_checksum * Remove remaining usages of iso_checksum_type, fix config.hcl2spec.go generation and re-run it * Use default SR if `sr_iso_name` is not specified * Work around XenAPI compatibility issue to get default SR * Use default SR if `sr_iso_name` is not specified * Work around XenAPI compatibility issue to get default SR * Ensure that SrISOName is no longer a required field * Revert "Allow ISO Storage repository to fallback to default SR if unspecified" * Enable xva builder to create VM from existing template * Update XVA builder to match ISO builder * Move create instance step to common directory * Update StepCreateInstance to accommodate both ISO and XVA builders * Update XVA builder to use shared StepCreateInstance step * Allow tagging VMs (cherry picked from commit 4200795) * Update docs (cherry picked from commit 2961af4) * Update config.hcl2spec.go with go generate * Add depndabot and ci job for running go tests. Ensure go versions are consistent * Add the firmware argument to the builder documentation since it was missing * Update xenserver-iso.html.markdown Add xva_compressed to documentation * don't use tools by default * add tools_iso_name in the doc * remove packer.json * remove ToolsIsoName * Fix tests Signed-off-by: Dom Del Nano <ddelnano@gmail.com> * Add configuration for github release generation * Allow goreleaser to publish the github release and have it run go tests * Upgrade go to 1.17 and update deps * Allow having a template or a full VM * typo * remove file * Converting to template is now the default behavior + add docs Signed-off-by: Cécile MORANGE <contact@ataxya.net> * Bump google.golang.org/grpc from 1.40.0 to 1.56.3 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.40.0 to 1.56.3. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](grpc/grpc-go@v1.40.0...v1.56.3) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Adding a few more config items to docs; Adjusting compile script to be consistent; * Adding specific compile notes for Windows; * Allow user to set VDI name * Bump golang.org/x/crypto from 0.11.0 to 0.17.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.11.0 to 0.17.0. - [Commits](golang/crypto@v0.11.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/net from 0.10.0 to 0.17.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.17.0. - [Commits](golang/net@v0.10.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/crypto from 0.17.0 to 0.18.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.17.0 to 0.18.0. - [Commits](golang/crypto@v0.17.0...v0.18.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Add documentation for disk_name * Add a new setting HostSshPort A XenServer host may accept SSH connections on port other than 22. This commit adds a packer option 'remote_ssh_port' to connect to a custom port. * Apply HostSshPort in ssh port forwarding * Bump golang.org/x/crypto from 0.18.0 to 0.19.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.19.0. - [Commits](golang/crypto@v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Upgrade go to 1.20 to reflect latest packer-plugins-sdk go version and unblock gomod upgrades Signed-off-by: Dom Del Nano <ddelnano@gmail.com> * Bump golang.org/x/crypto from 0.19.0 to 0.21.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.19.0 to 0.21.0. - [Commits](golang/crypto@v0.19.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump google.golang.org/protobuf from 1.30.0 to 1.33.0 Bumps google.golang.org/protobuf from 1.30.0 to 1.33.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump github.com/zclconf/go-cty from 1.10.0 to 1.14.4 Bumps [github.com/zclconf/go-cty](https://github.com/zclconf/go-cty) from 1.10.0 to 1.14.4. - [Release notes](https://github.com/zclconf/go-cty/releases) - [Changelog](https://github.com/zclconf/go-cty/blob/main/CHANGELOG.md) - [Commits](zclconf/go-cty@v1.10.0...v1.14.4) --- updated-dependencies: - dependency-name: github.com/zclconf/go-cty dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Disable exclusive VNC connection when packer in debug mode * Bump golang.org/x/net from 0.21.0 to 0.23.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.21.0 to 0.23.0. - [Commits](golang/net@v0.21.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Ensure version package exists and matches existing linker variable on release Signed-off-by: Dom Del Nano <ddelnano@gmail.com> * Use correct version package from the main package Signed-off-by: Dom Del Nano <ddelnano@gmail.com> * Replace deprecated --rm-dist goreleaser flag with --clean * Use packer-plugin-skaffolding goreleaser action version Signed-off-by: Dom Del Nano <ddelnano@gmail.com> * Validate .goreleaser.yml file with 'goreleaser check' Signed-off-by: Dom Del Nano <ddelnano@gmail.com> * Bump github.com/hashicorp/hcl/v2 from 2.12.0 to 2.20.1 Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.12.0 to 2.20.1. - [Release notes](https://github.com/hashicorp/hcl/releases) - [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md) - [Commits](hashicorp/hcl@v2.12.0...v2.20.1) --- updated-dependencies: - dependency-name: github.com/hashicorp/hcl/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/crypto from 0.21.0 to 0.24.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.21.0 to 0.24.0. - [Commits](golang/crypto@v0.21.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Use packer-sdc fix to address go-cty issues Signed-off-by: Dom Del Nano <ddelnano@gmail.com> * - Moved to official XenServer go SDK - Added vGPU support - Added Clone support - Added support for ISO driver disk instead of Floppy - Added support for vTPM - Simplified vCPU configuration - Added CoresPerSocket configuration - Code cleanup * Updated Go versions * - Added Packer plugin version to User-Agent string - Updated version initialization * Fix the issue what iso builder does not clean up VMs after failure, and add logging for cleanup process. * Add certification check * Fix CI: download XenServer Go SDK before running tests Mirrors the approach used in terraform-provider-xenserver: adds a step to download and extract the XenServer Go SDK into ./goSDK before go test runs, resolving the missing replacement directory error. Also updates actions/checkout and actions/setup-go from v2 to v4. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix go vet errors and removed SDK constant reference - Replace log.Printf(fmt.Sprintf(...)) with log.Printf(...) in vm_cleanup.go - Fix fmt.Sprintf %s format verb for *xenapi.Session type in step_export.go - Replace packer.BuildNameConfigKey (removed from SDK) with literal string in tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix %s format verb for *xenapi.Session in step_import_instance.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix %s format verb used with map type in step_start_on_himn.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix tests broken by certification check validation Add skip_cert_verification=true to test configs so they pass the new server_cert validation added in the "Add certification check" commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Skip unimplemented iso_checksum_type validation test case The builder does not validate unknown checksum type values so the "fake" test case cannot pass. Skipping until validation is added. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Skip UT in CI, run build only As the UT requires a live XenServer host (un-mocked XenAPI), skip the unit tests in CI and replace with a build check only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Signed-off-by: Ringo De Smet <ringo@de-smet.name> Signed-off-by: AtaxyaNetwork <contact@ataxya.net> Signed-off-by: Dom Del Nano <ddelnano@gmail.com> Signed-off-by: Cécile MORANGE <contact@ataxya.net> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: daniel <d.koschuetzki@hs-furtwangen.de> Co-authored-by: Dom Del Nano <ddelnano@gmail.com> Co-authored-by: Ariel Sandor <arielsandor> Co-authored-by: Ariel Sandor <ebrainte@gmail.com> Co-authored-by: 4censord <mail@business-insulting.de> Co-authored-by: Daniel Koschützki <koschuet@hs-furtwangen.de> Co-authored-by: Ringo De Smet <ringo@de-smet.name> Co-authored-by: John Jones <john@exthilion.org> Co-authored-by: Maxence Boutet <maxenceboutet@outlook.com> Co-authored-by: BryceTech122 <meach495@gmail.com> Co-authored-by: Arnaud Charles <arnaud@mirahi.io> Co-authored-by: AtaxyaNetwork <contact@ataxya.net> Co-authored-by: somerandomqaguy <76200225+somerandomqaguy@users.noreply.github.com> Co-authored-by: Heinrich Kruger <heinrich.kruger@sohonet.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Arden Shackelford <arden@ardens.tech> Co-authored-by: Marshall Wu <wumarshall@163.com> Co-authored-by: Marko Mahnič <marko.mahnic@gmail.com> Co-authored-by: Melchior NOGUES <m3lchior@gmail.com> Kossen_citrix@users.noreply.github.com>
The VNC client won't connect if the version string has already been read.