@@ -11,16 +11,12 @@ import (
1111 pb "github.com/refraction-networking/conjure/proto"
1212 tls "github.com/refraction-networking/utls"
1313
14- // td imports assets/ RegError/ generateHTTPRequestBeginning
14+ // td imports assets, RegError, generateHTTPRequestBeginning
1515 td "github.com/refraction-networking/gotapdance/tapdance"
1616
1717 "github.com/sirupsen/logrus"
1818)
1919
20- /**
21- * TODO: enable logging
22- */
23-
2420// timeout for sending TD request and getting a response
2521const deadlineConnectTDStationMin = 11175
2622const deadlineConnectTDStationMax = 14231
@@ -57,30 +53,9 @@ type DecoyRegistrar struct {
5753 // Fields taken from ConjureReg struct
5854 m sync.Mutex
5955 stats * pb.SessionStats
60- }
61-
62- // CurrentClientLibraryVersion returns the current client library version used
63- // for feature compatibility support between client and server. Currently I
64- // don't intend to connect this to the library tag version in any way.
65- //
66- // When adding new client versions comment out older versions and add new
67- // version below with a description of the reason for the new version.
68- func currentClientLibraryVersion () uint32 {
69- // Support for randomizing destination port for phantom connection
70- // https://github.com/refraction-networking/gotapdance/pull/108
71- return 3
72-
73- // // Selection algorithm update - Oct 27, 2022 -- Phantom selection version rework again to use
74- // // hkdf for actual uniform distribution across phantom subnets.
75- // // https://github.com/refraction-networking/conjure/pull/145
76- // return 2
77-
78- // // Initial inclusion of client version - added due to update in phantom
79- // // selection algorithm that is not backwards compatible to older clients.
80- // return 1
81-
82- // // No client version indicates any client before this change.
83- // return 0
56+ // add Width, sharedKeys necessary stuff (2nd line in struct except ConjureSeed)
57+ // Keys
58+ FspKey , FspIv , VspKey , VspIv , NewMasterSecret []byte
8459}
8560
8661func (r * DecoyRegistrar ) setTCPToDecoy (tcprtt * uint32 ) {
@@ -120,24 +95,6 @@ func (r *DecoyRegistrar) getTcpToDecoy() uint32 {
12095 return 0
12196}
12297
123- func generateFlags (cjSession * td.ConjureSession ) * pb.RegistrationFlags {
124- flags := & pb.RegistrationFlags {}
125- mask := default_flags
126- if cjSession .UseProxyHeader {
127- mask |= tdFlagProxyHeader
128- }
129-
130- uploadOnly := mask & tdFlagUploadOnly == tdFlagUploadOnly
131- proxy := mask & tdFlagProxyHeader == tdFlagProxyHeader
132- til := mask & tdFlagUseTIL == tdFlagUseTIL
133-
134- flags .UploadOnly = & uploadOnly
135- flags .ProxyHeader = & proxy
136- flags .Use_TIL = & til
137-
138- return flags
139- }
140-
14198func (r DecoyRegistrar ) createTLSConn (dialConn net.Conn , address string , hostname string , deadline time.Time ) (* tls.UConn , error ) {
14299 var err error
143100 //[reference] TLS to Decoy
@@ -171,8 +128,6 @@ func (r DecoyRegistrar) createTLSConn(dialConn net.Conn, address string, hostnam
171128 return tlsConn , nil
172129}
173130
174- // Register -> Send -> createRequest -> generateVSP -> generateClientToStation
175-
176131func (r * DecoyRegistrar ) createRequest (tlsConn * tls.UConn , decoy * pb.TLSDecoySpec , cjSession * td.ConjureSession ) ([]byte , error ) {
177132 //[reference] generate and encrypt variable size payload
178133 vsp , err := generateVSP (cjSession )
@@ -182,14 +137,14 @@ func (r *DecoyRegistrar) createRequest(tlsConn *tls.UConn, decoy *pb.TLSDecoySpe
182137 if len (vsp ) > int (^ uint16 (0 )) {
183138 return nil , fmt .Errorf ("Variable-Size Payload exceeds %v" , ^ uint16 (0 ))
184139 }
185- encryptedVsp , err := aesGcmEncrypt (vsp , cjSession . Keys . VspKey , cjSession . Keys .VspIv )
140+ encryptedVsp , err := aesGcmEncrypt (vsp , r . VspKey , r .VspIv )
186141 if err != nil {
187142 return nil , err
188143 }
189144
190145 //[reference] generate and encrypt fixed size payload
191146 fsp := generateFSP (uint16 (len (encryptedVsp )))
192- encryptedFsp , err := aesGcmEncrypt (fsp , cjSession . Keys . FspKey , cjSession . Keys .FspIv )
147+ encryptedFsp , err := aesGcmEncrypt (fsp , r . FspKey , r .FspIv )
193148 if err != nil {
194149 return nil , err
195150 }
@@ -277,7 +232,6 @@ func (r DecoyRegistrar) Register(cjSession *td.ConjureSession, ctx context.Conte
277232 }
278233
279234 // randomized sleeping here to break the intraflow signal
280- // TODO: is this okay?
281235 toSleep := r .GetRandomDuration (3000 , 212 , 3449 )
282236 logger .Debugf ("Successfully sent registrations, sleeping for: %v" , toSleep )
283237 lib .SleepWithContext (ctx , toSleep )
@@ -336,7 +290,7 @@ func (r *DecoyRegistrar) Send(ctx context.Context, cjSession *td.ConjureSession,
336290 //[reference] Write reg into conn
337291 _ , err = tlsConn .Write (httpRequest )
338292 if err != nil {
339- // // This will not get printed because it is executed in a goroutine.
293+ // This will not get printed because it is executed in a goroutine.
340294 // Logger().Errorf("%v - %v Could not send Conjure registration request, error: %v", decoy.GetHostname(), decoy.GetIpAddrStr(), err.Error())
341295 tlsConn .Close ()
342296 msg := fmt .Sprintf ("%v - %v Write: %v" , decoy .GetHostname (), decoy .GetIpAddrStr (), err .Error ())
0 commit comments