mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
sync
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"net"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
@@ -11,5 +12,10 @@ func Control(network, address string, c syscall.RawConn) error {
|
||||
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) // 启用地址重用
|
||||
syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1)
|
||||
syscall.SetsockoptLinger(int(fd), syscall.SOL_SOCKET, syscall.SO_LINGER, &syscall.Linger{Onoff: 1, Linger: 0})
|
||||
syscall.SetNonblock(int(fd), true)
|
||||
})
|
||||
}
|
||||
func ChangeControl(conn *net.TCPConn) error {
|
||||
conn.SetNoDelay(true)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -12,5 +12,6 @@ func Control(network, address string, c syscall.RawConn) error {
|
||||
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1) // 启用端口重用
|
||||
syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1)
|
||||
syscall.SetsockoptLinger(int(fd), syscall.SOL_SOCKET, syscall.SO_LINGER, &syscall.Linger{Onoff: 1, Linger: 0})
|
||||
syscall.SetNonblock(int(fd), true)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,5 +11,6 @@ func Control(network, address string, c syscall.RawConn) error {
|
||||
syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) // 启用地址重用
|
||||
syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1)
|
||||
syscall.SetsockoptLinger(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_LINGER, &syscall.Linger{Onoff: 1, Linger: 0})
|
||||
syscall.SetNonblock(syscall.Handle(fd), true)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"log"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"fmt"
|
||||
@@ -90,17 +89,12 @@ func server() {
|
||||
fmt.Fprint(w, "method is not supported")
|
||||
}
|
||||
})
|
||||
tlsCert, err := gtls.CreateCertWithAddr(net.IP{127, 0, 0, 1})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
server := http3.Server{
|
||||
Addr: "0.0.0.0:8080",
|
||||
Handler: mux,
|
||||
TLSConfig: &tls.Config{
|
||||
Certificates: []tls.Certificate{tlsCert},
|
||||
NextProtos: []string{"http3-echo-example"},
|
||||
},
|
||||
TLSConfig: gtls.GetCertConfigForClient(&tls.Config{
|
||||
NextProtos: []string{"http3-echo-example"},
|
||||
}),
|
||||
}
|
||||
fmt.Println("Server is listening...")
|
||||
fmt.Println(server.ListenAndServe())
|
||||
|
||||
Reference in New Issue
Block a user