mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
Just some commented-out SetReadDeadline() experiments
This commit is contained in:
parent
942b8865cf
commit
e09f052f45
2 changed files with 17 additions and 5 deletions
|
@ -35,7 +35,6 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Accepted client")
|
fmt.Println("Accepted client")
|
||||||
|
|
||||||
// Handle the connection in a new goroutine.
|
// Handle the connection in a new goroutine.
|
||||||
|
|
15
hkexnet.go
15
hkexnet.go
|
@ -27,12 +27,14 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Conn is a HKex connection - a drop-in replacement for net.Conn
|
// Conn is a HKex connection - a drop-in replacement for net.Conn
|
||||||
type Conn struct {
|
type Conn struct {
|
||||||
|
//net.Conn
|
||||||
c net.Conn // which also implements io.Reader, io.Writer, ...
|
c net.Conn // which also implements io.Reader, io.Writer, ...
|
||||||
h *HerraduraKEx
|
h *HerraduraKEx
|
||||||
cipheropts uint32 // post-KEx cipher/hmac options
|
cipheropts uint32 // post-KEx cipher/hmac options
|
||||||
|
@ -42,6 +44,10 @@ type Conn struct {
|
||||||
w cipher.Stream
|
w cipher.Stream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Conn) SetReadDeadline(t time.Time) error {
|
||||||
|
return c.SetReadDeadline(t)
|
||||||
|
}
|
||||||
|
|
||||||
// ConnOpts returns the cipher/hmac options value, which is sent to the
|
// ConnOpts returns the cipher/hmac options value, which is sent to the
|
||||||
// peer but is not itself part of the KEx.
|
// peer but is not itself part of the KEx.
|
||||||
//
|
//
|
||||||
|
@ -243,6 +249,7 @@ func (hl *HKExListener) Accept() (hc Conn, err error) {
|
||||||
hc.w = hc.getStream(hc.h.fa)
|
hc.w = hc.getStream(hc.h.fa)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Read into a byte slice
|
// Read into a byte slice
|
||||||
|
@ -250,9 +257,15 @@ func (hl *HKExListener) Accept() (hc Conn, err error) {
|
||||||
// See go doc io.Reader
|
// See go doc io.Reader
|
||||||
func (c Conn) Read(b []byte) (n int, err error) {
|
func (c Conn) Read(b []byte) (n int, err error) {
|
||||||
fmt.Printf("[Decrypting...]\n")
|
fmt.Printf("[Decrypting...]\n")
|
||||||
|
|
||||||
|
//c.c.SetReadDeadline(time.Now().Add(1 * time.Second))
|
||||||
n, err = c.c.Read(b)
|
n, err = c.c.Read(b)
|
||||||
if err != nil && err.Error() != "EOF" {
|
if err != nil && err.Error() != "EOF" {
|
||||||
panic(err)
|
//if neterr, ok := err.(net.Error); ok {
|
||||||
|
// fmt.Printf("[Read() timeout - %s]\n", neterr)
|
||||||
|
//} else {
|
||||||
|
// panic(err)
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
fmt.Printf(" ctext:%+v\n", b[:n]) // print only used portion
|
fmt.Printf(" ctext:%+v\n", b[:n]) // print only used portion
|
||||||
db := bytes.NewBuffer(b[:n])
|
db := bytes.NewBuffer(b[:n])
|
||||||
|
|
Loading…
Reference in a new issue