private/server: fix fastopen socket option

Change-Id: I7acbe0562ebfe9d78dae5c57f6057b8364dfa0e7
This commit is contained in:
Egon Elbre 2023-01-31 15:59:04 +02:00
parent 9bb9275acf
commit 053beef8c4
2 changed files with 44 additions and 2 deletions

View File

@ -9,10 +9,10 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
) )
const tcpFastOpen = 0x17 const tcpFastOpenServer = 15
func setTCPFastOpen(fd uintptr, queue int) error { func setTCPFastOpen(fd uintptr, queue int) error {
return syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_TCP, tcpFastOpen, queue) return syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_TCP, tcpFastOpenServer, 1)
} }
func tryInitFastOpen(*zap.Logger) {} func tryInitFastOpen(*zap.Logger) {}

View File

@ -4,19 +4,61 @@
package server_test package server_test
import ( import (
"context"
"os"
"strconv" "strconv"
"strings"
"testing" "testing"
"time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
"storj.io/common/errs2"
"storj.io/common/identity/testidentity"
"storj.io/common/peertls/tlsopts" "storj.io/common/peertls/tlsopts"
"storj.io/common/rpc" "storj.io/common/rpc"
_ "storj.io/common/rpc/quic" _ "storj.io/common/rpc/quic"
"storj.io/common/storj" "storj.io/common/storj"
"storj.io/common/testcontext" "storj.io/common/testcontext"
"storj.io/storj/private/server"
"storj.io/storj/private/testplanet" "storj.io/storj/private/testplanet"
) )
func TestServer(t *testing.T) {
ctx := testcontext.New(t)
log := zaptest.NewLogger(t)
identity := testidentity.MustPregeneratedIdentity(0, storj.LatestIDVersion())
host := "127.0.0.1"
if hostlist := os.Getenv("STORJ_TEST_HOST"); hostlist != "" {
host, _, _ = strings.Cut(hostlist, ";")
}
tlsOptions, err := tlsopts.NewOptions(identity, tlsopts.Config{
PeerIDVersions: "latest",
}, nil)
require.NoError(t, err)
instance, err := server.New(log.Named("server"), tlsOptions, server.Config{
Address: host + ":0",
PrivateAddress: host + ":0",
TCPFastOpen: true,
TCPFastOpenQueue: 256,
})
require.NoError(t, err)
defer func() {
require.NoError(t, instance.Close())
}()
serverCtx, serverCancel := context.WithTimeout(ctx, time.Second)
defer serverCancel()
err = instance.Run(serverCtx)
err = errs2.IgnoreCanceled(err)
require.NoError(t, err)
}
func TestHybridConnector_Basic(t *testing.T) { func TestHybridConnector_Basic(t *testing.T) {
testplanet.Run(t, testplanet.Config{ testplanet.Run(t, testplanet.Config{
SatelliteCount: 1, SatelliteCount: 1,