Просмотр исходного кода

Seed the random number generator so that generated fronting addresses are unpredictable.

Adam Kruger 10 лет назад
Родитель
Сommit
70e758faa1
2 измененных файлов с 5 добавлено и 1 удалено
  1. 4 0
      psiphon/controller.go
  2. 1 1
      psiphon/tunnel.go

+ 4 - 0
psiphon/controller.go

@@ -25,6 +25,7 @@ package psiphon
 
 import (
 	"errors"
+	"math/rand"
 	"net"
 	"sync"
 	"time"
@@ -62,6 +63,9 @@ type Controller struct {
 // NewController initializes a new controller.
 func NewController(config *Config) (controller *Controller, err error) {
 
+	// Needed by regen, at least
+	rand.Seed(int64(time.Now().Nanosecond()))
+
 	// Generate a session ID for the Psiphon server API. This session ID is
 	// used across all tunnels established by the controller.
 	sessionId, err := MakeSessionId()

+ 1 - 1
psiphon/tunnel.go

@@ -30,9 +30,9 @@ import (
 	"sync"
 	"time"
 
+        "github.com/Psiphon-Inc/goregen"
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/transferstats"
 	"golang.org/x/crypto/ssh"
-        "github.com/Psiphon-Inc/goregen"
 )
 
 // Tunneler specifies the interface required by components that use a tunnel.