Cấu hình khoá truy cập

Outline sử dụng cấu hình dựa trên YAML để xác định các tham số VPN và xử lý lưu lượng truy cập TCP/UDP. Cấu hình này hỗ trợ khả năng kết hợp ở nhiều cấp, cho phép thiết lập linh hoạt và có thể mở rộng.

Cấu hình cấp cao nhất chỉ định một TunnelConfig.

Ví dụ

Cấu hình Shadowsocks thông thường sẽ có dạng như sau:

transport:
  $type: tcpudp

  tcp:
    $type: shadowsocks
    endpoint: ss.example.com:80
    cipher: chacha20-ietf-poly1305
    secret: SECRET
    prefix: "POST "  # HTTP request

  udp:
    $type: shadowsocks
    endpoint: ss.example.com:53
    cipher: chacha20-ietf-poly1305
    secret: SECRET
    prefix: "\u0097\u00a7\u0001\u0000\u0000\u0001\u0000\u0000\u0000\u0000\u0000\u0000"  # DNS query

Lưu ý cách chúng ta hiện có thể chạy TCP và UDP trên các cổng hoặc điểm cuối khác nhau và với các tiền tố khác nhau.

Bạn có thể sử dụng neo YAML và khoá hợp nhất << để tránh trùng lặp:

transport:
  $type: tcpudp

  tcp:
    <<: &shared
      $type: shadowsocks
      endpoint: ss.example.com:4321
      cipher: chacha20-ietf-poly1305
      secret: SECRET
    prefix: "POST "

  udp: *shared

Giờ đây, bạn có thể soạn chiến lược và thực hiện nhiều bước chuyển tiếp:

transport:
  $type: tcpudp

  tcp:
    $type: shadowsocks

    endpoint:
      $type: dial
      address: exit.example.com:4321
      dialer:
        $type: shadowsocks
        address: entry.example.com:4321
        cipher: chacha20-ietf-poly1305
        secret: ENTRY_SECRET

    cipher: chacha20-ietf-poly1305
    secret: EXIT_SECRET

  udp: *shared

Trong trường hợp bị chặn các giao thức "không có giao diện" như Shadowsocks, bạn có thể sử dụng Shadowsocks-over-Websockets. Hãy xem cấu hình ví dụ về máy chủ để biết cách triển khai cấu hình đó. Cấu hình ứng dụng sẽ có dạng như sau:

transport:
  $type: tcpudp
  tcp:
    $type: shadowsocks
    endpoint:
        $type: websocket
        url: wss://legendary-faster-packs-und.trycloudflare.com/SECRET_PATH/tcp
    cipher: chacha20-ietf-poly1305
    secret: SS_SECRET

  udp:
    $type: shadowsocks
    endpoint:
        $type: websocket
        url: wss://legendary-faster-packs-und.trycloudflare.com/SECRET_PATH/udp
    cipher: chacha20-ietf-poly1305
    secret: SS_SECRET

Xin lưu ý rằng điểm cuối Websocket có thể lấy một điểm cuối, có thể được tận dụng để bỏ qua việc chặn dựa trên DNS:

transport:
  $type: tcpudp
  tcp:
    $type: shadowsocks
    endpoint:
        $type: websocket
        url: wss://legendary-faster-packs-und.trycloudflare.com/SECRET_PATH/tcp
        endpoint: cloudflare.net:443
    cipher: chacha20-ietf-poly1305
    secret: SS_SECRET

  udp:
    $type: shadowsocks
    endpoint:
        $type: websocket
        url: wss://legendary-faster-packs-und.trycloudflare.com/SECRET_PATH/udp
        endpoint: cloudflare.net:443
    cipher: chacha20-ietf-poly1305
    secret: SS_SECRET

Để đảm bảo khả năng tương thích trên nhiều phiên bản ứng dụng Outline, hãy sử dụng tuỳ chọn first-supported trong cấu hình của bạn. Điều này đặc biệt quan trọng khi các chiến lược và tính năng mới được thêm vào Outline, vì không phải tất cả người dùng đều có thể cập nhật lên phần mềm ứng dụng mới nhất. Bằng cách sử dụng first-supported, bạn có thể cung cấp một cấu hình hoạt động liền mạch trên nhiều nền tảng và phiên bản ứng dụng, đảm bảo khả năng tương thích ngược và trải nghiệm người dùng nhất quán.

transport:
  $type: tcpudp
  tcp:
    $type: shadowsocks
    endpoint:
      $type: first-supported
      options:
        - $type: websocket
          url: wss://legendary-faster-packs-und.trycloudflare.com/SECRET_PATH/tcp
        - ss.example.com:4321
    cipher: chacha20-ietf-poly1305
    secret: SS_SECRET

  udp:
    $type: shadowsocks
    endpoint:
      $type: first-supported
      options:
        - $type: websocket
          url: wss://legendary-faster-packs-und.trycloudflare.com/SECRET_PATH/udp
        - ss.example.com:4321
    cipher: chacha20-ietf-poly1305
    secret: SS_SECRET