package obfuscated2

import (
	
	
)

// Metadata represents metadata received from header.
type Metadata struct {
	Protocol [4]byte
	DC       uint16
}

// Accept creates new io.ReadWriter for server-side deobfuscation.
func ( io.ReadWriter,  []byte) (io.ReadWriter, Metadata, error) {
	var (
		  = make([]byte, 64)
		 Metadata
	)
	if ,  := io.ReadFull(, );  != nil {
		return nil, , 
	}

	var  keys
	if  := .createStreams(, );  != nil {
		return nil, , 
	}
	// Swap to match client's streams.
	.encrypt, .decrypt = .decrypt, .encrypt

	var  [64]byte
	.decrypt.XORKeyStream([:], )

	copy(.Protocol[:], [56:60])
	.DC = binary.LittleEndian.Uint16([60:62])

	return &Obfuscated2{
		rand: nil, // Used only in Handshake.
		conn: ,
		keys: ,
	}, , nil
}