socks01 / app.py
Alibrown's picture
Create app.py
37c0451 verified
raw
history blame
738 Bytes
from flask import Flask, request, Response, jsonify
import logging
app = Flask(__name__)
logging.basicConfig(level=logging.INFO)
@app.route('/')
def show_ip():
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
logging.info(f"Zugriff von IP: {client_ip}")
return jsonify({
"your_ip": client_ip,
"proxy_config_url": request.url_root + "proxy.pac"
})
@app.route('/proxy.pac')
def proxy_pac():
pac_content = """function FindProxyForURL(url, host) {
return "PROXY %s:7860; DIRECT";
}""" % request.host
return Response(
pac_content,
mimetype='application/x-ns-proxy-autoconfig'
)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860)