更新 templates/index.html

This commit is contained in:
XOF
2025-12-15 04:31:50 +08:00
parent 25715cfe22
commit 4bc1a4959d

View File

@@ -12,11 +12,10 @@
} }
body { body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 20px; padding: 20px;
@@ -24,161 +23,30 @@
.container { .container {
background: white; background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
padding: 40px; padding: 40px;
border-radius: 15px; max-width: 600px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
width: 100%; width: 100%;
max-width: 700px;
animation: fadeIn 0.5s ease-out;
} }
@keyframes fadeIn { h1 {
from {
opacity: 0;
transform: scale(0.95);
}
to {
opacity: 1;
transform: scale(1);
}
}
.header {
text-align: center;
margin-bottom: 30px;
}
.header h1 {
font-size: 32px;
color: #333; color: #333;
margin-bottom: 10px; margin-bottom: 10px;
font-size: 28px;
} }
.header p { .subtitle {
color: #666; color: #666;
margin-bottom: 30px;
font-size: 14px; font-size: 14px;
} }
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #555;
font-weight: 500;
font-size: 14px;
}
.input-wrapper {
position: relative;
display: flex;
gap: 10px;
}
input[type="url"] {
flex: 1;
padding: 14px 16px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 15px;
transition: all 0.3s;
}
input[type="url"]:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
button {
padding: 14px 30px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
white-space: nowrap;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
button:active {
transform: translateY(0);
}
.info-box {
background: #f8f9fa;
border-left: 4px solid #667eea;
padding: 15px;
border-radius: 5px;
margin-top: 20px;
}
.info-box h3 {
font-size: 14px;
color: #333;
margin-bottom: 8px;
}
.info-box ul {
list-style: none;
padding-left: 0;
}
.info-box li {
font-size: 13px;
color: #666;
margin-bottom: 5px;
padding-left: 20px;
position: relative;
}
.info-box li:before {
content: "✓";
position: absolute;
left: 0;
color: #667eea;
font-weight: bold;
}
.footer {
margin-top: 20px;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 10px;
}
.footer a {
color: #667eea;
text-decoration: none;
font-size: 14px;
transition: color 0.3s;
}
.footer a:hover {
color: #764ba2;
}
.stats {
font-size: 12px;
color: #999;
}
.error-message { .error-message {
background: #fee; background: #fee;
color: #c33; color: #c33;
padding: 12px; padding: 12px;
border-radius: 5px; border-radius: 10px;
margin-bottom: 20px; margin-bottom: 20px;
text-align: center; text-align: center;
font-size: 14px; font-size: 14px;
@@ -197,65 +65,136 @@
75% { transform: translateX(10px); } 75% { transform: translateX(10px); }
} }
@media (max-width: 600px) { form {
.container { display: flex;
padding: 25px; flex-direction: column;
} gap: 15px;
}
.header h1 {
font-size: 24px; input[type="url"] {
} padding: 15px;
border: 2px solid #e0e0e0;
.input-wrapper { border-radius: 10px;
flex-direction: column; font-size: 16px;
} transition: border-color 0.3s;
}
button {
width: 100%; input[type="url"]:focus {
} outline: none;
border-color: #667eea;
}
button {
padding: 15px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 10px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}
button:active {
transform: translateY(0);
}
.features {
margin-top: 30px;
padding-top: 30px;
border-top: 1px solid #e0e0e0;
}
.features h2 {
font-size: 18px;
color: #333;
margin-bottom: 15px;
}
.features ul {
list-style: none;
color: #666;
font-size: 14px;
}
.features li {
padding: 8px 0;
padding-left: 25px;
position: relative;
}
.features li:before {
content: "✓";
position: absolute;
left: 0;
color: #667eea;
font-weight: bold;
}
.nav {
margin-top: 20px;
text-align: center;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav a {
color: #667eea;
text-decoration: none;
font-size: 14px;
}
.nav a:hover {
text-decoration: underline;
}
.stats {
font-size: 12px;
color: #999;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="header"> <h1>🔒 Secure Site Proxy</h1>
<h1>🔒 Secure Site Proxy</h1> <p class="subtitle">Access websites securely and privately</p>
<p>Access websites securely through encrypted proxy</p>
</div>
<div id="errorMessage" class="error-message"></div> <div id="errorMessage" class="error-message"></div>
<form id="proxyForm"> <form id="proxyForm" method="POST" action="/" target="_blank">
<div class="form-group"> <input
<label for="targetUrl">Enter URL to access:</label> type="url"
<div class="input-wrapper"> id="targetUrl"
<input name="url"
type="url" placeholder="Enter URL (e.g., https://example.com)"
id="targetUrl" required
name="url" autofocus
placeholder="https://example.com" pattern="https?://.+"
required title="Please enter a valid HTTP or HTTPS URL"
autofocus >
pattern="https?://.+" <button type="submit">🚀 Browse Securely</button>
>
<button type="submit">Access</button>
</div>
</div>
</form> </form>
<div class="info-box"> <div class="features">
<h3>Security Features:</h3> <h2>Features</h2>
<ul> <ul>
<li>End-to-end encrypted connection</li> <li>URL obfuscation for privacy</li>
<li>No logging of accessed URLs</li> <li>Content rewriting and filtering</li>
<li>Automatic content rewriting</li> <li>Intelligent caching</li>
<li>Protection against private network access</li> <li>Rate limiting protection</li>
<li>Rate limiting and caching</li> <li>Tracking script removal</li>
</ul> </ul>
</div> </div>
<div class="footer"> <div class="nav">
<a href="/logout">Logout</a> <a href="/logout">🚪 Logout</a>
<span class="stats" id="stats">Loading stats...</span> <span class="stats" id="stats">Loading stats...</span>
</div> </div>
</div> </div>
@@ -265,28 +204,18 @@
const errorDiv = document.getElementById('errorMessage'); const errorDiv = document.getElementById('errorMessage');
errorDiv.textContent = message; errorDiv.textContent = message;
errorDiv.classList.add('show'); errorDiv.classList.add('show');
setTimeout(() => { setTimeout(() => errorDiv.classList.remove('show'), 5000);
errorDiv.classList.remove('show');
}, 5000);
} }
document.getElementById('proxyForm').addEventListener('submit', function(e) { document.getElementById('proxyForm').addEventListener('submit', function(e) {
e.preventDefault();
const url = document.getElementById('targetUrl').value.trim(); const url = document.getElementById('targetUrl').value.trim();
// 基本验证
if (!url) {
showError('Please enter a URL');
return;
}
if (!url.startsWith('http://') && !url.startsWith('https://')) { if (!url.startsWith('http://') && !url.startsWith('https://')) {
e.preventDefault();
showError('URL must start with http:// or https://'); showError('URL must start with http:// or https://');
return; return;
} }
// 检查是否是私有地址
const privatePatterns = [ const privatePatterns = [
/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/i, /^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/i,
/^https?:\/\/192\.168\./i, /^https?:\/\/192\.168\./i,
@@ -294,33 +223,22 @@
/^https?:\/\/172\.(1[6-9]|2[0-9]|3[0-1])\./i, /^https?:\/\/172\.(1[6-9]|2[0-9]|3[0-1])\./i,
]; ];
for (const pattern of privatePatterns) { if (privatePatterns.some(p => p.test(url))) {
if (pattern.test(url)) { e.preventDefault();
showError('Private network addresses are not allowed'); showError('Private network addresses are not allowed');
return;
}
} }
// 在新标签页打开代理页面
window.open('/proxy?url=' + encodeURIComponent(url), '_blank');
}); });
// 加载统计信息 fetch('/stats')
function loadStats() { .then(r => r.json())
fetch('/stats') .then(data => {
.then(r => r.json()) const sizeMB = (data.size / 1024 / 1024).toFixed(2);
.then(data => { document.getElementById('stats').textContent =
const sizeMB = (data.size / 1024 / 1024).toFixed(2); `Cache: ${data.entries} entries, ${sizeMB} MB`;
document.getElementById('stats').textContent = })
`Cache: ${data.entries} entries, ${sizeMB} MB`; .catch(() => {
}) document.getElementById('stats').textContent = 'Stats unavailable';
.catch(() => { });
document.getElementById('stats').textContent = 'Stats unavailable';
});
}
loadStats();
setInterval(loadStats, 30000); // 每30秒更新一次
</script> </script>
</body> </body>
</html> </html>