// Start is called before the first frame update
    void Start()
    {
        Debug.Log(QuicheVersion.GetVersion());
        QuicheDebug.EnableDebugLogging((line, argp) => {
            Debug.Log(line);
        });
        var localAddress = IPAddress.Parse(localIpString);
        var localEP      = new IPEndPoint(localAddress, localPort);

        udpClient = new UdpClient(localEP);
        var config = new QuicheConfig(QuicheVersion.QUICHE_PROTOCOL_VERSION);

        byte[] protos = Encoding.ASCII.GetBytes("\x05hq-24\x05hq-23\x08http/0.9");
        config.LoadCertChainFromPemFile($"{Application.dataPath}/Server/cert.crt");
        config.LoadPrivKeyFromPemFile($"{Application.dataPath}/Server/cert.key");
        config.SetApplicationProtos(protos);
        config.SetIdleTimeout(5000);
        config.SetMaxPacketSize(QuicheClient.MAX_DATAGRAM_SIZE);
        config.SetInitialMaxData(10000000);
        config.SetInitialMaxStreamDataBidiLocal(1000000);
        config.SetInitialMaxStreamDataBidiRemote(1000000);
        config.SetInitialMaxStreamDataUni(1000000);
        config.SetInitialMaxStreamsBidi(100);
        config.SetInitialMaxStreamsUni(100);
        config.SetDisableActiveMigration(true);
        if (earlyData)
        {
            config.EnableEarlyData();
        }
        quiche = new QuicheListener(config);
    }
    // Start is called before the first frame update
    void Start()
    {
        uri = new Uri(urlString);
        Debug.Log(QuicheVersion.GetVersion());
        QuicheDebug.EnableDebugLogging((line, argp) => {
            Debug.Log(line);
        });
        client = new UdpClient();

        var config = new QuicheConfig(0xbabababa);

        byte[] protos = Encoding.ASCII.GetBytes("\x05hq-24\x05hq-23\x08http/0.9");
        config.SetApplicationProtos(protos);
        config.SetIdleTimeout(5000);
        config.SetMaxPacketSize(QuicheClient.MAX_DATAGRAM_SIZE);
        config.SetInitialMaxData(10000000);
        config.SetInitialMaxStreamDataBidiLocal(1000000);
        config.SetInitialMaxStreamDataUni(1000000);
        config.SetInitialMaxStreamsBidi(100);
        config.SetInitialMaxStreamsUni(100);
        config.SetDisableActiveMigration(true);
        config.VerifyPeer(false);
        quiche = new QuicheClient(config);
        Connect();
    }
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        uri = new Uri(urlString);
        Debug.Log(QuicheVersion.GetVersion());
        if (isDebugLog)
        {
            QuicheDebug.EnableDebugLogging((line, argp) => {
                Debug.Log(line);
            });
        }
        udpClient    = new UdpClient();
        quicheClient = new QuicheClient(CreateQuicheConfig());
        udpClient.Connect($"{uri.Host}", uri.Port);
        quicheConn = quicheClient.Connect(uri.Authority);
        Debug.Log(
            $"connecting to {uri.Authority} from {udpClient.Client.LocalEndPoint} "
            + $"with scid {quicheClient.HexDump}");
        // initial send
        int write = quicheConn.Send(buf);

        udpClient.Send(buf, write);

        h3Config = new H3Config();
        // Prepare request.
        var reqList = new H3Header[] {
            new H3Header(":method", "GET"),
            new H3Header(":scheme", "https"),
            new H3Header(":authority", uri.Host),
            new H3Header(":path", uri.PathAndQuery),
            new H3Header("user-agent", "unity-quiche"),
        }.ToList();

        // TODO Add custom headers to the request.

        // TODO Add body
        body = null;
        if (body != null)
        {
            reqList.Add(new H3Header(
                            "content-length", $"{body.Length}"));
        }
        req = reqList.ToArray();
    }