Merge pull request #105143 from aojea/netexec_optional_listen

agnhost: allow to disable udp listener on netexec
This commit is contained in:
Kubernetes Prow Robot 2021-09-20 16:10:22 -07:00 committed by GitHub
commit c4587a62f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View File

@ -417,6 +417,8 @@ It will also start a UDP server on the indicated UDP port that responds to the f
- `echo <msg>`: Returns the given `<msg>`
- `clientip`: Returns the request's IP address
The UDP server can be disabled by setting `--udp-port -1`.
Additionally, if (and only if) `--sctp-port` is passed, it will start an SCTP server on that port,
responding to the same commands as the UDP server.

View File

@ -1 +1 @@
2.33
2.34

View File

@ -106,12 +106,14 @@ will be upgraded to HTTPS. The image has default, "localhost"-based cert/privkey
If "--http-override" is set, the HTTP(S) server will always serve the override path & options,
ignoring the request URL.
It will also start a UDP server on the indicated UDP port that responds to the following commands:
It will also start a UDP server on the indicated UDP port and addresses that responds to the following commands:
- "hostname": Returns the server's hostname
- "echo <msg>": Returns the given <msg>
- "clientip": Returns the request's IP address
The UDP server can be disabled by setting --udp-port to -1.
Additionally, if (and only if) --sctp-port is passed, it will start an SCTP server on that port,
responding to the same commands as the UDP server.
`,
@ -168,14 +170,19 @@ func main(cmd *cobra.Command, args []string) {
addRoutes(http.DefaultServeMux, exitCh)
}
udpBindTo, err := parseAddresses(udpListenAddresses)
if err != nil {
log.Fatal(err)
// UDP server
if udpPort != -1 {
udpBindTo, err := parseAddresses(udpListenAddresses)
if err != nil {
log.Fatal(err)
}
for _, address := range udpBindTo {
go startUDPServer(address, udpPort)
}
}
for _, address := range udpBindTo {
go startUDPServer(address, udpPort)
}
// SCTP server
if sctpPort != -1 {
go startSCTPServer(sctpPort)
}