]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/egd.go
Forbid any later GNU GPL versions autousage
[govpn.git] / src / cypherpunks.ru / govpn / egd.go
index 04ec87b9678cf2dfa10c576c84bfc66bbe4ef493..f06296cda1065b6c83fa395ff309d02ac9198487 100644 (file)
@@ -1,11 +1,10 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2019 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
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, version 3 of the License.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,13 +19,12 @@ package govpn
 
 import (
        "crypto/rand"
-       "errors"
        "io"
        "net"
 )
 
 var (
-       Rand io.Reader = rand.Reader
+       Rand = rand.Reader
 )
 
 type EGDRand string
@@ -37,18 +35,9 @@ func (egdPath EGDRand) Read(b []byte) (int, error) {
        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) {