/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
import (
"crypto/rand"
- "errors"
"io"
"net"
)
var (
- Rand io.Reader = rand.Reader
+ Rand = rand.Reader
)
type EGDRand string
if err != nil {
return 0, err
}
+ defer conn.Close()
conn.Write([]byte{0x02, byte(len(b))})
- read, err := conn.Read(b)
- if err != nil {
- conn.Close()
- return read, err
- }
- if read != len(b) {
- conn.Close()
- return read, errors.New("Got less bytes than expected from EGD")
- }
- conn.Close()
- return read, nil
+ return io.ReadFull(conn, b)
}
func EGDInit(path string) {