import { CipherSuiteList } from "../../cipher/const" ; import { CipherContext } from "../../context/cipher" ; import { DtlsContext } from "../../context/dtls" ; import { TransportContext } from "../../context/transport" ; import { ClientHello } from "../../handshake/message/client/hello" ; import { DtlsRandom } from "../../handshake/random" ; import { Extension } from "../../typings/domain" ; import { Flight } from "../flight" ; export class Flight1 extends Flight { constructor ( udp , dtls , private cipher ) { super ( udp , dtls , 1 , 3 ) ; } async exec ( extensions ) { if ( this . dtls . flight === 1 ) throw new Error ( ) ; this . dtls . flight = 1 ; const hello = new ClientHello ( { major : 255 - 1 , minor : 255 - 2 } , new DtlsRandom ( ) , Buffer . from ( [ ] ) , Buffer . from ( [ ] ) , CipherSuiteList , [ 0 ] , extensions ) ; this . dtls . version = hello . clientVersion ; this . cipher . localRandom = DtlsRandom . from ( hello . random ) ; const packets = this . createPacket ( [ hello ] ) ; const buf = Buffer . concat ( packets . map ( ( v ) => v . serialize ( ) ) ) ; await this . transmit ( [ buf ] ) ; } }