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

add functions for proxy on adjust headers #275

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions pkg/client/common/v1/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func (c *WSClient) internalConnectWithCancel(ctx context.Context, ctxCancel cont
myHeader.Set("Host", c.cOptions.Host)
myHeader.Set("Authorization", "token "+c.cOptions.APIKey)
myHeader.Set("User-Agent", clientinterfaces.DgAgent)
if c.cOptions.WSHeaderProcessor != nil {
c.cOptions.WSHeaderProcessor(myHeader)
}

// attempt to establish connection
i := int64(0)
Expand Down Expand Up @@ -196,6 +199,7 @@ func (c *WSClient) internalConnectWithCancel(ctx context.Context, ctxCancel cont
dialer = websocket.Dialer{
HandshakeTimeout: 15 * time.Second,
RedirectService: c.cOptions.RedirectService,
Proxy: c.cOptions.Proxy,
}
} else {
dialer = websocket.Dialer{
Expand All @@ -204,6 +208,7 @@ func (c *WSClient) internalConnectWithCancel(ctx context.Context, ctxCancel cont
TLSClientConfig: &tls.Config{InsecureSkipVerify: c.cOptions.SkipServerAuth},
RedirectService: c.cOptions.RedirectService,
SkipServerAuth: c.cOptions.SkipServerAuth,
Proxy: c.cOptions.Proxy,
}
}
// perform the websocket connection
Expand Down
17 changes: 12 additions & 5 deletions pkg/client/interfaces/v1/types-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@

package interfacesv1

import (
"net/http"
"net/url"
)

// ClientOptions defines any options for the client
type ClientOptions struct {
APIKey string
Host string // override for the host endpoint
APIVersion string // override for the version used
Path string // override for the endpoint path usually <version/listen> or <version/projects>
SelfHosted bool // set to true if using on-prem
APIKey string
Host string // override for the host endpoint
APIVersion string // override for the version used
Path string // override for the endpoint path usually <version/listen> or <version/projects>
SelfHosted bool // set to true if using on-prem
Proxy func(*http.Request) (*url.URL, error) // provide function for proxy -- e.g. http.ProxyFromEnvironment
WSHeaderProcessor func(http.Header) // process headers before dialing for websocket connection

// shared client options
SkipServerAuth bool // keeps the client from authenticating with the server
Expand Down
Loading