Skip to content

Commit

Permalink
refs #59: added transport options to shared library payload;
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfinn committed Jul 29, 2023
1 parent d4615cf commit 86a9768
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cffi_src/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,23 @@ func getTlsClient(requestInput RequestInput, sessionId string, withSession bool)
options = append(options, tls_client.WithDisableIPV6())
}

if requestInput.TransportOptions != nil {
transportOptions := &tls_client.TransportOptions{
DisableKeepAlives: requestInput.TransportOptions.DisableKeepAlives,
DisableCompression: requestInput.TransportOptions.DisableCompression,
MaxIdleConns: requestInput.TransportOptions.MaxIdleConns,
MaxIdleConnsPerHost: requestInput.TransportOptions.MaxIdleConnsPerHost,
MaxConnsPerHost: requestInput.TransportOptions.MaxConnsPerHost,
MaxResponseHeaderBytes: requestInput.TransportOptions.MaxResponseHeaderBytes,
WriteBufferSize: requestInput.TransportOptions.WriteBufferSize,
ReadBufferSize: requestInput.TransportOptions.ReadBufferSize,
IdleConnTimeout: requestInput.TransportOptions.IdleConnTimeout,
// RootCAs: requestInput.TransportOptions.RootCAs,
}

options = append(options, tls_client.WithTransportOptions(transportOptions))
}

if requestInput.LocalAddress != nil {
localAddr, err := net.ResolveTCPAddr("", *requestInput.LocalAddress)
if err != nil {
Expand Down
16 changes: 16 additions & 0 deletions cffi_src/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type RequestInput struct {
CatchPanics bool `json:"catchPanics"`
CertificatePinningHosts map[string][]string `json:"certificatePinningHosts"`
CustomTlsClient *CustomTlsClient `json:"customTlsClient"`
TransportOptions *TransportOptions `json:"transportOptions"`
FollowRedirects bool `json:"followRedirects"`
ForceHttp1 bool `json:"forceHttp1"`
HeaderOrder []string `json:"headerOrder"`
Expand Down Expand Up @@ -94,6 +95,21 @@ type CustomTlsClient struct {
SupportedVersions []string `json:"supportedVersions"`
}

// TransportOptions contains settings for the underlying http transport of the tls client
type TransportOptions struct {
DisableKeepAlives bool `json:"disableKeepAlives"`
DisableCompression bool `json:"disableCompression"`
MaxIdleConns int `json:"maxIdleConns"`
MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost"`
MaxConnsPerHost int `json:"maxConnsPerHost"`
MaxResponseHeaderBytes int64 `json:"maxResponseHeaderBytes"` // Zero means to use a default limit.
WriteBufferSize int `json:"writeBufferSize"` // If zero, a default (currently 4KB) is used.
ReadBufferSize int `json:"readBufferSize"` // If zero, a default (currently 4KB) is used.
// IdleConnTimeout is the maximum amount of time an idle (keep-alive)
// connection will remain idle before closing itself. Zero means no limit.
IdleConnTimeout *time.Duration `json:"idleConnTimeout"`
}

type PriorityFrames struct {
PriorityParam PriorityParam `json:"priorityParam"`
StreamID uint32 `json:"streamID"`
Expand Down

0 comments on commit 86a9768

Please sign in to comment.