File size: 738 Bytes
37c0451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)