Skip to content

Instantly share code, notes, and snippets.

/**
* Pull request #651 (https://github.com/h2o/quicly/pull/651) introduced an extra parameter called `payload` that specifies the
* location of the payload to be encrypted (i.e., out-of-place encryption). Custom encryption callbacks can either adopt the new
* API directly, or use a wrapper function that copies the out-of-place payload then calls the original function.
*
* The function below is an example of such a wrapper function.
*/
void new_encrypt_packet(struct st_quicly_crypto_engine_t *engine, quicly_conn_t *conn, ptls_cipher_context_t *header_protect_ctx,
ptls_aead_context_t *packet_protect_ctx, ptls_iovec_t datagram, size_t first_byte_at,
size_t payload_from, const void *payload, uint64_t packet_number, int coalesced)
diff --git a/t/50connect-eyeballs.t b/t/50connect-eyeballs.t
index 832c1b051..717ac0729 100644
--- a/t/50connect-eyeballs.t
+++ b/t/50connect-eyeballs.t
@@ -1,5 +1,6 @@
use strict;
use warnings;
+use File::Temp qw(tempdir);
use IO::Socket::IP;
use Test::More;
#include <stdint.h>
#include <stdio.h>
#include <openssl/engine.h>
#include <openssl/provider.h>
#include "picotls.h"
#include "picotls/openssl.h"
int main(int argc, char **argv)
{
OSSL_PROVIDER *legacy = OSSL_PROVIDER_load(NULL, "legacy");
@kazuho
kazuho / llmproxy.js
Last active May 9, 2025 01:36
proxy that adds function call capabilities to llama.cpp server
// proxy.js
// Express server wrapping llama.cpp server with OpenAI function-calling semantics
// Logs client requests/responses and model requests/responses to console
const express = require('express');
const axios = require('axios');
const bodyParser = require('body-parser');
const { v4: uuidv4 } = require('uuid');
const { spawn } = require('child_process');
@kazuho
kazuho / addmib.pl
Last active March 1, 2025 06:57
tiny memory load generator
#! /usr/bin/perl
use strict;
use warnings;
while (my $l = <STDIN>) {
chomp $l;
if ($l !~ /MiB/ and $l =~ /([0-9]+,[0-9,]+)/) {
$l .= toMiB($1);
}
@kazuho
kazuho / freespace.rb
Last active July 4, 2024 07:37
calculate amount of disk space returned, once all the given files and directories are removed
#!/usr/bin/env ruby
require 'find'
BLOCK_SIZE = 512 # ブロックサイズは通常 512 バイト
def calculate_freed_space(paths)
inodes = {}
total_blocks = 0
processed_files = {}
@kazuho
kazuho / sshd-tcpd.socket
Last active July 3, 2024 14:29
sshd + tcp wrappers
# こいつは systemctl enable sshd-tcpd.socket する
[Unit]
Description=ssh
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
Conflicts=ssh.socket
[Socket]
ListenStream=22
Accept=yes
@kazuho
kazuho / nespresso.scad
Created January 8, 2024 10:34
Nespressoカプセルホルダ(OpenSCAD形式)レイヤ0.2mm前提
Rtop = 12;
Htop = 25;
Rin = 15;
Rout = 20;
H = 2 + (Rout - Rin) / 1.5;
thick = 1.2;
rows = 7;
cols = 5;
for (i = [0:cols - 1]) {
# 必要なモジュールのインポート
import numpy as np
import scipy.stats as stats
# カウントされた足の本数
counts = np.array([57, 62, 63, 60, 57, 60, 58, 60, 61, 62])
# つるとかめの個体数は合計で20匹
total_animals = 20
2752512 bytes alive from 0x7f8e184d27d1, alloc=84, free=0, collision=0
X509_VAL_it at ??:?
SSL_set_ciphersuites at ??:?
966000 bytes alive from 0x7f8e185b746e, alloc=29642, free=26548, collision=0
CRYPTO_zalloc at ??:?
229376 bytes alive from 0x7f8e184d27d1, alloc=7, free=0, collision=0
X509_VAL_it at ??:?