2025-05-08 20:07:44 -04:00
2025-04-10 19:41:08 -04:00
2025-04-10 19:41:08 -04:00
2025-05-05 15:48:01 -04:00
2025-05-05 15:48:01 -04:00
2025-04-10 19:41:08 -04:00
2025-05-08 05:16:20 +00:00
2025-04-18 23:19:56 -04:00
2025-04-10 19:42:25 -04:00
2025-05-08 20:07:44 -04:00
2025-05-04 05:00:58 +00:00

go-gitlooseleaf

A soft-fork of Gitea that enables simultaneous multi-protocol access via standard TLS, I2P, and Tor onion services. This repository contains only the network interface modules and CI configuration needed to build custom Gitea binaries.

How It Works

This project leverages GitHub Actions to automatically build a modified version of Gitea that can simultaneously serve content over multiple protocols:

  • Standard HTTPS/TLS connections
  • I2P (Invisible Internet Project) network
  • Tor onion services

The beauty of this approach is that it requires no changes to Gitea's core codebase, as Gitea intelligently encapsulates network operations through abstraction:

  1. Network Listeners: Gitea uses graceful.GetListener() (defined in modules/graceful/server.go) for all incoming connections
  2. Network Clients: Gitea's HTTP client connections can be configured with custom transport implementations

We take advantage of these abstractions by replacing the default implementations with our multi-protocol versions during the build process.

Implementation Details

The network listener replacement works because Gitea's default GetListener() implementations (DefaultGetListener()) are defined in platform-specific files:

  • modules/graceful/net_unix.go for Unix-like systems
  • modules/graceful/net_windows.go for Windows

Our implementation introduces a MultiGetListener() function that handles TLS, I2P, and Tor connections using the go-meta-listener package, while still supporting Unix sockets for internal functions.

Similarly, we replace the default HTTP client with a version that can route traffic through the appropriate network (TLS, I2P, or Tor) based on the destination.

Current Implementation

The current implementation in net_mirror.go uses:

  • go-meta-listener/mirror for listening on multiple protocols
  • Rate limiting through go-i2p/go-limit
  • Environment variables (EMAIL, HOSTNAME) for configuration
// This implements the GetListener function for TLS, I2P, and Onion
func MultiGetListener(network, address string) (net.Listener, error) {
    // Support for Unix sockets remains unchanged
    if network == "unix" || network == "unixpacket" {
        unixAddr, err := ResolveUnixAddr(network, address)
        if err != nil {
            return nil, err
        }
        return GetListenerUnixWrapper(network, unixAddr)
    }
    
    // For TCP connections, create a multi-protocol mirror listener
    ml, err := mirrorListener.Listen(address, os.Getenv("EMAIL"), "./certs", true)
    if err != nil {
        return nil, err
    }
    
    // Apply rate limiting
    return limitedlistener.NewLimitedListener(ml,
        limitedlistener.WithMaxConnections(500), // concurrent connections
        limitedlistener.WithRateLimit(24),       // connections per second
    ), nil
}

Usage Caveats

While the HTTP interface works seamlessly across all three protocols, other Gitea communication channels require additional configuration:

  1. SMTP Client: If configured, email connections from Gitea will need proper routing:

    • For I2P: Use local ports like 127.0.0.1:7659/7660
    • For Tor: Configure appropriate SOCKS proxy settings
  2. SSH Connections: Git operations over SSH require additional configuration to properly route through anonymity networks. These settings depend on your specific deployment environment.

  3. Environment Variables:

    • EMAIL: Used for TLS certificate generation (required for HTTPS)
    • HOSTNAME: Server hostname (defaults to local machine name if not set)

Installation

You can:

  1. Download prebuilt binaries from the releases page
  2. Use the included install.sh script to set up a system service
  3. Build from source using the GitHub Actions workflows as a reference

License

Both this modification and Gitea itself are licensed under the MIT license.

Description
A soft-fork of gitea with support for running as an Clearnet TLS, I2P, and Onion service simultaneously. Just the mod and the CI files.
Readme MIT 458 KiB
Languages
Go 45.8%
Makefile 37.8%
Shell 16.4%