<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IP 拦截 - 防火墙防护</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<canvas id="rain-canvas"></canvas>
<div class="fog-effect"></div>
<div class="firewall" id="firewall"></div>
<div class="content">
<h1 id="access-status">访问已被拦截</h1>
<p id="access-info">您的 IP 已被系统识别为非法访问<br>
根据安全策略,您的访问请求已被防火墙阻止</p>
<button class="firewall-button" id="retry-button" onclick="retryAccess()">尝试其他途径访问</button>
<div class="card">
<canvas id="card-canvas" width="300" height="200"></canvas>
<div class="card-content">
<p><strong>设备 IP 地址:</strong> <span id="device-ip">获取中...</span></p>
<p><strong>访问时间:</strong> <span id="access-time">--</span></p>
<p><strong>状态:</strong> <span id="current-status">黑名单成员</span></p>
<p><strong>剩余时间:</strong> <span id="remaining-time">--</span></p>
</div>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
index.html
style.css
index.js
现在支持上传本地图片了!
body {
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
background-color: #000;
color: #00ff00;
overflow: hidden;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.content {
text-align: center;
z-index: 10;
position: relative;
}
h1 {
font-size: 3rem;
margin-bottom: 20px;
text-shadow: 0 0 10px #00ff00;
animation: pulse 2s infinite;
}
p {
font-size: 1.2rem;
margin-bottom: 30px;
max-width: 600px;
}
.firewall {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 5;
}
.firewall-bar {
position: absolute;
background: linear-gradient(90deg, transparent, #00ff00, transparent);
height: 2px;
width: 80%;
animation: scan 2s infinite linear;
}
.firewall-button {
background-color: #003300;
color: #00ff00;
border: 1px solid #00ff00;
padding: 10px 20px;
font-size: 1rem;
cursor: pointer;
transition: all 0.3s;
margin-top: 20px;
}
.firewall-button:hover {
background-color: #005500;
box-shadow: 0 0 15px #000ff0;
}
.ip-info {
margin-top: 30px;
padding: 15px;
background-color: rgba(0, 51, 0, 0.3);
border: 1px solid #00ff00;
border-radius: 5px;
width: 300px;
position: relative;
}
.ip-info p {
margin: 5px 0;
}
/* 雾效 */
.fog-effect {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.7));
z-index: 3; /* 调整雾效层级,确保在雨滴效果之上 */
pointer-events: none;
}
/* 脉动效果 */
@keyframes pulse {
0% {
text-shadow: 0 0 10px #00ff00;
}
50% {
text-shadow: 0 0 20px #00ff00, 0 0 30px #00ff88;
}
100% {
text-shadow: 0 0 10px #00ff00;
}
}
/* Canvas 雨滴 */
#rain-canvas {
position: absolute;
top: 0;
left: 0;
z-index: 2;
}
/* 卡片样式 */
.card {
width: 300px;
height: 200px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin-top: 30px;
}
#card-canvas {
position: absolute;
z-index: 1;
}
.card-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 10px;
padding: 20px;
box-sizing: border-box;
z-index: 2;
}
/* 调整内容样式 */
.content {
z-index: 10;
position: relative;
}
class Raindrop {
constructor(canvasWidth, canvasHeight) {
this.x = Math.random() * canvasWidth;
this.resetY(canvasHeight);
this.length = Math.random() * 15 + 10; // 雨滴长度
this.speed = Math.random() * 2 + 1; // 雨滴速度
this.opacity = Math.random() * 0.5 + 0.1; // 雨滴透明度
this.width = Math.random() * 1.5 + 0.5; // 雨滴宽度
}
update(canvasHeight) {
this.y += this.speed;
if (this.y > canvasHeight) {
this.resetY(canvasHeight);
this.x = Math.random() * canvas.width;
}
}
resetY(canvasHeight) {
this.y = -10; // 从屏幕外开始
}
draw(ctx) {
ctx.beginPath();
ctx.strokeStyle = `rgba(0, 255, 0, ${this.opacity})`;
ctx.lineWidth = this.width;
ctx.moveTo(this.x, this.y);
ctx.lineTo(this.x, this.y + this.length);
ctx.stroke();
// 添加雨滴头部的圆形效果
ctx.beginPath();
ctx.arc(this.x, this.y + this.length, this.width * 1.5, 0, Math.PI, true);
ctx.stroke();
}
}
let raindrops = [];
let canvas, ctx;
function initRain() {
canvas = document.getElementById('rain-canvas');
ctx = canvas.getContext('2d');
// 设置画布大小为窗口大小
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// 创建雨滴
const rainCount = 200;
raindrops = [];
for (let i = 0; i < rainCount; i++) {
raindrops.push(new Raindrop(canvas.width, canvas.height));
}
// 开始动画循环
animate();
}
function animate() {
// 清除画布
ctx.clearRect(0, 0, canvas.width, canvas.height);
// 绘制和更新雨滴
raindrops.forEach(drop => {
drop.update(canvas.height);
drop.draw(ctx);
});
// 循环动画
requestAnimationFrame(animate);
}
// 创建动态的防火墙效果,自适应页面大小
function createFirewallBars() {
const firewall = document.getElementById('firewall');
const barCount = 10;
for (let i = 0; i < barCount; i++) {
const bar = document.createElement('div');
bar.className = 'firewall-bar';
// 设置随机位置和动画时间
bar.style.left = Math.random() * 100 + '%';
bar.style.animationDuration = 2 + Math.random() * 3 + 's';
bar.style.animationDelay = Math.random() * 2 + 's';
// 设置宽度为页面宽度的一定比例,以适应不同屏幕尺寸
bar.style.width = (window.innerWidth * 0.2) + 'px';
firewall.appendChild(bar);
}
}
// 页面加载和窗口大小改变时初始化效果
window.onload = function() {
createFirewallBars();
initRain();
};
window.onresize = function() {
// 清除现有的防火墙元素
const firewall = document.getElementById('firewall');
firewall.innerHTML = '';
// 创建新的效果以适应新的窗口大小
createFirewallBars();
// 重新初始化雨滴效果
initRain();
}
// 获取设备 IP 地址
async function getDeviceIP() {
try {
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
return data.ip;
} catch (error) {
console.error('获取 IP 地址失败:', error);
return '无法获取 IP 地址';
}
}
// 黑名单设置(模拟)
const blacklist = {
'192.168.1.100': new Date().getTime() + 300000, // 5 分钟后解除
'192.168.1.101': new Date().getTime() + 600000 // 10 分钟后解除
};
// 更新 IP 信息和状态
function updateIPInfo() {
getDeviceIP().then(ip => {
const deviceIpElement = document.getElementById('device-ip');
deviceIpElement.textContent = ip;
// 检查 IP 是否在黑名单中
const currentTime = new Date().getTime();
if (blacklist[ip]) {
const endTime = blacklist[ip];
const remainingTime = endTime - currentTime;
if (remainingTime > 0) {
// 更新剩余时间显示
const remainingTimeElement = document.getElementById('remaining-time');
const minutes = Math.floor(remainingTime / 60000);
const seconds = Math.floor((remainingTime % 60000) / 1000);
remainingTimeElement.textContent = `${minutes} 分钟 ${seconds} 秒`;
// 每秒更新一次剩余时间
setTimeout(updateIPInfo, 1000);
} else {
// 时间已到,申请管理员
document.getElementById('access-status').textContent = '正在申请管理员权限';
document.getElementById('access-info').textContent = '您的访问请求正在审核中';
document.getElementById('retry-button').textContent = '刷新状态';
document.getElementById('remaining-time').textContent = '审核中';
}
} else {
// IP 不在黑名单中
document.getElementById('current-status').textContent = '封锁';
document.getElementById('remaining-time').textContent = '您未连接到ip或服务器';
}
});
}
// 尝试访问函数
function retryAccess() {
const deviceIp = document.getElementById('device-ip').textContent;
if (deviceIp === '无法获取 IP 地址') {
alert('无法获取您的 IP 地址,请检查网络连接');
return;
}
// 模拟重新加载页面
location.reload();
}
// 页面加载时初始化
window.onload = function() {
createFirewallBars();
initRain();
updateIPInfo();
// 更新访问时间
const currentTime = new Date();
const formattedTime = `${currentTime.getFullYear()}-${String(currentTime.getMonth() + 1).padStart(2, '0')}-${String(currentTime.getDate()).padStart(2, '0')} ${String(currentTime.getHours()).padStart(2, '0')}:${String(currentTime.getMinutes()).padStart(2, '0')}:${String(currentTime.getSeconds()).padStart(2, '0')}`;
document.getElementById('access-time').textContent = formattedTime;
};
// 绘制卡片边角下压效果
function drawCardCorners() {
const cardCanvas = document.getElementById('card-canvas');
const ctx = cardCanvas.getContext('2d');
// 清除画布
ctx.clearRect(0, 0, cardCanvas.width, cardCanvas.height);
// 设置边角样式
ctx.strokeStyle = '#00ff00';
ctx.lineWidth = 1;
// 左上角
ctx.beginPath();
ctx.moveTo(10, 0);
ctx.lineTo(0, 10);
ctx.lineTo(20, 20);
ctx.lineTo(20, 0);
ctx.closePath();
ctx.stroke();
// 右上角
ctx.beginPath();
ctx.moveTo(cardCanvas.width - 10, 0);
ctx.lineTo(cardCanvas.width, 10);
ctx.lineTo(cardCanvas.width - 20, 20);
ctx.lineTo(cardCanvas.width - 20, 0);
ctx.closePath();
ctx.stroke();
// 左下角
ctx.beginPath();
ctx.moveTo(10, cardCanvas.height);
ctx.lineTo(0, cardCanvas.height - 10);
ctx.lineTo(20, cardCanvas.height - 20);
ctx.lineTo(20, cardCanvas.height);
ctx.closePath();
ctx.stroke();
// 右下角
ctx.beginPath();
ctx.moveTo(cardCanvas.width - 10, cardCanvas.height);
ctx.lineTo(cardCanvas.width, cardCanvas.height - 10);
ctx.lineTo(cardCanvas.width - 20, cardCanvas.height - 20);
ctx.lineTo(cardCanvas.width - 20, cardCanvas.height);
ctx.closePath();
ctx.stroke();
}
// 页面加载和窗口大小改变时初始化效果
window.onload = function() {
createFirewallBars();
initRain();
updateIPInfo();
// 更新访问时间
const currentTime = new Date();
const formattedTime = `${currentTime.getFullYear()}-${String(currentTime.getMonth() + 1).padStart(2, '0')}-${String(currentTime.getDate()).padStart(2, '0')} ${String(currentTime.getHours()).padStart(2, '0')}:${String(currentTime.getMinutes()).padStart(2, '0')}:${String(currentTime.getSeconds()).padStart(2, '0')}`;
document.getElementById('access-time').textContent = formattedTime;
// 绘制卡片边角
drawCardCorners();
};
// 响应窗口大小变化
window.onresize = function() {
// 清除现有的防火墙元素
const firewall = document.getElementById('firewall');
firewall.innerHTML = '';
// 创建新的效果以适应新的窗口大小
createFirewallBars();
// 重新初始化雨滴效果
initRain();
// 重新绘制卡片边角
drawCardCorners();
};
预览