Skip to content

Commit

Permalink
update tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
ginuerzh committed Oct 2, 2024
1 parent 157ae1d commit 4119df1
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 11 deletions.
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/dtls.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# DTLS

DTLS是GOST中的一种数据通道类型。DTLS的实现依赖于[pion/dtls](https://github.com/pion/dtls)库。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/grpc.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# gRPC

gRPC是GOST中的一种数据通道类型。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/http.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# HTTP

HTTP代理是利用HTTP协议的[CONNECT方法](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Methods/CONNECT)实现的代理服务。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/http2.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# HTTP2

HTTP2有两种模式:代理模式和通道模式。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/http3.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# HTTP3

HTTP3有两种模式:通道模式(数据通道)和反向代理模式。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/kcp.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# KCP

KCP是GOST中的一种数据通道类型。KCP的实现依赖于[xtaci/kcp-go](https://github.com/xtaci/kcp-go)库。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/mtcp.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# MTCP

具有多路复用功能的TCP数据通道。多路复用基于[xtaci/smux](https://github.com/xtaci/smux)库。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/overview.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# 协议

正如[代理转发和通道](/concepts/proxy/)所述,一个GOST服务或节点被分为两层,数据处理层和数据通道层,每一层分别对应一种网络协议。两层之间相互独立,并可以任意组合使用(除了有部分限制)。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/pht.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# Plain HTTP Tunnel

PHT是GOST中的一种数据通道类型。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/quic.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# QUIC

QUIC是GOST中的一种数据通道类型。QUIC的实现依赖于[quic-go/quic-go](https://github.com/quic-go/quic-go)库。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/relay.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# Relay协议

Relay协议是GOST特有的一个协议,同时具有代理和转发功能,可同时处理TCP和UDP的数据,并支持用户认证。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/sni.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# SNI

[SNI](https://www.cloudflare.com/zh-cn/learning/ssl/what-is-sni/)(Server Name Indication)是TLS协议的扩展,包含在TLS握手的流程中(Client Hello),用来标识所访问目标主机名。SNI代理通过解析TLS握手信息中的SNI部分,从而获取目标访问地址。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/socks.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# SOCKS4,SOCKS5

## SOCKS4
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/ss.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# Shadowsocks

GOST对shadowsocks的支持基于[shadowsocks/shadowsocks-go](https://github.com/shadowsocks/shadowsocks-go)[shadowsocks/go-shadowsocks2](https://github.com/shadowsocks/go-shadowsocks2)库。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/ssh.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# SSH

SSH是GOST中的一种数据通道类型。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/tls.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# TLS

TLS是GOST中的一种数据通道类型。
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/protocols/ws.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
comments: true
---

# Websocket

Websocket是GOST中的一种数据通道类型。
Expand Down
24 changes: 14 additions & 10 deletions docs/tutorials/sniffing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
comments: true
---

默认情况下客户端与服务端之间的数据交互对于中间的代理和转发服务来说是透明的,除了部分服务(例如SNI代理,透明代理等)需要根据请求中的信息获取目标主机地址外,都是对所经过的流量进行简单的转发而并不知道所转发的数据内容。
# 流量嗅探

有些时候我们可能需要对流量进行更进一步的分析,从而可以实现流量的实时监控,统计分析,对于开发人员来说也可以更好的辅助协议调试
默认情况下客户端与服务端之间的数据交互对于中间的代理和转发服务来说是透明的,除了部分服务(例如SNI代理,透明代理,DNS代理等)需要根据请求中的信息获取目标主机地址外,都是对所经过的流量进行简单的转发而并不知道所转发的数据内容

# 流量嗅探
有些时候我们可能需要对流量进行更进一步的分析,从而可以实现流量的实时监控,统计分析,对于开发人员来说也可以更好的辅助协议调试。

!!! note "协议支持"
流量嗅探目前支持HTTP/1,HTTP/2,TLS协议和DNS协议
流量嗅探目前支持HTTP/1,HTTP/2,TLS和DNS协议

流量嗅探是指对于所中转的流量进行分析,一般是对客户端的首次请求数据进行协议匹配,大多数情况下会检查是否为HTTP或TLS请求。如果满足条件,后面的数据交互就会按照特定的协议进行解析,从而可以获取到具体的通信内容。

GOST中大部分的代理和转发服务都支持流量嗅探(具体请查看响应的协议文档说明)。流量嗅探需要配合[记录器](../concepts/recorder.md)插件,服务会将嗅探到的内容通过记录器实时上报。
GOST中大部分代理和转发服务都支持流量嗅探。流量嗅探需要配合[记录器](../concepts/recorder.md)插件,服务会将嗅探到的内容通过记录器实时上报。

例如以下是一个开启了流量嗅探的HTTP代理服务,当代理协商阶段结束后,会进一步检查流量,尝试嗅探出HTTP或TLS流量。

Expand Down Expand Up @@ -106,8 +106,6 @@ curl -x localhost:8080 https://www.example.com

TLS流量劫持的关键是对私有CA根证书的信任,用我们提供的根证书来签发并替代原始主机的证书。仅当同时设置了正确的CA证书和私钥(mitm.certFile和mitm.keyFile)后才会开启TLS流量劫持。

以下是开启了MITM TLS流量劫持的HTTP代理,并仅对访问`example.com`及其子域名的TLS流量进行劫持。

!!! tip "生成CA根证书"
借助于[openssl](https://github.com/openssl/openssl)命令,可以生成私有CA证书:

Expand All @@ -118,6 +116,8 @@ TLS流量劫持的关键是对私有CA根证书的信任,用我们提供的根
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
```

以下是开启了TLS流量劫持的HTTP代理,并仅对访问`example.com`及其子域名的TLS流量进行劫持。

```yaml hl_lines="19-26"
services:
- name: service-0
Expand Down Expand Up @@ -172,7 +172,7 @@ bypasses:
: Bypass名称,引用`bypasses.name`,通过bypass可以对指定的主机进行TLS流量劫持。


当通过代理请求`https://www.example.com`时,代理会嗅探到TLS协议,并执行TLS终止来对流量进行解密后再次嗅探解密后的流量,此时会同时嗅探到TLS握手信息和解密后的HTTP/2请求响应内容:
当通过代理请求`https://www.example.com`时,代理会嗅探到TLS协议,并执行TLS终止来对流量进行解密后再次嗅探解密后的流量,因此会进一步嗅探到解密后的HTTP/2请求响应内容:

```bash
curl -k -x localhost:8080 https://www.example.com
Expand All @@ -196,10 +196,14 @@ curl -k -x localhost:8080 https://www.example.com

# 数据聚合与分析

GOST对于流量嗅探信息仅作上报操作,不会再进一步处理,如果需要对信息进行查询统计分析,可以把接收到的上报信息存储在ELK,Loki等日志聚合系统。你也可以选择直接使用[gost-plugins](https://github.com/ginuerzh/gost-plugins)中的记录器插件服务,其会将接收到的记录数据保存在MongoDB数据库中或推送给Loki服务。
GOST对于流量嗅探信息仅作上报操作,不会再进一步处理。如果需要对信息进行查询统计和分析,可以把接收到的上报信息存储在[ELK](https://www.elastic.co/cn/elastic-stack),[Grafana Loki](https://grafana.com/oss/loki/)等日志聚合系统。

你也可以选择直接使用[gost-plugins](https://github.com/ginuerzh/gost-plugins)中的记录器插件服务,其会将接收到的记录数据保存在MongoDB数据库中或推送给Loki服务。

```bash
docker run -p 8000:8000 ginuerzh/gost-plugins recorder --addr=:8000 --loki.url=http://loki.write:3100/loki/api/v1/push --loki.id=gost --mongo.uri=mongodb://mongo.db:27017 --mongo.db=gost
docker run -p 8000:8000 ginuerzh/gost-plugins \
recorder --addr=:8000 --loki.url=http://loki.write:3100/loki/api/v1/push --loki.id=gost \
--mongo.uri=mongodb://mongo.db:27017 --mongo.db=gost
```

![Loki - HTTP](../../images/loki01.png)
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ nav:
- 反向代理: tutorials/reverse-proxy.md
- 反向代理隧道: tutorials/reverse-proxy-tunnel.md
- 反向代理隧道-高可用: tutorials/reverse-proxy-tunnel-ha.md
- 流量嗅探: tutorials/sniffing.md
- HTTP文件服务: tutorials/file.md
- 探测防御: tutorials/probe-resistance.md
- PROXY Protocol: tutorials/proxy-protocol.md
Expand All @@ -177,7 +178,6 @@ nav:
- ICMP通道: tutorials/icmp.md
- Unix域套接字重定向: tutorials/unix.md
- 串口重定向: tutorials/serial.md
- 流量嗅探与MITM: tutorials/sniffing.md
- 监控指标: tutorials/metrics.md
- 日志: tutorials/log.md
- 参考:
Expand Down

0 comments on commit 4119df1

Please sign in to comment.