tried implementing post function

This commit is contained in:
Roxy 2023-05-25 11:17:07 +02:00
parent 5835becb62
commit 83b1294a07
1 changed files with 12 additions and 3 deletions

View File

@ -7,7 +7,7 @@ require "uri"
$replacements = { $replacements = {
"e621.net" => "e621.fuwwy.ch", # Replace this with your domain/subdomain obviously "e621.net" => "e621.fuwwy.ch", # Replace this with your domain/subdomain obviously
">e621<" => ">e621.fuwwy.ch<", # This basically just changes the title shown on the main page ">e621<" => ">e621.fuwwy.ch<", # This basically just changes the title shown on the main page
"https:" => "http:" # only needed if your nginx backend doesnt have ssl yet "https:" => "http:" # only needed if your nginx backend doesn't have SSL yet
} }
class MyProxy < WEBrick::HTTPServlet::AbstractServlet class MyProxy < WEBrick::HTTPServlet::AbstractServlet
@ -15,12 +15,20 @@ class MyProxy < WEBrick::HTTPServlet::AbstractServlet
def do_GET(request, response) def do_GET(request, response)
uri = request.unparsed_uri uri = request.unparsed_uri
proxy_request(request, response, Net::HTTP::Get.new(uri, {"User-Agent" => "amongus happy meal guys this is crazy i ordered an amogus happy meal at 3am hugy wugy came and sucked my dick this is so scary"}))
end
def do_POST(request, response)
uri = request.unparsed_uri
proxy_request(request, response, Net::HTTP::Post.new(uri, {"User-Agent" => "amongus happy meal guys this is crazy i ordered an amogus happy meal at 3am hugy wugy came and sucked my dick this is so scary"}), request.body)
end
def proxy_request(request, response, http_request, body = nil)
http = Net::HTTP.new(HOST, 443) http = Net::HTTP.new(HOST, 443)
http.use_ssl = true http.use_ssl = true
http_request.body = body if body
resp = http.request(Net::HTTP::Get.new(uri, {"User-Agent" => "amongus happy meal guys this is crazy i ordered an amogus happy meal at 3am hugy wugy came and sucked my dick this is so scary"})) resp = http.request(http_request)
# please change this user agent to something unique otherwise e621 will block your request and you might get IP banned
body = resp.body body = resp.body
response.content_type = resp["content-type"] response.content_type = resp["content-type"]
@ -36,3 +44,4 @@ server.mount "/", MyProxy
trap("INT"){ server.shutdown } trap("INT"){ server.shutdown }
server.start server.start