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

masque: update Client to reflect template configuration changes #78

Merged
merged 1 commit into from
Oct 24, 2024
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
12 changes: 5 additions & 7 deletions content/docs/masque/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,26 @@ weight: 2
A client needs to be configured with the same URI template as the proxy. For more information on URI templates, see [URI Templates]({{< relref "proxy#uri-templates" >}}).

```go
t := uritemplate.MustNew("https://example.org:4443/masque?h={target_host}&p={target_port}")
cl := masque.Client{
Template: t,
}
template := uritemplate.MustNew("https://example.org:4443/masque?h={target_host}&p={target_port}")
```

`Client.DialAddr` can then be used establish proxied connections to servers by hostname.
In this case, DNS resolution is handled by the proxy:
```go
cl := masque.Client{}
// dial a target with a hostname
conn, rsp, err := cl.DialAddr(ctx, "quic-go.net:443")
conn, rsp, err := cl.DialAddr(ctx, template, "quic-go.net:443")
```

`Client.Dial` can be used to establish proxied connections to servers by IP address:
```go
conn, rsp, err := cl.Dial(ctx, <*net.UDPAddr>)
conn, rsp, err := cl.Dial(ctx, template,<*net.UDPAddr>)
```

The `net.PacketConn` returned from these methods is only non-nil if the proxy accepted the proxying request.
This is the case if the HTTP status code is in the 2xx range:
```go
conn, rsp, err := cl.DialAddr(ctx, "quic-go.net:443")
conn, rsp, err := cl.DialAddr(ctx, template, "quic-go.net:443")
// ... handle error ...
if rsp.StatusCode < 200 && rsp.StatusCode > 299 {
// proxying request rejected
Expand Down