Read 1024 Bytes a time of stream; more time-precise stats
This commit is contained in:
parent
ba769a8435
commit
f1ec646068
19
knockr.go
19
knockr.go
@ -188,12 +188,17 @@ func proxy(c net.Conn) {
|
|||||||
fmt.Println("[ERR] Proxy connection to server failed")
|
fmt.Println("[ERR] Proxy connection to server failed")
|
||||||
fmt.Println(" Error is ", err)
|
fmt.Println(" Error is ", err)
|
||||||
} else {
|
} else {
|
||||||
// A bit of cluttery code for statistics purposes, sorry.
|
go proxy_writefunc(c, ln, &traffic_in)
|
||||||
go func() {
|
proxy_writefunc(ln, c, &traffic_out)
|
||||||
delta_traffic_in, _ := io.Copy(c, ln)
|
}
|
||||||
traffic_in += delta_traffic_in
|
}
|
||||||
}()
|
|
||||||
delta_traffic_out, _ := io.Copy(ln, c)
|
func proxy_writefunc(a net.Conn, b net.Conn, written_bytes *int64) {
|
||||||
traffic_out += delta_traffic_out
|
var delta int64 = 0
|
||||||
|
var err error
|
||||||
|
|
||||||
|
for err == nil {
|
||||||
|
delta, err = io.CopyN(a, b, 1024)
|
||||||
|
*written_bytes += delta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user