如何通過openresty lua 代理發(fā)送tcp請(qǐng)求?
如何通過openresty lua 代理發(fā)送tcp請(qǐng)求
在線等,急
如題目: 正常咱們使用 socket:tcp 創(chuàng)建請(qǐng)示 然后 connect(host, port)
普通連接代碼如下:
-- check.lualocal portHandler = function(premature, ip_add<愛尬聊_尬聊百科>ress, port) local sock = ngx.socket.tcp() sock:settimeout(300) local ok, err = sock:connect(ip_address, port)if ok then --數(shù)據(jù)庫(kù)處理或文件處理寫入歷史 local ok, err = ngx.timer.at(1, hHandler, ip_address, port); if not ok then ngx.log(ngx.ERR, "failed to create timer: ", err) end else ngx.log(ngx.ERR, "port_handler_error: " .. ip_address, err) end sock:close() end
以上方法在沒有任何限制的情況下是可以使用的。
當(dāng)如果內(nèi)網(wǎng)有限制,比如需要訪問外網(wǎng)就必須得使用代理的時(shí)候,此時(shí)運(yùn)維給了一個(gè)可用的代理ip、端口及用戶名密碼,運(yùn)維稱使用的是ss5。那么現(xiàn)在我要如何通過他給的代理把tcp請(qǐng)求發(fā)出去?
http://lattecake.com/post/20100
