This commit is contained in:
Jaewook Lee
2024-11-30 01:19:39 -05:00
parent 4dd1f83501
commit 70b8ead10a
3 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
0,1,2
1,4014.52,4014.52
2,7866.07,3933.035
3,10550.74,3516.9133333333334
4,14024.92,3506.23
5,14161.24,2832.248
6,14438.38,2406.3966666666665
7,14620.7,2088.671428571429
8,14785.37,1848.17125
1 0 1 2
2 1 4014.52 4014.52
3 2 7866.07 3933.035
4 3 10550.74 3516.9133333333334
5 4 14024.92 3506.23
6 5 14161.24 2832.248
7 6 14438.38 2406.3966666666665
8 7 14620.7 2088.671428571429
9 8 14785.37 1848.17125

View File

@@ -14,6 +14,7 @@ export LLAMA_ARG_CTX_SIZE=65536
# export LC_ALL=C.UTF-8
alias rerun="docker compose down && docker compose up -d --build && docker compose logs -f"
export PATH="/usr/local/bin:/home/w/.cache/ms-playwright/chromium-1129/chrome-linux:$PATH"
export OLLAMA_HOST=host.docker.internal:11434

47
wireguard/wg-conf.py Executable file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/env python3
import subprocess, textwrap
def bash(command, input=None):
return subprocess.run(
command, shell=True, input=input, capture_output=True, text=True
)
def keygen():
privatekey = bash("wg genkey").stdout.strip()
publickey = bash("wg pubkey", privatekey).stdout.strip()
return {"private": privatekey, "public": publickey}
def server_conf(server, clients, server_port=51820):
return textwrap.dedent(
f"""
# server.conf
[Interface]
PrivateKey = {server['private']}
Address = 10.0.0.1/24
ListenPort = {server_port}
"""
+ "".join(
f"""
[Peer]
PublicKey = {client['public']}
AllowedIPs = 10.0.0.{idx+2}/32
"""
for idx, client in enumerate(clients)
)
)
# def client_conf(server_key, client_key, server_ip, server_port=51820):
if __name__ == "__main__":
assert bash("wg -v").returncode == 0
server = keygen()
clients = [keygen() for _ in range(2)]
print(server_conf(server, clients))