Skip to content
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: 2 additions & 0 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ type SocketConfig struct {
TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"`
TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"`
TCPCongestion string `json:"tcpCongestion"`
V6only bool `json:"v6only"`
Interface string `json:"interface"`
}

Expand Down Expand Up @@ -759,6 +760,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
TcpKeepAliveInterval: c.TCPKeepAliveInterval,
TcpKeepAliveIdle: c.TCPKeepAliveIdle,
TcpCongestion: c.TCPCongestion,
V6Only: c.V6only,
Interface: c.Interface,
}, nil
}
Expand Down
56 changes: 33 additions & 23 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: 2 additions & 0 deletions transport/internet/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,6 @@ message SocketConfig {
string tcp_congestion = 12;

string interface = 13;

bool v6only = 14;
}
6 changes: 6 additions & 0 deletions transport/internet/sockopt_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
}
}

if config.V6Only {
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_IPV6, syscall.IPV6_V6ONLY, 1); err != nil {
return newError("failed to set IPV6_V6ONLY", err)
}
}

return nil
}

Expand Down