Command Line¶
Usage¶
GOST has the following command line options:
-L
- Specify local service(s)¶
The value of this parameter is in URL-like format (the content in square brackets can be omitted):
For port forwarding mode
scheme¶
It can be a combination of a handler and a listener, or a single handler (the listener defaults to tcp) or a listener (the handler defaults to auto), for example:
http+tls
- The combination of the http handler and the tls listener specifies the HTTPS proxy service.http
- Equivalent tohttp+tcp
, the combination of the handler http and the listener tcp, specifies the HTTP proxy service.tcp
- Equivalent totcp+tcp
, a combination of handler tcp and listener tcp, specifies TCP port forwarding.tls
- Equivalent toauto+tls
, a combination of handler auto and listener tls.
# http+tcp
gost -L http://:8080
# http+tcp -> socks5+tcp
gost -L http://:8080 -L socks5://:1080?foo=bar
# http+tls
gost -L http+tls://gost:gost@:8443
# auto+tls
gost -L tls://:8443
# tcp+tcp或forward+tcp
gost -L tcp://:8080/192.168.1.1:80
# Port forwarding mode supports the following forwarding target address list format:
gost -L tcp://:8080/192.168.1.1:80,192.168.1.2:80,192.168.1.3:8080
-F
- Specify forwarding node(s) to form a forwarding chain¶
This parameter value is in URL-like format (the content in square brackets can be omitted).
scheme¶
It can be a combination of a connector and a dialer, or a single connector (the default for the dialer is tcp) or a dialer (the default for the connector is http), for example:
http+tls
- A combination of connector http and dialer tls, specifying the HTTPS proxy node.http
- Equivalent tohttp+tcp
, a combination of the handler http and the listener tcp, specifying the HTTP proxy node.tls
- Equivalent tohttp+tls
.
# multi-level forwarding
gost -L http://:8080 \
-F http://gost:gost@192.168.1.1:8080 \
-F socks5+tls://192.168.1.2:1080?foo=bar
# You can also form a node group by setting an address list:
gost -L http://:8080 -F http://gost:gost@192.168.1.1:8080,192.168.1.2:8080
Special Characters
On some systems, certain characters (for example &
, !
) have special meanings and functions in command lines. If the scheme contains these special characters, use double quotes "
.
-C
- Specify the path or content of the external configuration file¶
# Use the configuration file gost.yml
gost -C /etc/gost/gost.yml
# Inline mode.
gost -C '{"api":{"addr":":8080"}}'
# Read from stdin:
gost -C - < gost.yml
-O
- Specify the configuration output format¶
Currently supports yaml
and json
formats.
# Output yaml format configuration:
gost -L http://:8080 -O yaml
# Output json format configuration:
gost -L http://:8080 -O json
# Convert json format configuration to yaml format:
gost -C gost.json -O yaml
# Convert yaml format configuration to json format:
gost -C gost.yaml -O json
-D
- Enable Debug log level¶
Debug level has more detailed log output than info level and is generally used for development and debugging.
-DD
- Enable Trace log level¶
Output more detailed log information than debug level.
-V
- Print version¶
-api
- Specify the web API address¶
Please refer to WebAPI for more details.
-metrics
- Specify prometheus metrics API address¶
Please refer to Metrics for more details.
Scoped Parameters¶
3.2.1
Most parameters set in command line mode are passed down by default. For example, for service, they will affect the service, the listener, and the handler in the service. For forwarding chain, they will affect the hop, the node, and the dialer and connector in the node.
Scoped parameters are defined by using a scope-qualified prefix before the parameter to specify the scope of the parameter.
Currently supported prefixes are:
service.
- service levellistener.
- listener levelhandler.
- handler levelhop.
- hop levelnode.
- node leveldialer.
- dialer levelconnector.
- connector level
services:
- name: service-0
addr: :8080
handler:
type: auto
metadata:
key1: value1
listener:
type: tcp
metadata:
key2: value2
metadata:
key3: value3
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8000
connector:
type: http
metadata:
key7: value7
dialer:
type: tcp
metadata:
key6: value6
metadata:
key5: value5
metadata:
key4: value4
key1
limited to handler level parameter, corresponding to handler.metadata.key1
.
key2
limited to listener level parameter, corresponding to listener.metadata.key2
.
key3
limited to service level parameter, corresponding to service.metadata.key3
.
key4
limited to hop level parameter, corresponding to hop.metadata.key4
.
key5
limited to node level parameter, corresponding to node.metadata.key5
.
key6
limited to dialer level parameter, corresponding to dialer.metadata.key6
.
key7
limited to connector level parameter, corresponding to connector.metadata.key7
.