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

Fix antctl proxy not using user specified port #5435

Merged
merged 1 commit into from
Aug 24, 2023
Merged
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
6 changes: 2 additions & 4 deletions pkg/antctl/raw/proxy/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var defaultFS = afero.NewOsFs()
// validateAndComplete checks the proxyOptions to see if there is sufficient information to run the
// command, and adds default values when needed.
func (o *proxyOptions) validateAndComplete() error {
if o.port != 0 && o.unixSocket != "" {
if o.port != defaultPort && o.unixSocket != "" {
return fmt.Errorf("cannot set --unix-socket and --port at the same time")
}

Expand All @@ -88,8 +88,6 @@ func (o *proxyOptions) validateAndComplete() error {
}
}

o.port = defaultPort

if !strings.HasSuffix(o.staticPrefix, "/") {
o.staticPrefix += "/"
}
Expand Down Expand Up @@ -143,7 +141,7 @@ func init() {
Command.Flags().StringVar(&o.rejectPaths, "reject-paths", proxy.DefaultPathRejectRE, "Regular expression for paths that the proxy should reject. Paths specified here will be rejected even accepted by --accept-paths.")
Command.Flags().StringVar(&o.acceptHosts, "accept-hosts", proxy.DefaultHostAcceptRE, "Regular expression for hosts that the proxy should accept.")
Command.Flags().StringVar(&o.rejectMethods, "reject-methods", proxy.DefaultMethodRejectRE, "Regular expression for HTTP methods that the proxy should reject (example --reject-methods='POST,PUT,PATCH'). ")
Command.Flags().IntVarP(&o.port, "port", "p", o.port, "The port on which to run the proxy. Set to 0 to pick a random port.")
Command.Flags().IntVarP(&o.port, "port", "p", defaultPort, "The port on which to run the proxy. Set to 0 to pick a random port.")
Command.Flags().StringVarP(&o.address, "address", "", defaultAddress, "The IP address on which to serve on.")
Command.Flags().BoolVar(&o.disableFilter, "disable-filter", false, "If true, disable request filtering in the proxy. This is dangerous, and can leave you vulnerable to XSRF attacks, when used with an accessible port.")
Command.Flags().StringVarP(&o.unixSocket, "unix-socket", "u", "", "Unix socket on which to run the proxy.")
Expand Down