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

🐛 http dialer add socket config; sockopt.mark use uint32 #1264

Merged
merged 2 commits into from
Sep 10, 2021
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
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