GreenTunnel
GreenTunnel is an anti-censorship utility designed to bypass the DPI system that is put in place by various ISPs to block access to certain websites.
Top Related Projects
Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)
Peer-to-peer VPN
Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
A fast TCP/UDP tunnel over HTTP
GO Simple Tunnel - a simple tunnel written in golang
Quick Overview
GreenTunnel is an anti-censorship utility designed to bypass Deep Packet Inspection (DPI). It works by circumventing Internet censorship and online restrictions through various techniques, including DNS-over-HTTPS and SNI manipulation. GreenTunnel is particularly useful in regions where internet access is limited or monitored.
Pros
- Easy to use with a simple command-line interface
- Cross-platform support (Windows, macOS, Linux)
- Implements multiple bypass techniques for improved effectiveness
- Open-source and actively maintained
Cons
- May slow down internet connection due to additional processing
- Not as comprehensive as some VPN solutions
- Requires some technical knowledge to set up and use effectively
- May not work against all types of censorship or blocking methods
Code Examples
// Example 1: Starting GreenTunnel from the command line
greentunnel
// Example 2: Starting GreenTunnel with a custom port
greentunnel --port 8080
// Example 3: Running GreenTunnel with verbose logging
greentunnel --verbose
Getting Started
- Install Node.js (version 10 or higher)
- Install GreenTunnel globally:
npm install -g green-tunnel - Run GreenTunnel:
greentunnel - Configure your system or browser to use the proxy:
- Proxy Address: 127.0.0.1
- Proxy Port: 8000 (default)
For more advanced usage and configuration options, refer to the project's GitHub repository.
Competitor Comparisons
Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)
Pros of sslh
- Multi-protocol support: Handles various protocols (SSH, HTTP, TLS, etc.) on a single port
- Flexible configuration: Allows fine-tuning of protocol detection and forwarding rules
- Active development: Regularly updated with new features and bug fixes
Cons of sslh
- More complex setup: Requires more configuration compared to GreenTunnel's simpler approach
- Higher resource usage: May consume more system resources due to its multi-protocol handling
- Less focused on censorship circumvention: Primarily designed for port multiplexing rather than anti-censorship
Code Comparison
GreenTunnel (JavaScript):
const dns = require('dns');
const net = require('net');
const http = require('http');
const https = require('https');
sslh (C):
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
GreenTunnel focuses on DNS-over-HTTPS and HTTP/HTTPS proxying for censorship circumvention, while sslh is a versatile protocol multiplexer. GreenTunnel is written in JavaScript, making it more accessible for web developers, whereas sslh is implemented in C for better performance and lower-level system integration.
Peer-to-peer VPN
Pros of n2n
- Provides a full peer-to-peer VPN solution, allowing for more complex network topologies
- Supports encryption and compression of network traffic
- Has a longer development history and larger community
Cons of n2n
- More complex setup and configuration compared to GreenTunnel
- Requires superuser privileges to create virtual network interfaces
- May have higher resource usage due to its comprehensive VPN functionality
Code Comparison
n2n (edge node configuration):
edge_conf_t conf;
conf.community_name = "mycommunity";
conf.encrypt_key = "myencryptionkey";
conf.supernode_addr = "1.2.3.4";
conf.supernode_port = 1234;
GreenTunnel (client configuration):
const greenTunnel = new GreenTunnel({
dns: {
server: '1.1.1.1',
port: 853,
},
proxy: {
port: 8080,
},
});
While both projects aim to bypass internet censorship, n2n provides a more comprehensive VPN solution with peer-to-peer capabilities, whereas GreenTunnel focuses on a simpler DNS-over-HTTPS and HTTP proxy approach. n2n offers more flexibility but requires more setup, while GreenTunnel is easier to use but may be less versatile for complex networking scenarios.
Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Pros of wstunnel
- Supports multiple protocols (WebSocket, HTTP2, SOCKS5)
- Offers both client and server components
- More actively maintained with recent updates
Cons of wstunnel
- Less focused on censorship circumvention
- Requires more technical knowledge to set up and use
- May be more complex for basic tunneling needs
Code Comparison
GreenTunnel (JavaScript):
const httpMitmProxy = require('./httpMitmProxy');
const httpProxy = require('./httpProxy');
const dnsOverHttps = require('./dnsOverHttps');
wstunnel (Rust):
use tokio::net::TcpListener;
use tokio_tungstenite::accept_async;
use futures_util::StreamExt;
GreenTunnel focuses on HTTP and DNS manipulation for bypassing censorship, while wstunnel provides a more general-purpose tunneling solution using WebSockets and other protocols. GreenTunnel is written in JavaScript, making it potentially easier for web developers to understand and modify. wstunnel, written in Rust, may offer better performance but requires knowledge of a systems programming language.
Both projects serve different use cases, with GreenTunnel being more specialized for censorship circumvention and wstunnel offering a broader range of tunneling options for various networking scenarios.
A fast TCP/UDP tunnel over HTTP
Pros of Chisel
- More versatile, supporting various protocols (HTTP, SOCKS5, TCP) and tunneling options
- Cross-platform compatibility (Windows, macOS, Linux)
- Active development and larger community support
Cons of Chisel
- More complex setup and configuration
- Requires both client and server components
- Not specifically designed for anti-censorship, unlike GreenTunnel
Code Comparison
GreenTunnel (JavaScript):
const dns = require('dns');
const net = require('net');
const dnsResolve = (hostname) => {
return new Promise((resolve, reject) => {
dns.resolve(hostname, (err, addresses) => {
if (err) reject(err);
else resolve(addresses[0]);
});
});
};
Chisel (Go):
func (c *Client) Start() error {
if err := c.Connect(); err != nil {
return err
}
return c.run()
}
While both projects serve networking purposes, GreenTunnel focuses on DNS manipulation for bypassing censorship, whereas Chisel provides a more general-purpose tunneling solution with a broader range of features and protocols.
GO Simple Tunnel - a simple tunnel written in golang
Pros of gost
- Multi-protocol support (HTTP, SOCKS4, SOCKS5, Shadowsocks)
- Flexible chain proxying and forwarding capabilities
- Cross-platform compatibility (Windows, macOS, Linux, Android, iOS)
Cons of gost
- More complex setup and configuration
- Larger codebase and potentially higher resource usage
- Less focused on specific censorship circumvention techniques
Code Comparison
GreenTunnel (JavaScript):
const net = require('net');
const http = require('http');
const https = require('https');
const url = require('url');
const dns = require('dns');
gost (Go):
import (
"crypto/tls"
"net"
"net/http"
"net/url"
)
Summary
GreenTunnel is a lightweight, focused tool for bypassing Deep Packet Inspection (DPI), primarily targeting HTTP/HTTPS traffic. It's easier to set up and use for specific censorship circumvention scenarios.
gost, on the other hand, is a more comprehensive and versatile proxy solution, supporting multiple protocols and offering advanced features like chain proxying. It's better suited for users who need flexibility and diverse proxy capabilities beyond simple censorship bypass.
The code comparison shows that both projects use similar networking libraries, but gost's implementation in Go may offer performance advantages for certain use cases.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Green Tunnel
GreenTunnel bypasses DPI (Deep Packet Inspection) systems found in many ISPs (Internet Service Providers) which block access to certain websites.
It runs a local proxy that splits the TLS ClientHello so the hostname you are visiting never appears whole in a single packet, and resolves DNS over an encrypted channel so your resolver cannot be used to block or observe you either.
Note: GreenTunnel does not hide your IP address and is not a VPN. It defeats hostname-based blocking, nothing more.
![]() |
GreenTunnel v3 is out now. A ground-up TypeScript rewrite: a new engine with real backpressure and timeouts, RFC 8484 DoH and DoT, a system-proxy layer that snapshots your settings and puts them back â even after a crash â and a rebuilt Electron app with a live log panel. Runtime dependencies are down to two. Open-source tools that help people reach the free internet shouldn't die â and with AI-assisted development, they don't have to. We'll keep doing our best to help people access the open internet, one packet at a time. |
A note from the maintainer
Contribute prompts, not pull requests.
I don't take large diffs anymore. If you want to change something in GreenTunnel, send the prompt instead â the final one, the one you'd hand to your own agent. Open an issue, label it
PROMPT REQUEST, and paste it in.I'll run it against the codebase, review what comes out, and open the PR for you â committed with your email, so it lands in the history as your contribution, because it is one.
Write it like you'd run it yourself: name the files, say what done looks like, say how to verify it. Several prompts in sequence are welcome â that's usually how real work goes. A sharp prompt is worth more to this project than a big patch: it's the part I can't write for you, and it's the part that decides what the code becomes.
Small, focused PRs â a bug fix, a typo, a dead link â are as welcome as they ever were. The world is changing. Let's build with it.
Installation
Requirements
- Node.js 24+ (for the CLI and the library; the desktop app and the Docker image bring their own)
npm (recommended)
npm install -g green-tunnel
After installation, run with gt or green-tunnel.
Desktop app
Download the installer for your OS from the releases page â .dmg for macOS, .exe for Windows, .AppImage or .deb for Linux.
Builds are currently unsigned, so macOS Gatekeeper and Windows SmartScreen will warn on first launch. On macOS, right-click the app and choose Open.
Docker
docker run -p 8000:8000 sadeghhayeri/green-tunnel
Usage
CLI
Usage: gt [options]
Server
--host <ip> Address to bind (default: 127.0.0.1)
-p, --port <n> Port to bind, 0 = random (default: 8000)
--https-only Reject plain HTTP requests
Fragmentation
--no-fragment Forward the ClientHello untouched
--fragment-size <n> Bytes per piece (default: 40)
--tls-records Re-frame pieces as valid TLS records
--fragment-delay <ms> Pause between pieces (default: 0)
DNS
--dns <mode> doh | dot | plain (default: doh)
--doh-url <url> DoH endpoint (default: Cloudflare)
--dot-host <host> DoT server (default: 1.1.1.1)
--dot-port <n> DoT port (default: 853)
--dns-server <ip> Plain resolver, repeatable
--family <pref> ipv4 | ipv6 | ipv4-first | ipv6-first
Other
--no-system-proxy Do not touch the OS proxy settings
--log-level <level> silent | error | warn | info | debug | trace
-q, --quiet No banner, no logs
-h, --help Show this help
-V, --version Show the version
Examples:
# Basic usage (auto-sets the system proxy)
gt
# Custom port
gt --port 9000
# Stricter fragmentation, for DPI that reassembles TCP
gt --tls-records
# DNS over TLS via Quad9
gt --dns dot --dot-host 9.9.9.9
# Leave the OS alone and configure your client yourself
gt --no-system-proxy
# Debug mode
gt --log-level debug
If a site is still blocked, see Good to know.
Docker
# Basic
docker run -p 8000:8000 sadeghhayeri/green-tunnel
# Custom port
docker run -e PORT=9000 -p 9000:9000 sadeghhayeri/green-tunnel
# Run in background, restart on reboot
docker run -d --restart unless-stopped -p 8000:8000 sadeghhayeri/green-tunnel
The container never touches a system proxy â point your client at it.
Environment variables:
| Variable | Description | Default |
|---|---|---|
HOST | Address to bind inside the container | 0.0.0.0 |
PORT | Proxy port | 8000 |
DNS_MODE | doh, dot or plain | doh |
DOH_URL | DoH endpoint | Cloudflare |
DOT_HOST | DoT server, when DNS_MODE=dot | 1.1.1.1 |
DNS_SERVER | Plain resolver, when DNS_MODE=plain | system |
FRAGMENT_SIZE | Bytes per ClientHello piece | 40 |
FRAGMENT_DELAY | Milliseconds between pieces | 0 |
TLS_RECORDS | Set to any value to re-frame as TLS records | off |
NO_FRAGMENT | Set to any value to disable fragmentation | off |
HTTPS_ONLY | Set to any value to block plain HTTP | off |
LOG_LEVEL | silentâ¦trace | info |
Boolean variables are on when set to anything and off when unset â HTTPS_ONLY=false still turns it on.
Desktop app
A 340 px window with an on/off switch, a tray icon, and an Advanced panel for DNS transport, port, fragmentation and log level. It snapshots your system proxy settings before changing them and restores them when it stops â including after a crash, on the next launch.
Library
import { Proxy, SystemProxy, DEFAULT_BYPASS } from 'green-tunnel';
const proxy = new Proxy({
port: 8000,
fragment: { size: 40, tlsRecords: true },
dns: { mode: 'doh' },
});
const { host, port } = await proxy.start();
const system = new SystemProxy();
await system.enable({ host, port, bypass: DEFAULT_BYPASS });
proxy.on('tunnel:open', ({ kind, host }) => {
console.log(`${kind} â ${host}`);
});
// later
await system.disable();
await proxy.stop();
The engine and the gt command ship as one package, so v2's import { Proxy } from 'green-tunnel' still works unchanged. Runtime dependencies are just dns-packet and lru-cache.
How It Works
HTTPS / SNI fragmentation
TLS's Server Name Indication (SNI) extension sends the target hostname in plaintext during the handshake â the one part of an HTTPS connection a DPI box can still read. GreenTunnel splits that handshake at the moment it forwards it:
- TCP split â the ClientHello is written across several small segments, so no single packet contains the whole hostname.
- Record split (
--tls-records) â the handshake is re-framed into several individually valid TLS records. A box that reassembles TCP but inspects record-by-record still never sees a complete SNI. Legal per RFC 8446 §5.1.
HTTP
Plain HTTP requests carry the hostname in the Host header, in the clear. GreenTunnel relays them through the same split, so the header straddles a segment boundary and the DPI cannot match the blocked hostname.
Encrypted DNS
Standard DNS lookups can be intercepted or spoofed by ISPs to block domains at the DNS level. GreenTunnel resolves over DNS over HTTPS (RFC 8484 wire format) or DNS over TLS, so your ISP's resolver cannot return a poisoned answer or log the lookup.
Good to know
- A site is still blocked. Try, in order: a smaller
--fragment-size, then--tls-records, then--fragment-delay 10. Different DPI boxes reassemble differently, and one of the three usually gets through. - Quad9 over DoH doesn't work. Their endpoint refuses HTTP/1.1, which is all
Node's
fetchspeaks. Use--dns dot --dot-host 9.9.9.9instead. - Linux system proxy is GSettings, so it covers GNOME and its relatives. On
other desktops, run with
--no-system-proxyand point your browser at the proxy yourself. - Terminal tools ignore the system proxy. No process can set another's
environment, so
curl,gitand friends needhttp_proxy/https_proxyexported â the CLI prints the exact line for you.
Repository layout
packages/cli/ green-tunnel â the only published package
packages/cli/src/core/ the engine: proxy, TLS fragmentation, DNS, system proxy
apps/desktop/ the Electron app
Development
npm install # workspaces: packages/*, apps/*
npm run check # typecheck + lint + test
npm run build # core, cli, desktop
npm run dev # the desktop app, with HMR
npm run dev:cli # build the CLI and run it
â ï¸ npm run dev points your real system proxy at the app. See
CLAUDE.md for a throwaway-profile recipe, plus architecture
notes, conventions, and what is and is not verified.
Contributing
The main way to contribute code here is to send the prompt you'd run, and let me run it for you.
Prompt requests
Open an issue, label it
PROMPT REQUEST, and paste in the finished prompt â or the sequence of them â
that you want run against the repository. I'll run it, review the result, iterate
if it needs it, and open the PR authored with your email. Tell me which
address to use; otherwise I'll take the one on your GitHub account.
A prompt worth running usually has:
- Scope â the files or areas it should touch, and the ones it must not.
- Intent â what the change is for, so a judgement call goes the right way.
- Done â the observable result. "
gt --port 0prints the chosen port" beats "improve port handling". - Verification â the command that proves it.
npm run checkis the floor; name the test you'd add.
Read CLAUDE.md before you write one. It's the same context I'd be handing the model, and it names the conventions, the constraints, and the mistakes this codebase has already made once.
Pull requests
Still open for the small stuff: a bug fix, a typo, a dead link, a doc correction.
- Use
FIX:,ADD:,UPDATE:prefixes in the title. - Keep commits focused and descriptive.
- Make sure
npm run checkpasses.
Large rewrites and sweeping refactors won't be merged. Send them as a prompt request instead â same work, and you still get the commit.
License
Licensed under the MIT License.
Top Related Projects
Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)
Peer-to-peer VPN
Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
A fast TCP/UDP tunnel over HTTP
GO Simple Tunnel - a simple tunnel written in golang
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot