@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/dialer"
|
||||
"github.com/xtaci/kcp-go"
|
||||
)
|
||||
|
||||
func BenchmarkRequestsRawTCP(b *testing.B) {
|
||||
@@ -29,25 +28,6 @@ func BenchmarkRequestsRawTCP(b *testing.B) {
|
||||
benchmarkRequestsConnPair(b, conn0, conn1)
|
||||
}
|
||||
|
||||
func BenchmarkRequestsRawKCP(b *testing.B) {
|
||||
b.Skip("KCP broken")
|
||||
|
||||
// Benchmarks the rate at which we can serve requests over a single,
|
||||
// unencrypted KCP channel over the loopback interface.
|
||||
|
||||
// Get a connected KCP pair
|
||||
conn0, conn1, err := getKCPConnectionPair()
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
defer conn0.Close()
|
||||
defer conn1.Close()
|
||||
|
||||
// Bench it
|
||||
benchmarkRequestsConnPair(b, conn0, conn1)
|
||||
}
|
||||
|
||||
func BenchmarkRequestsTLSoTCP(b *testing.B) {
|
||||
conn0, conn1, err := getTCPConnectionPair()
|
||||
if err != nil {
|
||||
@@ -58,18 +38,6 @@ func BenchmarkRequestsTLSoTCP(b *testing.B) {
|
||||
benchmarkRequestsTLS(b, conn0, conn1)
|
||||
}
|
||||
|
||||
func BenchmarkRequestsTLSoKCP(b *testing.B) {
|
||||
b.Skip("KCP broken")
|
||||
|
||||
conn0, conn1, err := getKCPConnectionPair()
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
defer conn0.Close()
|
||||
defer conn1.Close()
|
||||
benchmarkRequestsTLS(b, conn0, conn1)
|
||||
}
|
||||
|
||||
func benchmarkRequestsTLS(b *testing.B, conn0, conn1 net.Conn) {
|
||||
// Benchmarks the rate at which we can serve requests over a single,
|
||||
// TLS encrypted channel over the loopback interface.
|
||||
@@ -170,35 +138,6 @@ func getTCPConnectionPair() (net.Conn, net.Conn, error) {
|
||||
return conn0, conn1, nil
|
||||
}
|
||||
|
||||
func getKCPConnectionPair() (net.Conn, net.Conn, error) {
|
||||
lst, err := kcp.Listen("127.0.0.1:0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var conn0 net.Conn
|
||||
var err0 error
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
conn0, err0 = lst.Accept()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
// Dial the connection
|
||||
conn1, err := kcp.Dial(lst.Addr().String())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Check any error from accept
|
||||
<-done
|
||||
if err0 != nil {
|
||||
return nil, nil, err0
|
||||
}
|
||||
|
||||
return conn0, conn1, nil
|
||||
}
|
||||
|
||||
func negotiateTLS(cert tls.Certificate, conn0, conn1 net.Conn) (net.Conn, net.Conn) {
|
||||
cfg := &tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
|
||||
Reference in New Issue
Block a user