Skip to content

Commit

Permalink
Sockopt config: Add penetrate for XHTTP U-D-S, Remove tcpNoDelay
Browse files Browse the repository at this point in the history
Now `sockopt` can be shared via `extra`, and be replaced with upload's forcibly.

Closes #4227
  • Loading branch information
RPRX authored Dec 31, 2024
1 parent 4ce65fc commit 369d894
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 59 deletions.
8 changes: 2 additions & 6 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
extra.Host = c.Host
extra.Path = c.Path
extra.Mode = c.Mode
extra.Extra = c.Extra
c = &extra
}

Expand Down Expand Up @@ -318,9 +317,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
if c.Mode == "stream-one" {
return nil, errors.New(`Can not use "downloadSettings" in "stream-one" mode.`)
}
if c.Extra != nil {
c.DownloadSettings.SocketSettings = nil
}
var err error
if config.DownloadSettings, err = c.DownloadSettings.Build(); err != nil {
return nil, errors.New(`Failed to build "downloadSettings".`).Base(err)
Expand Down Expand Up @@ -689,7 +685,7 @@ type SocketConfig struct {
TCPCongestion string `json:"tcpCongestion"`
TCPWindowClamp int32 `json:"tcpWindowClamp"`
TCPMaxSeg int32 `json:"tcpMaxSeg"`
TcpNoDelay bool `json:"tcpNoDelay"`
Penetrate bool `json:"penetrate"`
TCPUserTimeout int32 `json:"tcpUserTimeout"`
V6only bool `json:"v6only"`
Interface string `json:"interface"`
Expand Down Expand Up @@ -776,7 +772,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
TcpCongestion: c.TCPCongestion,
TcpWindowClamp: c.TCPWindowClamp,
TcpMaxSeg: c.TCPMaxSeg,
TcpNoDelay: c.TcpNoDelay,
Penetrate: c.Penetrate,
TcpUserTimeout: c.TCPUserTimeout,
V6Only: c.V6only,
Interface: c.Interface,
Expand Down
68 changes: 34 additions & 34 deletions transport/internet/config.pb.go

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

4 changes: 2 additions & 2 deletions transport/internet/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ message SocketConfig {

string interface = 13;

bool v6only = 14;
bool v6only = 14;

int32 tcp_window_clamp = 15;

int32 tcp_user_timeout = 16;

int32 tcp_max_seg = 17;

bool tcp_no_delay = 18;
bool penetrate = 18;

bool tcp_mptcp = 19;

Expand Down
6 changes: 0 additions & 6 deletions transport/internet/sockopt_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
return errors.New("failed to unset SO_KEEPALIVE", err)
}
}

if config.TcpNoDelay {
if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_NODELAY, 1); err != nil {
return errors.New("failed to set TCP_NODELAY", err)
}
}
}

return nil
Expand Down
5 changes: 0 additions & 5 deletions transport/internet/sockopt_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
}
}

if config.TcpNoDelay {
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_NODELAY, 1); err != nil {
return errors.New("failed to set TCP_NODELAY", err)
}
}
if len(config.CustomSockopt) > 0 {
for _, custom := range config.CustomSockopt {
var level = 0x6 // default TCP
Expand Down
5 changes: 0 additions & 5 deletions transport/internet/sockopt_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
return errors.New("failed to unset SO_KEEPALIVE", err)
}
}
if config.TcpNoDelay {
if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1); err != nil {
return errors.New("failed to set TCP_NODELAY", err)
}
}
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion transport/internet/splithttp/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
globalDialerAccess.Lock()
if streamSettings.DownloadSettings == nil {
streamSettings.DownloadSettings = common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig)
if streamSettings.DownloadSettings.SocketSettings == nil {
if streamSettings.SocketSettings != nil && streamSettings.SocketSettings.Penetrate {
streamSettings.DownloadSettings.SocketSettings = streamSettings.SocketSettings
}
}
Expand Down

0 comments on commit 369d894

Please sign in to comment.