forked from kevin/lmvpn_server
- 新增 TUN 设备层(water 库),分 linux/darwin 平台配置 IP/路由/MTU - 实现 IP 分配管理:动态池自动分配 + 按用户静态预留,支持热更新 - 实现 PacketSwitch 共享 TUN 包转发:源 IP 防伪、按目的 IP 查表转发、allow-c2c - 重写隧道:自研简化 WS 协议(文本帧 JSON 控制 init/ready,二进制帧=原始 IP 包) - VpnService 单例管理 TUN 生命周期,子网变更踢线重建,预留增删热更新 - 新增 vpn_settings/vpn_reservations 表,AutoMigrate + 默认设置 seed - 新增 Admin API:settings 读写、status、clients、reservations CRUD - 前端新增 VpnView(/admin/vpn):状态面板/设置表单/在线客户端/静态预留 - main.go 启动时按 DB 设置初始化 VPN 服务
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import HomeView from '../views/HomeView.vue'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
name: 'home',
|
|
component: HomeView,
|
|
},
|
|
{
|
|
path: '/about',
|
|
name: 'about',
|
|
component: () => import('../views/AboutView.vue'),
|
|
},
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
component: () => import('../views/LoginView.vue'),
|
|
},
|
|
{
|
|
path: '/profile',
|
|
name: 'profile',
|
|
component: () => import('../views/ProfileView.vue'),
|
|
meta: { requiresAuth: true },
|
|
},
|
|
{
|
|
path: '/admin',
|
|
name: 'admin',
|
|
component: () => import('../views/AdminView.vue'),
|
|
meta: { requiresAuth: true, adminOnly: true },
|
|
},
|
|
{
|
|
path: '/admin/users',
|
|
name: 'users',
|
|
component: () => import('../views/UserManageView.vue'),
|
|
meta: { requiresAuth: true, adminOnly: true },
|
|
},
|
|
{
|
|
path: '/admin/vpn',
|
|
name: 'vpn',
|
|
component: () => import('../views/VpnView.vue'),
|
|
meta: { requiresAuth: true, adminOnly: true },
|
|
},
|
|
],
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
const authStore = useAuthStore()
|
|
|
|
if (to.meta.requiresAuth && !authStore.isLoggedIn) {
|
|
next({ name: 'login' })
|
|
} else if (to.meta.adminOnly && authStore.user?.role !== 'admin') {
|
|
next({ name: 'profile' })
|
|
} else if (to.name === 'login' && authStore.isLoggedIn) {
|
|
next({ name: 'profile' })
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|