Skip to content

Commit

Permalink
🐛 http dialer add socket config; sockopt.mark use uint32 (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vigilans committed Sep 10, 2021
1 parent 4a174e8 commit 4d155bc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion common/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type Content struct {
// Sockopt is the settings for socket connection.
type Sockopt struct {
// Mark of the socket connection.
Mark int32
Mark uint32
}

// SetAttribute attachs additional string attributes to content.
Expand Down
2 changes: 1 addition & 1 deletion infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (p TransportProtocol) Build() (string, error) {
}

type SocketConfig struct {
Mark int32 `json:"mark"`
Mark uint32 `json:"mark"`
TFO *bool `json:"tcpFastOpen"`
TProxy string `json:"tproxy"`
AcceptProxyProtocol bool `json:"acceptProxyProtocol"`
Expand Down
8 changes: 4 additions & 4 deletions transport/internet/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion transport/internet/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ message ProxyConfig {
// SocketConfig is options to be applied on network sockets.
message SocketConfig {
// Mark of the connection. If non-zero, the value will be set to SO_MARK.
int32 mark = 1;
uint32 mark = 1;

enum TCPFastOpenState {
// AsIs is to leave the current TFO state as is, unmodified.
Expand Down
6 changes: 3 additions & 3 deletions transport/internet/http/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (

type dialerCanceller func()

func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.Config) (*http.Client, dialerCanceller) {
func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.Config, streamSettings *internet.MemoryStreamConfig) (*http.Client, dialerCanceller) {
globalDialerAccess.Lock()
defer globalDialerAccess.Unlock()

Expand Down Expand Up @@ -62,7 +62,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, tlsSettings *tls.C
address := net.ParseAddress(rawHost)

detachedContext := core.ToBackgroundDetachedContext(ctx)
pconn, err := internet.DialSystem(detachedContext, net.TCPDestination(address, port), nil)
pconn, err := internet.DialSystem(detachedContext, net.TCPDestination(address, port), streamSettings.SocketSettings)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
if tlsConfig == nil {
return nil, newError("TLS must be enabled for http transport.").AtWarning()
}
client, canceller := getHTTPClient(ctx, dest, tlsConfig)
client, canceller := getHTTPClient(ctx, dest, tlsConfig, streamSettings)

opts := pipe.OptionsFromContext(ctx)
preader, pwriter := pipe.New(opts...)
Expand Down

0 comments on commit 4d155bc

Please sign in to comment.