@@ -38,7 +38,7 @@ const (
38
38
var VERSION = "SELFBUILD"
39
39
40
40
// handle multiplex-ed connection
41
- func handleMux (conn net.Conn , config * Config , seed []byte ) {
41
+ func handleMux (_Q_ * qpp. QuantumPermutationPad , conn net.Conn , config * Config , seed []byte ) {
42
42
// check if target is unix domain socket
43
43
var isUnix bool
44
44
if _ , _ , err := net .SplitHostPort (config .Target ); err != nil {
@@ -60,12 +60,6 @@ func handleMux(conn net.Conn, config *Config, seed []byte) {
60
60
}
61
61
defer mux .Close ()
62
62
63
- // create shared QPP
64
- var _Q_ * qpp.QuantumPermutationPad
65
- if config .QPP {
66
- _Q_ = qpp .NewQPP (seed , uint16 (config .QPPCount ), QUBIT )
67
- }
68
-
69
63
for {
70
64
stream , err := mux .AcceptStream ()
71
65
if err != nil {
@@ -475,6 +469,12 @@ func main() {
475
469
go http .ListenAndServe (":6060" , nil )
476
470
}
477
471
472
+ // create shared QPP
473
+ var _Q_ * qpp.QuantumPermutationPad
474
+ if config .QPP {
475
+ _Q_ = qpp .NewQPP (pass , uint16 (config .QPPCount ), QUBIT )
476
+ }
477
+
478
478
// main loop
479
479
var wg sync.WaitGroup
480
480
loop := func (lis * kcp.Listener ) {
@@ -500,9 +500,9 @@ func main() {
500
500
conn .SetACKNoDelay (config .AckNodelay )
501
501
502
502
if config .NoComp {
503
- go handleMux (conn , & config , pass )
503
+ go handleMux (_Q_ , conn , & config , pass )
504
504
} else {
505
- go handleMux (generic .NewCompStream (conn ), & config , pass )
505
+ go handleMux (_Q_ , generic .NewCompStream (conn ), & config , pass )
506
506
}
507
507
} else {
508
508
log .Printf ("%+v" , err )
0 commit comments