GO Simple Tunnel (GOST)

repository·master·Indexed 27 days ago

https://github.com/go-gost/gost

A versatile, secure tunneling tool implemented in Go that supports proxying, port forwarding, and intranet penetration. Key features include multi-level forwarding chains, TCP/UDP transparent proxy, DNS resolution, TUN/TAP device support, and a plugin system. It provides a CLI for configuration, a Web API for dynamic management, and Prometheus metrics for monitoring. Supports a wide array of connectors, dialers, handlers, and listeners across various protocols including HTTP2, HTTP3, SOCKS, SSH, and QUIC.

Tokens
1.7K
Snippets
1
Records
11
Agent score
93%

What's inside GOST

  1. Overview of GOST usage modes

    master

    GOST can be used in three primary modes:

    1. Proxy: Acts as a proxy service to access the network. Multiple protocols can be combined to form a forwarding chain for traffic.
    2. Port Forwarding: Maps the port of one service to the port of another service. Like the proxy mode, it supports multi-level forwarding chains using various protocols.
    3. Reverse Proxy: Uses tunnels and intranet penetration to expose local services located behind a NAT or firewall to the public network.
  2. Explore GOST features and tools

    master

    GOST is a feature-rich tunneling tool. Key capabilities include:

    Core Features

    • Multi-port listening and multi-level forwarding chains.
    • Support for multiple protocols and TCP/UDP port forwarding.
    • Reverse proxy and tunneling for intranet penetration.
    • TCP/UDP transparent proxy (redirect).
    • DNS resolution and proxying.
    • TUN/TAP device support and TUN2SOCKS.
    • Load balancing, route control, and admission control.
    • Rate limiting (speed/flow control).
    • Plugin system and dynamic configuration via Web API.
    • Prometheus metrics monitoring.

    Management Tools

  3. Explore GOST features

    master

    GOST provides a wide range of networking and tunneling capabilities, including:

    • Traffic Control: Load balancing, routing control (bypass), admission control, and bandwidth/rate limiting.
    • Networking: TCP/UDP port forwarding, TCP/UDP transparent proxy, DNS resolver and proxy, and TUN/TAP device support (including TUN2SOCKS).
    • Advanced Tunneling: Multi-level forwarding chains, Reverse Proxy, and Reverse Tunnel.
    • Extensibility: Plugin system, Web API, and Dynamic configuration.
    • Observability: Prometheus metrics.
    • Interfaces: GUI (gostctl) and WebUI (gost-ui).
  4. Install GO Simple Tunnel (GOST)

    master

    You can install GOST using several methods: binary files, installation scripts, source compilation, or Docker.

    Installation Methods

    1. Installation Script To install the latest version automatically:

    bash <(curl -fsSL https://github.com/go-gost/gost/raw/master/install.sh) --install

    To select a specific version during installation:

    bash <(curl -fsSL https://github.com/go-gost/gost/raw/master/install.sh)

    2. Source Compilation Clone the repository and build the binary using Go:

    git clone https://github.com/go-gost/gost.git
    cd gost/cmd/gost
    go build

    3. Docker Run the Docker image to verify installation:

    docker run --rm gogost/gost -V

    4. Binary Files Download pre-compiled binaries from the official releases page.

    bash <(curl -fsSL https://github.com/go-gost/gost/raw/master/install.sh) --install
  5. Reload configuration in GO Simple Tunnel

    master

    The GO Simple Tunnel process supports dynamic configuration reloading without a full restart using two methods:

    1. SIGHUP Signal: Sending a SIGHUP signal to the running process triggers a configuration reload.
    2. Auto Reload: If the reload interval is configured, the application will automatically reload the configuration at the specified time intervals.

    When a reload is triggered, the application parses the new configuration, loads the services, and restarts the service layer to match the new settings.

  6. Configure GO Simple Tunnel services

    master

    GO Simple Tunnel supports several built-in management services that can be enabled via configuration:

    • API Service: Provides an interface for managing the instance. It can be configured with a specific address (supporting tcp or unix:// prefixes), a PathPrefix, AccessLog settings, and authentication via Auth strings or a named Auther.
    • Metrics Service: Exposes operational metrics. It supports a specific address (supporting tcp or unix:// prefixes), a Path, and authentication via Auth strings or a named Auther.
    • Profiling Service: Enables Go profiling. By default, it listens on :6060 if no address is provided.
  7. Run multiple GOST instances simultaneously using the '--' separator

    master

    You can run multiple GOST worker processes within a single command execution by using the -- separator. Each segment separated by -- will be treated as a distinct worker process. This allows for running multiple service configurations or node chains in one command execution.

    Example usage:

    gost -L proxy://:8080 -- -L proxy://:8081
  8. Available Connectors, Dialers, Handlers, and Listeners in GO Simple Tunnel

    master

    GO Simple Tunnel supports a wide variety of network protocols and tunneling methods through its extensible architecture. When configuring proxy chains or tunnels, you can utilize the following registered components:

    Connectors

    Used to establish connections to remote services.

    • direct, forward, http, http2, masque, relay, router, serial, sni, socks/v4, socks/v5, ss, ss/udp, sshd, tcp, tunnel, unix

    Dialers

    Used to dial out to destinations.

    • direct, dtls, ftcp, grpc, http2, http2/h2, http3, http3/masque, http3/wt, icmp, kcp, mtcp, mtls, mws, obfs/http, obfs/tls, pht, quic, serial, ssh, sshd, tcp, tls, udp, unix, utls, ws

    Handlers

    Used to process incoming traffic.

    • api, auto, dns, file, forward/local, forward/remote, http, http2, http3, masque, metrics, redirect/tcp, redirect/udp, relay, router, serial, sni, socks/v4, socks/v5, ss, ss/udp, sshd, tap, tun, tungo, tunnel, unix

    Listeners

    Used to listen for incoming connections on specific protocols/interfaces.

    • dns, dtls, ftcp, grpc, http2, http2/h2, http3, http3/h3, http3/wt, icmp, kcp, mtcp, mtls, mws, obfs/http, obfs/tls, pht, quic, redirect/tcp, redirect/udp, rtcp, rudp, runix, serial, stdio, ssh, sshd, tap, tcp, tls, tun, tungo, udp, unix, ws
  9. Use GOST CLI flags for configuration and monitoring

    master

    The gost binary provides several flags to configure services, nodes, configuration sources, and monitoring endpoints.

    Configuration Flags

    • -L <service>: Specify a list of services to run.
    • -F <node>: Specify a list of chain nodes.
    • -C <config>: Provide one or more configuration files, URLs, or inline JSON strings.
    • -O <format>: Set the output format to yaml or json.
    • -R <duration>: Set an auto-reload period (e.g., 30s, 1m).

    Monitoring and Debugging

    • -D: Enable debug mode.
    • -DD: Enable trace mode.
    • --api <address>: Set the API service address.
    • --metrics <address>: Set the metrics service address.
    • -V: Print the version and exit.