<commit_before>local core = require "sys.core"
local socket = require "sys.socket"
local dns = require "sys.dns"
local crypto = require "sys.crypto"
local packet = require "packet"

local key = core.envget("crypt")

local function tunnel_intenet(tunnelfd)
	local pk = packet.read(tunnelfd)
	local port = string.unpack("<I2", pk)
	local domain = pk:sub(2+1)
	domain = crypto.aesdecode(key, domain)
	print(domain, port)
	if dns.isname(domain) then
		domain = assert(dns.resolve(domain), domain)
	end
	local addr = string.format("%s:%d", domain, port)
	local fd = socket.connect(addr)
	--print("connect", fd, domain, addr)
	core.log("----tunnel bridge:", tunnelfd, fd)
	core.fork(packet.fromtunnel(tunnelfd, fd))
	core.fork(packet.fromweb(fd, tunnelfd))
end

socket.listen(core.envget("server"), function(tunnelfd, addr)
        print(tunnelfd, "from", addr)
	socket.limit(tunnelfd, 1024 * 1024 * 1024)
	local ok, err = core.pcall(tunnel_intenet, tunnelfd)
	if not ok then
		print(err)<commit_msg>server modify packet limit is 64MByte<commit_after>local core = require "sys.core"
local socket = require "sys.socket"
local dns = require "sys.dns"
local crypto = require "sys.crypto"
local packet = require "packet"

local key = core.envget("crypt")

local function tunnel_intenet(tunnelfd)
	local pk = packet.read(tunnelfd)
	local port = string.unpack("<I2", pk)
	local domain = pk:sub(2+1)
	domain = crypto.aesdecode(key, domain)
	print(domain, port)
	if dns.isname(domain) then
		domain = assert(dns.resolve(domain), domain)
	end
	local addr = string.format("%s:%d", domain, port)
	local fd = socket.connect(addr)
	--print("connect", fd, domain, addr)
	core.log("----tunnel bridge:", tunnelfd, fd)
	core.fork(packet.fromtunnel(tunnelfd, fd))
	core.fork(packet.fromweb(fd, tunnelfd))
end

socket.listen(core.envget("server"), function(tunnelfd, addr)
        print(tunnelfd, "from", addr)
	socket.limit(tunnelfd, 64 * 1024 * 1024)
	local ok, err = core.pcall(tunnel_intenet, tunnelfd)
	if not ok then
		print(err)
{'fraction_non_alphanumeric': 0.14527363184079603, 'fraction_numerical': 0.014925373134328358, 'mean_word_length': 5.093939393939394, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6018460', 'n_tokens_mistral': 772, 'n_tokens_neox': 734, 'n_words': 182}