Skip to content

BurstObservatory: add option to set http method for burst check#4835

Merged
yuhan6665 merged 4 commits intoXTLS:mainfrom
Jolymmiles:feature/add-option-to-set-http-method-for-burst-check
Jun 23, 2025
Merged

BurstObservatory: add option to set http method for burst check#4835
yuhan6665 merged 4 commits intoXTLS:mainfrom
Jolymmiles:feature/add-option-to-set-http-method-for-burst-check

Conversation

@Jolymmiles
Copy link
Contributor

@Jolymmiles Jolymmiles commented Jun 19, 2025

burstObservatory is unable to correctly detect certain local blocks in Russia, as the current implementation uses only HEAD requests, and the regular observatory does not read the response body or handle errors. This makes it impossible to detect blocks based on the size of downloaded data.

Problem:
Recently, certain types of blocking have been observed in Russia, where:

  • A TCP connection is established.
  • The 3-way handshake and TLS Client Hello complete successfully.
  • After that, the connection hangs for 40–60 seconds and then ends with an RST.

Such connections are marked as alive in burstObservatory because the HEAD request does not trigger the block.

After thorough analysis, it was found that the block is triggered only when attempting to read the body of a GET request, and only if the body size is greater than or equal to 20 KB.

Solution:
The ping function in burstObservatory was modified:

  1. An httpMethod option was added to allow choosing the request method.
  2. Full body reading using io.ReadAll was implemented for GET requests, along with error handling.

For testing, a site was set up with the URL /slow-200 that returns a static 20 KB body.

Result (after modification):

[Warning] app/observatory/burst: error ping https://test.dev.com/slow-200 with CDN-PROXY: Get "https://test.dev.com/slow-200": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
[Warning] app/observatory/burst: error ping https://test.dev.com/slow-200 with ENTRY-PROXY: context deadline exceeded (Client.Timeout or context cancellation while reading body)

Before modification (HEAD request):

[Warning] app/observatory/burst: error ping https://test.dev.com/slow-200 with CDN-PROXY: Get "https://test.dev.com/slow-200": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

In the second case, the block is not detected, and observatory considers the connection available, which leads to routing traffic through a non-working outbound.

@Jolymmiles
Copy link
Contributor Author

burstObservatory не способен корректно определить некоторые локальные блокировки в России, т.к. текущая реализация использует только HEAD-запросы, а обычная observatory не читает тело ответа и не обрабатывает ошибки. Это делает невозможным детектирование блокировок, основанных на отсечке по размеру загружаемых данных.
Проблема:
С недавнего времени, в РФ наблюдаются блокировки, при которых:
• Устанавливается TCP-соединение.
• Проходит 3-way handshake и TLS Client Hello.
• После чего соединение зависает на 40–60 секунд и завершается RST.
Такие подключения помечаются как alive в burstObservatory, так как HEAD-запрос не вызывает блокировки.
После тщательного анализа выяснилось, что блокировка срабатывает только при попытке прочитать тело GET-запроса, если оно превышает или равняется 20 KB.
Решение:
Была модифицирована функция ping в burstObservatory:

  1. Добавлена опция httpMethod для выбора метода запроса.
  2. Реализовано чтение тела до конца (io.ReadAll), с обработкой ошибок для GET запроса.
    Для тестов был поднят сайт с URL /slow-200, отдающий статическое тело размером 20KB.
    Результат (после модификации):
    [Warning] app/observatory/burst: error ping https://test.dev.com/slow-200 with CDN-PROXY: Get "https://test.dev.com/slow-200": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
    [Warning] app/observatory/burst: error ping https://test.dev.com/slow-200 with ENTRY-PROXY: context deadline exceeded (Client.Timeout or context cancellation while reading body)

До модификации (HEAD-запрос):
[Warning] app/observatory/burst: error ping https://test.dev.com/slow-200 with CDN-PROXY: Get "https://test.dev.com/slow-200": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Во втором случае блокировка не фиксируется, и observatory считает соединение доступным, что приводит к маршрутизации трафика через нерабочий outbound.

@Fangliding
Copy link
Member

image
protoc gen go version

@Jolymmiles
Copy link
Contributor Author

Jolymmiles commented Jun 19, 2025

image protoc gen go version

image

yeah, because it in main branch

@Jolymmiles
Copy link
Contributor Author

also

image image

@Jolymmiles Jolymmiles force-pushed the feature/add-option-to-set-http-method-for-burst-check branch from a98ee1a to 8e6a301 Compare June 19, 2025 19:34
@Jolymmiles
Copy link
Contributor Author

Jolymmiles commented Jun 19, 2025

solved proto gen, but it required change core/proto.go

@Fangliding
Copy link
Member

solved proto gen, but it required change core/proto.go

you can simply just not commit that file

@Jolymmiles
Copy link
Contributor Author

@Fangliding could you look pls?

@Fangliding
Copy link
Member

proto问题应该已经没有了
我不觉得我们应该为下载20kb后再阻断的神秘行为负责 不过加一个method应该是可以接受的 还有一个问题是是否只在get的时候尝试获得响应体
具体得看 @yuhan6665

@yuhan6665 yuhan6665 changed the title Feature/add option to set http method for burst check BurstObservatory: add option to set http method for burst check Jun 23, 2025
@yuhan6665 yuhan6665 merged commit 27742da into XTLS:main Jun 23, 2025
39 checks passed
@yuhan6665
Copy link
Member

Thanks for your work! Looks good to me!

return rttFailed, err
}
// don't wait for body
if httpMethod == http.MethodGet {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW I agree with Fangliding that maybe better read body for any method except HEAD. But it is too minor we can do later so I merged it

patterniha pushed a commit to patterniha/Xray-core that referenced this pull request Jun 28, 2025
…#4835)

* feat: add options to set method for burst check.

* chore: gen proto.

* chore: change protoc-gen-go to latest.

* revert

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
maoxikun pushed a commit to maoxikun/Xray-core that referenced this pull request Aug 23, 2025
…#4835)

* feat: add options to set method for burst check.

* chore: gen proto.

* chore: change protoc-gen-go to latest.

* revert

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
(cherry picked from commit 27742da)
it2konst pushed a commit to it2konst/gametunnel-core that referenced this pull request Mar 1, 2026
…#4835)

* feat: add options to set method for burst check.

* chore: gen proto.

* chore: change protoc-gen-go to latest.

* revert

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
drovosek229 pushed a commit to drovosek229/Xray-core that referenced this pull request Mar 16, 2026
…#4835)

* feat: add options to set method for burst check.

* chore: gen proto.

* chore: change protoc-gen-go to latest.

* revert

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants