mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2025-01-03 04:50:11 +00:00
add timeout
This commit is contained in:
parent
ce40143581
commit
b7a76ab5ec
@ -2,6 +2,7 @@ package net
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/xvzc/SpoofDPI/doh"
|
"github.com/xvzc/SpoofDPI/doh"
|
||||||
@ -56,6 +57,8 @@ func (conn *Conn) ReadBytes() ([]byte, error) {
|
|||||||
ret := make([]byte, 0)
|
ret := make([]byte, 0)
|
||||||
buf := make([]byte, BUF_SIZE)
|
buf := make([]byte, BUF_SIZE)
|
||||||
|
|
||||||
|
conn.conn.SetReadDeadline(time.Now().Add(3 * time.Second))
|
||||||
|
|
||||||
for {
|
for {
|
||||||
n, err := conn.Read(buf)
|
n, err := conn.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user