# 【记录】Warp 与 Tor 共存

Last updated on March 19, 2024 pm

## 注册 Zero Trust

1. 访问 CF Zero Trust,按网上教程注册
2. 开启 GitHub Authentication: Setting - Authentication - Login methods - Add new
3. 添加 Device enrollment: Setting - WARP Client - Device enrollment permissions - Manage - Add a rule
4. Selector 选 Emails; Value 填 GitHub 的邮箱
5. 访问 Warp-go, 按教程 WARP Teams 获取并用于 Linux 的方法 获取 warp-account.conf
6. 访问 https://your-team-name.cloudflareaccess.com/warp 审查元素也可获取 authtoken
7. 记录 warp-account.conf 文件中的 [“account”][“private_key”] 和 [“config”][“peers”][“public_key”]
8. 运行 `bash api.sh -i -f ./warp-account.conf` 获取 reserved

## 部署 Tor

    1
    2
    3
    4
    5
    6
    7

    mkdir -p ~/app/tor && cd ~/app/tor && nano Dockerfile && nano docker-compose.yml
    echo 'SocksPort 0.0.0.0:9050' > torrc
    docker build -t limour/tor .
    docker image ls | grep limour/tor
    sudo docker network create sswitch
    sudo docker-compose up -d && sudo docker-compose logs
    docker run --rm --net=sswitch alpine/curl --socks5-hostname "tor:9050" "https://check.torproject.org/api/ip"

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19

    # set alpine as the base image of the Dockerfile
    FROM alpine:latest

    # update the package repository and install Tor
    RUN apk update && apk --no-cache add tor

    # Copy over the torrc created above and set the owner to `tor`
    COPY torrc /etc/tor/torrc
    RUN chown -R tor /etc/tor

    # Set `tor` as the default user during the container runtime
    USER tor

    # Set `tor` as the entrypoint for the image
    ENTRYPOINT ["tor"]

    # Set the default container command
    # This can be overridden later when running a container
    CMD ["-f", "/etc/tor/torrc"]

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    version: '3.3'
    services:
        tor:
            restart: always
            image: limour/tor

    networks:
      default:
        external: true
        name: sswitch

- 安装好 docker

## 部署 Warp

    1
    2
    3
    4
    5
    6

    mkdir -p ~/app/socks5 && cd ~/app/socks5 && nano docker-compose.yml
    mkdir ./config
    nano ./config/config.json
    wget https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db -O config/geoip.db
    wget https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db -O config/geosite.db
    sudo docker-compose up -d && sudo docker-compose logs

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78

    {
      "log": {
        "level": "info"
      },
      "inbounds": [
        {
          "type": "socks",
          "tag": "socks-in",
          "listen": "::",
          "listen_port": 5353,
          "tcp_fast_open": false,
          "udp_fragment": true,
          "sniff": true,
          "sniff_override_destination": false,
          "sniff_timeout": "300ms",
          "udp_timeout": 300,
          "proxy_protocol": false,
          "proxy_protocol_accept_no_header": false
        }
      ],
      "outbounds": [
        {
          "type": "direct"
        },
        {
          "type": "wireguard",
          "tag": "wireguard",
          "server": "engage.cloudflareclient.com",
          "server_port": 2408,
          "local_address": ["10.0.0.2/32"],
          "private_key": "记录的private_key",
          "peer_public_key": "记录的public_key",
    	  "reserved": [0, 0, 0] // 记录的reserved值
        },
        {
          "type": "socks",
          "tag": "tor",
          "server": "tor",
          "server_port": 9050
        }
      ],
      "route": {
        "rules": [
          {
            "domain_suffix": [".onion"],
            "outbound": "tor"
          },
          {
            "domain_suffix": ["openai.com"],
            "outbound": "wireguard"
          },
          {
            "domain_suffix": [".cn"],
            "outbound": "wireguard"
          },
          {
            "domain_suffix": ["check.torproject.org"],
            "outbound": "tor"
          },
          {
            "domain_suffix": ["myip.ipip.net"],
            "outbound": "wireguard"
          },
          {
            "geoip": ["cn"],
            "outbound": "wireguard"
          },
          {
            "geosite": ["cn"],
            "outbound": "wireguard"
          },
          {
            "domain_keyword": ["bing","microsoft"],
            "outbound": "wireguard"
          }
        ]
      }
    }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    version: '3.3'
    services:
        socks5:
            restart: always
            volumes:
                - './config/:/etc/sing-box/'
            image: gzxhwq/sing-box:git

    networks:
      default:
        external: true
        name: sswitch

## 测试 Warp 和 Tor

    1
    2
    3
    4

    docker run --rm --net=sswitch alpine/curl --socks5-hostname socks5:5353 https://myip.ipip.net
    docker run --rm --net=sswitch alpine/curl --socks5-hostname socks5:5353 https://api.ipify.org/?format=json
    docker run --rm --net=sswitch alpine/curl --socks5-hostname "socks5:5353" "https://check.torproject.org/api/ip"
    docker run --rm --net=sswitch alpine/curl --socks5-hostname "socks5:5353" "https://www.nytimesn7cgmftshazwhfgzm37qxb44r64ytbb2dj3x62d2lljsciiyd.onion"

#socks5 #warp #tor
【记录】Warp 与 Tor 共存
https://hexo.limour.top/-ji-lu-Warp-yu-Tor-gong-cun
Author
Limour
Posted on
July 1, 2023
Updated on
March 19, 2024
Licensed under
【记录】SOCKS5 转 QUIC Previous
【记录】Go 实现 OpenAI API HTTP 代理 Next

#### Search

Keyword