add timeout

This commit is contained in:
xvzc 2022-03-05 08:46:47 +09:00
parent ce40143581
commit b7a76ab5ec

View File

@ -2,6 +2,7 @@ package net
import (
"net"
"time"
log "github.com/sirupsen/logrus"
"github.com/xvzc/SpoofDPI/doh"
@ -56,6 +57,8 @@ func (conn *Conn) ReadBytes() ([]byte, error) {
ret := make([]byte, 0)
buf := make([]byte, BUF_SIZE)
conn.conn.SetReadDeadline(time.Now().Add(3 * time.Second))
for {
n, err := conn.Read(buf)
if err != nil {