Overview
gitGost implements the Git Smart HTTP protocol as defined in the Git documentation. This protocol enables Git clients to communicate with the gitGost service using standardgit push and git fetch commands over HTTP/HTTPS.
The Smart HTTP protocol consists of two main phases:
- Discovery Phase - Client discovers available references and capabilities
- Data Transfer Phase - Client sends or receives packfiles
Protocol Flow
Push Operation (git push)
Fetch Operation (git fetch/pull)
PKT-Line Format
The Git Smart HTTP protocol uses the pkt-line format for all communication. Each line is prefixed with a 4-character hexadecimal length.Format Specification
- Length Prefix: 4 hex digits (includes the 4 bytes itself)
- Data: Variable length payload
- Flush Packet:
0000- indicates end of section
Examples
0032= 50 bytes total (0x32 = 50)- Payload is 46 bytes
Implementation
gitGost implements pkt-line parsing and writing:internal/http/handlers.go:46-55
Capabilities
gitGost advertises the following capabilities during the discovery phase:Receive-Pack (Push) Capabilities
Server will send detailed status about ref updates
Client can delete remote references
Multiplexed progress, error, and data on a single connection
Suppress server-side progress messages
Server understands offset deltas in packfiles
Client can send push options (e.g.,
pr-hash=abc123)internal/http/handlers.go:100
Side-Band-64k Protocol
The side-band-64k protocol allows the server to send three types of messages to the client:Side-Band Format
Each side-band message follows this structure:- length: 4-byte hex length (includes band byte and message)
- band: 1-byte band identifier (0x01, 0x02, or 0x03)
- message: Variable-length data
Example Implementation
internal/http/handlers.go:58-77
Authentication
gitGost requires no authentication for push operations to maintain complete anonymity. The service authenticates with GitHub on behalf of the user using its own bot account.The anonymous nature of gitGost means:
- No username/password required from users
- No SSH keys needed
- No GitHub tokens from contributors
- Complete metadata anonymization
Protocol Endpoints
The Git Smart HTTP protocol is implemented through specific endpoints:- Discovery:
GET /v1/gh/:owner/:repo/info/refs?service=<service> - Data Transfer:
POST /v1/gh/:owner/:repo/<service>
Push Options
gitGost supports custom push options for advanced workflows: Push options are parsed during the packfile extraction phase:internal/git/receive.go:86-90
Security & Rate Limiting
gitGost implements multiple layers of protection:Per-IP Rate Limiting
- Limit: 5 PRs per hour per IP address
- Window: 1 hour sliding window
- Response: HTTP 200 with error in side-band channel
Global Burst Detection
- Monitors: Push attempts across all IPs
- Threshold: 20 pushes from 10+ IPs in 60 seconds
- Action: Admin notification via ntfy
Panic Mode
When activated, all push operations are rejected:Content-Type Headers
Git Smart HTTP uses specific Content-Type headers:Discovery Phase
application/x-git-receive-pack-advertisementapplication/x-git-upload-pack-advertisementData Transfer Phase
application/x-git-receive-pack-requestapplication/x-git-receive-pack-resultapplication/x-git-upload-pack-requestapplication/x-git-upload-pack-resultRelated Resources
Receive-Pack API
POST endpoint for pushing commits
Upload-Pack API
POST endpoint for fetching commits
Git Protocol Docs
Official Git Smart HTTP specification
Quickstart Guide
Get started with gitGost in 2 minutes