-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
98 lines (84 loc) · 2.77 KB
/
Copy pathapp.py
File metadata and controls
98 lines (84 loc) · 2.77 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from flask import Flask, render_template_string, request
from frps_parser import FrpsDirectory
import threading
import time
from database_manager import DatabaseManager
from routes.nodes import nodes_bp
# Configurations
FRPS_DASHBOARD_URL = 'http://204.10.194.164:7500' # Change as needed
FRPS_DASHBOARD_USER = "admin" # Set if dashboard authentication is enabled
FRPS_DASHBOARD_PWD = "admin123" # Set if dashboard authentication is enabled
REFRESH_INTERVAL = 5 # seconds
directory = FrpsDirectory(FRPS_DASHBOARD_URL, FRPS_DASHBOARD_USER, FRPS_DASHBOARD_PWD)
db = DatabaseManager()
db.execute_query('''
CREATE TABLE IF NOT EXISTS movies (
id INTEGER PRIMARY KEY,
title TEXT,
year INTEGER
imdb_id TEXT
)
''')
#example query
"""INSERT INTO nodes (name, hostname, disk_available, status, last_seen)
VALUES ('Node-Server-1', 'server1.example.com', 100000, 'active', datetime('now'));
"""
db.execute_query('''
CREATE TABLE IF NOT EXISTS nodes (
id INTEGER PRIMARY KEY,
name TEXT,
hostname TEXT,
disk_available INTEGER,
status TEXT,
last_seen datetime,
private_key TEXT
)
''')
db.execute_query('''
CREATE TABLE IF NOT EXISTS movie_nodes (
movie_id INT REFERENCES movies(id),
node_id INT REFERENCES nodes(id),
PRIMARY KEY (movie_id, node_id)
)
''')
def update_clients_loop():
while True:
try:
directory.fetch_online_clients()
except Exception as e:
print(f"Error updating clients: {e}")
time.sleep(REFRESH_INTERVAL)
threading.Thread(target=update_clients_loop, daemon=True).start()
app = Flask(__name__)
app.register_blueprint(nodes_bp, url_prefix='/nodes')
TEMPLATE = '''
<!DOCTYPE html>
<html>
<head>
<title>FRPS Active Directory</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
table { border-collapse: collapse; width: 60%; }
th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
th { background: #f2f2f2; }
</style>
</head>
<body>
<h2>FRPS Active Clients and Domains</h2>
<table>
<tr><th>Client</th><th>Domains</th></tr>
{% for client, domains in clients.items() %}
<tr>
<td>{{ client }}</td>
<td>{{ ', '.join(domains) if domains else '-' }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
'''
@app.route('/')
def index():
return render_template_string(TEMPLATE, clients=directory.get_clients())
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)