1

我正在尝试为 Apache Traffic Server 编写一个简单的加密/解密插件。该插件应转换请求/响应以加密/解密它们。我决定使用 LUA https://github.com/portl4t/ts-lua

function encrypt(data, eos)
    if (data == '') then
        return data, eos
    end

    if (eos == 1) then
        ts.debug('End of Stream')
    end

    return data, eos
end

function do_remap()
    ts.debug('do_remap')
    if (ts.client_request.get_method() == 'POST') then
        ts.hook(TS_LUA_REQUEST_TRANSFORM, encrypt)
    end

    ts.http.resp_cache_transformed(0)
    ts.http.resp_cache_untransformed(0)
    return 0
end

一切都适用于GETDELETE请求,但是当我发送POST 分块编码请求时,ATS 几乎每次都崩溃。

这是堆栈跟踪:

[May 20 13:16:28.105] Server {0x7f045a1c1700} DEBUG: (http_redirect) [HttpSM::do_redirect]
[May 20 13:16:28.105] Server {0x7f045a1c1700} DEBUG: (http_redirect) [HttpTunnel::deallocate_postdata_copy_buffers]
NOTE: Traffic Server received Sig 11: Segmentation fault
bin/traffic_server - STACK TRACE: 
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0)[0x7f045cd29cb0]
bin/traffic_server(_ZN6HttpSM17handle_api_returnEv+0x171)[0x5c274f]
bin/traffic_server(_ZN6HttpSM17state_api_calloutEiPv+0x883)[0x5c24cf]
bin/traffic_server(_ZN6HttpSM23do_api_callout_internalEv+0x1b7)[0x5ceaef]
bin/traffic_server(_ZN6HttpSM14do_api_calloutEv+0x26)[0x5dc18e]
bin/traffic_server(_ZN6HttpSM14set_next_stateEv+0x12f9)[0x5d6a19]
bin/traffic_server(_ZN6HttpSM32call_transact_and_set_next_stateEPFvPN12HttpTransact5StateEE+0x1ba)[0x5d5718]
bin/traffic_server(_ZN6HttpSM36state_common_wait_for_transform_readEP17HttpTransformInfoMS_FiiPvEiS2_+0x39b)[0x5c1a11]
bin/traffic_server(_ZN6HttpSM37state_request_wait_for_transform_readEiPv+0x1e1)[0x5c1483]
bin/traffic_server(_ZN6HttpSM12main_handlerEiPv+0x333)[0x5c5eeb]
bin/traffic_server(_ZN12Continuation11handleEventEiPv+0x68)[0x4f06b2]
bin/traffic_server(_ZN17TransformTerminus12handle_eventEiPv+0x2f6)[0x538d2a]
bin/traffic_server(_ZN12Continuation11handleEventEiPv+0x68)[0x4f06b2]
bin/traffic_server(_ZN7EThread13process_eventEP5Eventi+0x11e)[0x7537e2]
bin/traffic_server(_ZN7EThread7executeEv+0xc9)[0x753a27]
bin/traffic_server[0x752ca7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a)[0x7f045cd21e9a]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f045c0383fd]
Segmentation fault (core dumped)

我已经尝试使用示例插件之一进行请求转换,但我仍然遇到同样的问题。使问题消失的唯一方法是避免请求转换。

我转换请求的方式有什么问题吗?我该如何解决这个问题segmentation fault

谢谢

4

0 回答 0