使用woo 语言开发 sockets4 sockets5 http https代理完整记录

本文详细记录了使用woo语言开发sockets4、sockets5及http、https代理的全过程,已在gitee开源。通过一个端口监听所有代理类型,并提供了启动服务监听端口的代码片段以及Windows10的代理设置指南。
摘要由CSDN通过智能技术生成

记录下使用woo语言开发 sockets 和https代理过程

已经在gitee开源: https://gitee.com/oshine/woo_proxy

目前使用的是一个端口监听所有的代理包含http https sockets4 sockets5

作为程序员,当克隆时候速度蚂蚁一般真的没地儿诉苦

好了废话不多说,上代码:

1.启动服务监听端口

client.woo 文件内容:

_DIR = _DIR == '.' and './' or _DIR

local conf = require(_DIR .. '.conf')

local addr = conf['http/s_sockets4/5_addr']
print('sockets(4/5) and http/s proxy start on:', addr)

local ser = woo.sockets:new()

-- 开启 tcp sockets proxy监听服务
ser:listen('tcp', addr, function(handler)
    -- 启动一个线程来处理,启动线程需要绝对路径
    _run(_DIR .. '/client/sockets_handler.woo', handler, _DIR, conf) -- 把sockets handler,目录位置传入线程中去
end, function(err)
    print(err)
end)

2.handler文件内容:

require(_ARGS[2] .. '.client.utils'); -- 导入工具包
local conf = _ARGS[3];

print('sockets(4/5) handler in:')
_out('_ARGS:=== ', _ARGS);

(function()
    -- 获取线程传入的 sockets handler
    local handler = _ARGS[1]
    assert(handler, 'server form parent not correct.')

    print('conn ok!')
    local len, b = handler:read(1)
    if len < 1 then
        print("Request packet is too short!")
        return
    end

    print('Got first byre for proxy:', b[1])

    if b[
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值