Update app.py
Browse files
app.py
CHANGED
@@ -9,12 +9,12 @@ import IP2Location
|
|
9 |
app = Flask(__name__)
|
10 |
CORS(app) # Enable CORS for all routes
|
11 |
|
12 |
-
# Load
|
13 |
IPV4_BIN = "PX2.LITE.IPV4.BIN"
|
14 |
IPV6_BIN = "PX2.LITE.IPV6.BIN"
|
15 |
|
16 |
-
db_ipv4 =
|
17 |
-
db_ipv6 =
|
18 |
|
19 |
|
20 |
@app.route('/')
|
@@ -57,20 +57,20 @@ def get_ecpm():
|
|
57 |
|
58 |
def check_proxy(ip):
|
59 |
try:
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
#
|
65 |
-
|
66 |
-
|
67 |
return False
|
68 |
|
69 |
@app.route("/check-ip", methods=["GET"])
|
70 |
def check_ip():
|
71 |
-
user_ip = request.headers.get("X-Forwarded-For", request.remote_addr)
|
72 |
is_proxy = check_proxy(user_ip)
|
73 |
-
|
74 |
return jsonify({
|
75 |
"ip": user_ip,
|
76 |
"proxy_detected": is_proxy
|
@@ -78,8 +78,6 @@ def check_ip():
|
|
78 |
|
79 |
|
80 |
|
81 |
-
|
82 |
-
|
83 |
@app.route('/get_latest_version', methods=['GET'])
|
84 |
def get_latest_version():
|
85 |
latest_version = "31.0" # Use snake_case for internal Python variables
|
|
|
9 |
app = Flask(__name__)
|
10 |
CORS(app) # Enable CORS for all routes
|
11 |
|
12 |
+
# Load IPv4 & IPv6 databases (Download and place in same folder)
|
13 |
IPV4_BIN = "PX2.LITE.IPV4.BIN"
|
14 |
IPV6_BIN = "PX2.LITE.IPV6.BIN"
|
15 |
|
16 |
+
db_ipv4 = IP2Location.IP2Location(IPV4_BIN)
|
17 |
+
db_ipv6 = IP2Location.IP2Location(IPV6_BIN)
|
18 |
|
19 |
|
20 |
@app.route('/')
|
|
|
57 |
|
58 |
def check_proxy(ip):
|
59 |
try:
|
60 |
+
db = db_ipv6 if ":" in ip else db_ipv4 # Use correct database
|
61 |
+
record = db.get_all(ip)
|
62 |
+
|
63 |
+
proxy_type = record.proxy_type
|
64 |
+
return proxy_type not in ["", "-"] # Proxy detected if type is not empty
|
65 |
+
except Exception as e:
|
66 |
+
print(f"Error checking IP: {e}")
|
67 |
return False
|
68 |
|
69 |
@app.route("/check-ip", methods=["GET"])
|
70 |
def check_ip():
|
71 |
+
user_ip = request.headers.get("X-Forwarded-For", request.remote_addr) # Get real IP
|
72 |
is_proxy = check_proxy(user_ip)
|
73 |
+
|
74 |
return jsonify({
|
75 |
"ip": user_ip,
|
76 |
"proxy_detected": is_proxy
|
|
|
78 |
|
79 |
|
80 |
|
|
|
|
|
81 |
@app.route('/get_latest_version', methods=['GET'])
|
82 |
def get_latest_version():
|
83 |
latest_version = "31.0" # Use snake_case for internal Python variables
|