Files
SiteProxy/templates/index.html
2025-12-15 03:59:19 +08:00

326 lines
8.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Secure Site Proxy</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: white;
padding: 40px;
border-radius: 15px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
width: 100%;
max-width: 700px;
animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
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;
margin-bottom: 10px;
}
.header p {
color: #666;
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 {
background: #fee;
color: #c33;
padding: 12px;
border-radius: 5px;
margin-bottom: 20px;
text-align: center;
font-size: 14px;
border: 1px solid #fcc;
display: none;
}
.error-message.show {
display: block;
animation: shake 0.5s;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-10px); }
75% { transform: translateX(10px); }
}
@media (max-width: 600px) {
.container {
padding: 25px;
}
.header h1 {
font-size: 24px;
}
.input-wrapper {
flex-direction: column;
}
button {
width: 100%;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🔒 Secure Site Proxy</h1>
<p>Access websites securely through encrypted proxy</p>
</div>
<div id="errorMessage" class="error-message"></div>
<form id="proxyForm">
<div class="form-group">
<label for="targetUrl">Enter URL to access:</label>
<div class="input-wrapper">
<input
type="url"
id="targetUrl"
name="url"
placeholder="https://example.com"
required
autofocus
pattern="https?://.+"
>
<button type="submit">Access</button>
</div>
</div>
</form>
<div class="info-box">
<h3>Security Features:</h3>
<ul>
<li>End-to-end encrypted connection</li>
<li>No logging of accessed URLs</li>
<li>Automatic content rewriting</li>
<li>Protection against private network access</li>
<li>Rate limiting and caching</li>
</ul>
</div>
<div class="footer">
<a href="/logout">Logout</a>
<span class="stats" id="stats">Loading stats...</span>
</div>
</div>
<script>
function showError(message) {
const errorDiv = document.getElementById('errorMessage');
errorDiv.textContent = message;
errorDiv.classList.add('show');
setTimeout(() => {
errorDiv.classList.remove('show');
}, 5000);
}
document.getElementById('proxyForm').addEventListener('submit', function(e) {
e.preventDefault();
const url = document.getElementById('targetUrl').value.trim();
// 基本验证
if (!url) {
showError('Please enter a URL');
return;
}
if (!url.startsWith('http://') && !url.startsWith('https://')) {
showError('URL must start with http:// or https://');
return;
}
// 检查是否是私有地址
const privatePatterns = [
/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/i,
/^https?:\/\/192\.168\./i,
/^https?:\/\/10\./i,
/^https?:\/\/172\.(1[6-9]|2[0-9]|3[0-1])\./i,
];
for (const pattern of privatePatterns) {
if (pattern.test(url)) {
showError('Private network addresses are not allowed');
return;
}
}
// 在新标签页打开代理页面
window.open('/proxy?url=' + encodeURIComponent(url), '_blank');
});
// 加载统计信息
function loadStats() {
fetch('/stats')
.then(r => r.json())
.then(data => {
const sizeMB = (data.size / 1024 / 1024).toFixed(2);
document.getElementById('stats').textContent =
`Cache: ${data.entries} entries, ${sizeMB} MB`;
})
.catch(() => {
document.getElementById('stats').textContent = 'Stats unavailable';
});
}
loadStats();
setInterval(loadStats, 30000); // 每30秒更新一次
</script>
</body>
</html>