Skip to content

Instantly share code, notes, and snippets.

@wlach
Created August 29, 2021 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wlach/e2352ae652dea067349627ed671e0d71 to your computer and use it in GitHub Desktop.
Save wlach/e2352ae652dea067349627ed671e0d71 to your computer and use it in GitHub Desktop.
tailscale whois example
#!/usr/bin/env python3
import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
server_address = "/var/run/tailscaled.socket"
sock.connect(server_address)
# this doesn't work
# but `http://local-tailscaled.sock/localapi/v0/status` does
sock.sendall(
b"GET http://local-tailscaled.sock/localapi/v0/whois?addr=100.87.138.81 HTTP/1.1\nHost: local-tailscaled.sock\n\n"
)
print(sock.recv(200))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment