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

TCP Keep Alive Control #1395

Merged
merged 11 commits into from
Nov 28, 2021
Merged

TCP Keep Alive Control #1395

merged 11 commits into from
Nov 28, 2021

Conversation

xiaokangwang
Copy link
Contributor

This is a reworked PR of #1276.

@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2021

Codecov Report

Merging #1395 (aa2b82e) into master (801d4a1) will decrease coverage by 0.03%.
The diff coverage is 12.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1395      +/-   ##
==========================================
- Coverage   39.62%   39.58%   -0.04%     
==========================================
  Files         598      598              
  Lines       35029    35064      +35     
==========================================
+ Hits        13879    13881       +2     
- Misses      19633    19660      +27     
- Partials     1517     1523       +6     
Impacted Files Coverage Δ
transport/internet/config.pb.go 15.86% <0.00%> (-0.24%) ⬇️
transport/internet/sockopt_linux.go 15.58% <0.00%> (-1.81%) ⬇️
transport/internet/sockopt_windows.go 38.70% <0.00%> (-9.30%) ⬇️
transport/internet/system_listener.go 51.92% <0.00%> (-2.08%) ⬇️
transport/internet/sockopt_darwin.go 44.44% <14.28%> (-17.10%) ⬇️
transport/internet/system_dialer.go 49.39% <50.00%> (+0.03%) ⬆️
infra/conf/cfgcommon/socketcfg/socket.go 70.37% <100.00%> (+1.13%) ⬆️
transport/pipe/impl.go 87.87% <0.00%> (-2.03%) ⬇️
transport/internet/headers/http/http.go 83.54% <0.00%> (-1.90%) ⬇️
app/dns/dnscommon.go 87.87% <0.00%> (+1.51%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 801d4a1...aa2b82e. Read the comment docs.

@@ -10,7 +10,8 @@ const (
// TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections.
TCP_FASTOPEN_SERVER = 0x01 // nolint: golint,stylecheck
// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
TCP_FASTOPEN_CLIENT = 0x02 // nolint: golint,stylecheck
TCP_FASTOPEN_CLIENT = 0x02 // nolint: golint,stylecheck
TCP_KEEPINTVL = 0x101 // nolint: golint,stylecheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@database64128
Copy link
Contributor

The syscall package recommends using golang.org/x/sys/unix and golang.org/x/sys/windows instead of syscall.

Deprecated: this package is locked down. Callers should use the corresponding package in the golang.org/x/sys repository instead. That is also where updates required by new systems or versions should be applied. See https://golang.org/s/go1.4-syscall for more information.

@xiaokangwang
Copy link
Contributor Author

Okay, I will rewrite these code to use unix instead of syscall.

xiaokangwang added a commit that referenced this pull request Nov 28, 2021
xiaokangwang added a commit that referenced this pull request Nov 28, 2021
@ValdikSS
Copy link
Contributor

Unfortunately this patchset does not handle keep-alive on accept()'ed sockets. Regardless of configured value, it's always 15 seconds.

@ValdikSS
Copy link
Contributor

Oh wait, the patch hasn't been backported to v4.

xiaokangwang added a commit that referenced this pull request Apr 28, 2022
xiaokangwang added a commit that referenced this pull request Apr 28, 2022
yuhan6665 pushed a commit to yuhan6665/Xray-core that referenced this pull request Jul 30, 2022
yuhan6665 pushed a commit to yuhan6665/Xray-core that referenced this pull request Jul 30, 2022
yuhan6665 added a commit to XTLS/Xray-core that referenced this pull request Jul 31, 2022
* Add TCP keep alive idle setting

* Add TCP keep alive idle setting: auto generated

* Add TCP keep alive support in Linux

* Add TCP keep alive support in MacOS, FreeBSD

* Add TCP keep alive support in Windows

* fix bug introduced in adding tcp keep alive adjustment

* embed macOS const to avoid platform inconsistency

* embed macOS const to avoid platform inconsistency(again)

* add TCP Keep Alive support in config

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* Separate TcpKeepAliveIdle and TcpKeepAliveInterval check logic

* Disable tcp keepAlive when TcpKeepAliveIdle < 0 and  TcpKeepAliveInterval <= 0

Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>

Co-authored-by: ValdikSS <iam@valdikss.org.ru>
Co-authored-by: Shelikhoo <xiaokangwang@outlook.com>
Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>
@Loyalsoldier Loyalsoldier deleted the dev-tcpkarev2 branch September 18, 2022 04:15
mwhorse46 added a commit to mwhorse46/Xray-core that referenced this pull request Feb 19, 2023
* Add TCP keep alive idle setting

* Add TCP keep alive idle setting: auto generated

* Add TCP keep alive support in Linux

* Add TCP keep alive support in MacOS, FreeBSD

* Add TCP keep alive support in Windows

* fix bug introduced in adding tcp keep alive adjustment

* embed macOS const to avoid platform inconsistency

* embed macOS const to avoid platform inconsistency(again)

* add TCP Keep Alive support in config

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* Separate TcpKeepAliveIdle and TcpKeepAliveInterval check logic

* Disable tcp keepAlive when TcpKeepAliveIdle < 0 and  TcpKeepAliveInterval <= 0

Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>

Co-authored-by: ValdikSS <iam@valdikss.org.ru>
Co-authored-by: Shelikhoo <xiaokangwang@outlook.com>
Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>
rampagekiller0725 added a commit to rampagekiller0725/wox that referenced this pull request Jun 29, 2023
* Add TCP keep alive idle setting

* Add TCP keep alive idle setting: auto generated

* Add TCP keep alive support in Linux

* Add TCP keep alive support in MacOS, FreeBSD

* Add TCP keep alive support in Windows

* fix bug introduced in adding tcp keep alive adjustment

* embed macOS const to avoid platform inconsistency

* embed macOS const to avoid platform inconsistency(again)

* add TCP Keep Alive support in config

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* Separate TcpKeepAliveIdle and TcpKeepAliveInterval check logic

* Disable tcp keepAlive when TcpKeepAliveIdle < 0 and  TcpKeepAliveInterval <= 0

Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>

Co-authored-by: ValdikSS <iam@valdikss.org.ru>
Co-authored-by: Shelikhoo <xiaokangwang@outlook.com>
Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>
Autumn216 added a commit to Autumn216/wox that referenced this pull request Oct 31, 2023
* Add TCP keep alive idle setting

* Add TCP keep alive idle setting: auto generated

* Add TCP keep alive support in Linux

* Add TCP keep alive support in MacOS, FreeBSD

* Add TCP keep alive support in Windows

* fix bug introduced in adding tcp keep alive adjustment

* embed macOS const to avoid platform inconsistency

* embed macOS const to avoid platform inconsistency(again)

* add TCP Keep Alive support in config

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* use sys/unix instead of syscall

Suggestion from:
v2fly/v2ray-core#1395 (comment)

* Separate TcpKeepAliveIdle and TcpKeepAliveInterval check logic

* Disable tcp keepAlive when TcpKeepAliveIdle < 0 and  TcpKeepAliveInterval <= 0

Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>

Co-authored-by: ValdikSS <iam@valdikss.org.ru>
Co-authored-by: Shelikhoo <xiaokangwang@outlook.com>
Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants