Skip to content

Commit

Permalink
Expose more of HTTPOverRPC's feature set to sanssh httpoverrpc proxy (
Browse files Browse the repository at this point in the history
#469)

We added a few RPC-level features like contacting a host other than localhost and supporting https, but only exposed them in `httpoverrpc get`. Let's expose them in the proxy too so that we have feature parity.

Co-authored-by: Edbert Linardi <[email protected]>
  • Loading branch information
stvnrhodes and sfc-gh-elinardi authored Aug 13, 2024
1 parent d3c719f commit 33f1a20
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions services/httpoverrpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ func (p *httpCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interfac
}

type proxyCmd struct {
listenAddr string
allowAnyHost bool
listenAddr string
allowAnyHost bool
protocol string
hostname string
insecureSkipVerify bool
}

func (*proxyCmd) Name() string { return "proxy" }
Expand All @@ -84,6 +87,10 @@ func (*proxyCmd) Usage() string {
func (p *proxyCmd) SetFlags(f *flag.FlagSet) {
f.StringVar(&p.listenAddr, "addr", "localhost:0", "Address to listen on, defaults to a random localhost port")
f.BoolVar(&p.allowAnyHost, "allow-any-host", false, "Serve data regardless of the Host in HTTP requests instead of only allowing localhost and IPs. False by default to prevent DNS rebinding attacks.")
f.StringVar(&p.protocol, "protocol", "http", "protocol to communicate with specified hostname")
f.StringVar(&p.hostname, "hostname", "localhost", "ip address or domain name to specify host")
f.BoolVar(&p.insecureSkipVerify, "insecure-skip-tls-verify", false, "If true, skip TLS cert verification")

}

// This context detachment is temporary until we use go1.21 and context.WithoutCancel is available.
Expand Down Expand Up @@ -164,9 +171,10 @@ func (p *proxyCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa
Headers: reqHeaders,
Body: body,
},
Port: int32(port),
Protocol: "http",
Hostname: "localhost",
Port: int32(port),
Protocol: p.protocol,
Hostname: p.hostname,
Tlsconfig: &pb.TLSConfig{InsecureSkipVerify: p.insecureSkipVerify},
}
resp, err := proxy.Host(ctx, req)
if err != nil {
Expand Down

0 comments on commit 33f1a20

Please sign in to comment.