File size: 1,252 Bytes
5e8800c
 
 
 
0fd5085
5e8800c
 
 
 
0fd5085
60d645e
 
 
 
5e8800c
 
 
60d645e
 
0fd5085
5e8800c
60d645e
 
 
 
5e8800c
 
 
60d645e
 
 
 
 
 
 
 
 
 
 
5e8800c
 
0fd5085
60d645e
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask, request, Response, jsonify
import requests

app = Flask(__name__)
# Logging komplett deaktivieren
app.logger.disabled = True

@app.route('/')
def show_ip():
    # Minimale Antwort ohne Logging
    return jsonify({
        "status": "running",
        "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'
    )

@app.route('/<path:url>', methods=['GET', 'POST', 'PUT', 'DELETE'])
def proxy(url):
    try:
        response = requests.request(
            method=request.method,
            url=url,
            headers={key: value for (key, value) in request.headers if key != 'Host'},
            data=request.get_data(),
            allow_redirects=False
        )
        return Response(response.content, response.status_code)
    except:
        return Response("Error", 500)

if __name__ == "__main__":
    # Werkzeug Logger auch deaktivieren
    import logging
    log = logging.getLogger('werkzeug')
    log.disabled = True
    app.run(host="0.0.0.0", port=7860)