MCPcopy Create free account
hub / github.com/SamNet-dev/snix / newFakeClientHello

Method newFakeClientHello

core/engine/engine.go:321–342  ·  view source on GitHub ↗

newFakeClientHello picks an SNI per the randomizer, builds a ClientHello with randomized extra padding, and returns both the bytes and the SNI used (for logging).

()

Source from the content-addressed store, hash-verified

319// with randomized extra padding, and returns both the bytes and the SNI used
320// (for logging).
321func (e *Engine) newFakeClientHello() ([]byte, string, error) {
322 sni := e.rnd.PickSNI(e.cfg.SNIPool)
323 if sni == "" {
324 return nil, "", errors.New("engine: empty SNI pool")
325 }
326 var rnd, sess, ks [32]byte
327 if _, err := rand.Read(rnd[:]); err != nil {
328 return nil, "", err
329 }
330 if _, err := rand.Read(sess[:]); err != nil {
331 return nil, "", err
332 }
333 if _, err := rand.Read(ks[:]); err != nil {
334 return nil, "", err
335 }
336 extra := e.rnd.ExtraPad()
337 buf, err := injector.BuildClientHelloPadded(rnd[:], sess[:], []byte(sni), ks[:], extra)
338 if err != nil {
339 return nil, "", err
340 }
341 return buf, sni, nil
342}
343
344func (e *Engine) infof(format string, args ...any) {
345 if e.cfg.Log != nil {

Callers 1

handleOutboundMethod · 0.95

Calls 3

BuildClientHelloPaddedFunction · 0.92
PickSNIMethod · 0.80
ExtraPadMethod · 0.80

Tested by

no test coverage detected