From c274c59044e01ae65b7ba7f69915bedb414dc3b8 Mon Sep 17 00:00:00 2001 From: coward Date: Fri, 8 Mar 2024 16:30:29 +0800 Subject: [PATCH] =?UTF-8?q?:art:=E5=90=8C=E6=AD=A5=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=94=B9=E4=B8=BA=E9=98=9F=E5=88=97=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=EF=BC=88=E6=B2=A1=E5=86=99=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constant/cache_prefix.go | 4 + global/global.go | 4 - http/api/server.go | 63 ++++++++++- http/param/server.go | 10 ++ logs/runtime-hyxc.log | 237 +++++++++++++++++++++++++++++++++++++++ repository/server.go | 23 +++- route/server.go | 3 +- script/db_migrate.go | 13 ++- 8 files changed, 343 insertions(+), 14 deletions(-) create mode 100644 http/param/server.go diff --git a/constant/cache_prefix.go b/constant/cache_prefix.go index 0acfae8..b36146d 100644 --- a/constant/cache_prefix.go +++ b/constant/cache_prefix.go @@ -4,3 +4,7 @@ const ( Token = "token" // 登陆token Captcha = "captcha" // 验证码 ) + +const ( + SyncWgConfigFile = "queues:wg:" +) diff --git a/global/global.go b/global/global.go index 209f4be..dfbfa4a 100644 --- a/global/global.go +++ b/global/global.go @@ -1,5 +1 @@ package global - -import "sync" - -type ServerConfigMap = sync.Map diff --git a/http/api/server.go b/http/api/server.go index 45be57c..62c7d6f 100644 --- a/http/api/server.go +++ b/http/api/server.go @@ -1,7 +1,11 @@ package api import ( + "gitee.ltd/lxh/logger/log" "github.com/gin-gonic/gin" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" + "wireguard-dashboard/http/param" + "wireguard-dashboard/model/entity" "wireguard-dashboard/repository" "wireguard-dashboard/utils" ) @@ -12,6 +16,49 @@ func Server() server { return server{} } +// SaveServer +// @description: 新增/更新服务端信息 +// @receiver server +// @param c +func (server) SaveServer(c *gin.Context) { + var p param.SaveServer + if err := c.ShouldBind(&p); err != nil { + utils.GinResponse(c).FailedWithErr("参数错误", err) + return + } + + var err error + if p.Id != "" { + if err = repository.Server().Update(p); err != nil { + log.Errorf("更改服务端信息失败: %v", err.Error()) + } + } else { + privateKey, err := wgtypes.GeneratePrivateKey() + if err != nil { + utils.GinResponse(c).FailedWithMsg("生成密钥失败") + return + } + publicKey := privateKey.PublicKey() + if err = repository.Server().Save(&entity.Server{ + IpScope: p.IpScope, + ListenPort: p.ListenPort, + PrivateKey: privateKey.String(), + PublicKey: publicKey.String(), + PostUpScript: p.PostUpScript, + PreDownScript: p.PreDownScript, + PostDownScript: p.PostDownScript, + }); err != nil { + log.Errorf("新增服务端失败: %v", err.Error()) + } + } + + if err != nil { + utils.GinResponse(c).FailedWithMsg("操作失败") + return + } + +} + // GetServer // @description: 获取服务端信息 // @receiver wireguard @@ -19,8 +66,20 @@ func Server() server { func (server) GetServer(c *gin.Context) { data, err := repository.Server().GetServer() if err != nil { - utils.GinResponse(c).FailedWithMsg("获取服务端信息失败") - return + log.Errorf("获取服务端信息失败: %v", err.Error()) + } + + utils.GinResponse(c).OKWithData(data) +} + +// GetGlobalSetting +// @description: 获取全局设置配置 +// @receiver server +// @param c +func (server) GetGlobalSetting(c *gin.Context) { + data, err := repository.System().GetServerSetting() + if err != nil { + log.Errorf("获取配置失败: %v", err.Error()) } utils.GinResponse(c).OKWithData(data) diff --git a/http/param/server.go b/http/param/server.go new file mode 100644 index 0000000..0414ee0 --- /dev/null +++ b/http/param/server.go @@ -0,0 +1,10 @@ +package param + +type SaveServer struct { + Id string `json:"id" form:"id" binding:"omitempty"` // id + IpScope string `json:"ipScope" form:"ipScope" binding:"required"` // 内网ip范围段 + ListenPort int `json:"listenPort" form:"listenPort" binding:"required"` // 监听端口 + PostUpScript string `json:"postUpScript" form:"postUpScript" binding:"omitempty"` + PreDownScript string `json:"preDownScript" form:"preDownScript" binding:"omitempty"` + PostDownScript string `json:"postDownScript" form:"postDownScript" binding:"omitempty"` +} diff --git a/logs/runtime-hyxc.log b/logs/runtime-hyxc.log index 198d714..fb33770 100644 --- a/logs/runtime-hyxc.log +++ b/logs/runtime-hyxc.log @@ -1595,3 +1595,240 @@ [2024-03-08 10:42:12.160] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 [2024-03-08 10:42:12.160] INFO script/db_migrate.go:60 [0s] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 [2024-03-08 10:42:12.160] INFO script/db_migrate.go:97 [0s] [rows:1] SELECT count(*) FROM `t_wg_server` +[2024-03-08 10:42:30.920] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_user" +[2024-03-08 10:42:30.933] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_user" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:42:30.934] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_user` LIMIT 1 +[2024-03-08 10:42:30.934] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:42:30.934] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 10:42:30.935] INFO sqlite@v1.5.5/migrator.go:413 [1.0693ms] [rows:0] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 10:42:30.935] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 10:42:30.936] INFO sqlite@v1.5.5/migrator.go:423 [1.0001ms] [rows:1] DROP TABLE `t_user` +[2024-03-08 10:42:30.937] INFO sqlite@v1.5.5/migrator.go:423 [1.0004ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 10:42:30.938] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:42:30.939] INFO sqlite@v1.5.5/migrator.go:368 [1.0004ms] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 10:42:30.940] INFO sqlite@v1.5.5/migrator.go:413 [530µs] [rows:1] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 10:42:30.940] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 10:42:30.941] INFO sqlite@v1.5.5/migrator.go:423 [1.0048ms] [rows:1] DROP TABLE `t_user` +[2024-03-08 10:42:30.942] INFO sqlite@v1.5.5/migrator.go:423 [999.9µs] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 10:42:30.944] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_server" +[2024-03-08 10:42:30.944] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_server" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:42:30.944] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_server` LIMIT 1 +[2024-03-08 10:42:30.944] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:42:30.944] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_server" AND name = "t_wg_server" +[2024-03-08 10:42:30.945] INFO sqlite@v1.5.5/migrator.go:413 [0s] [rows:1] CREATE TABLE `t_wg_server__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`ip_scope` varchar(30) NOT NULL,`listen_port` int(10) NOT NULL,`private_key` text NOT NULL,`public_key` text NOT NULL,`post_up_script` text,`pre_down_script` text,`post_down_script` text,PRIMARY KEY (`id`)) +[2024-03-08 10:42:30.945] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_server__temp`(`id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script`) SELECT `id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script` FROM `t_wg_server` +[2024-03-08 10:42:30.946] INFO sqlite@v1.5.5/migrator.go:423 [1.0002ms] [rows:0] DROP TABLE `t_wg_server` +[2024-03-08 10:42:30.947] INFO sqlite@v1.5.5/migrator.go:423 [1.0003ms] [rows:0] ALTER TABLE `t_wg_server__temp` RENAME TO `t_wg_server` +[2024-03-08 10:42:30.949] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_client" +[2024-03-08 10:42:30.949] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_client" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:42:30.950] INFO sqlite@v1.5.5/migrator.go:125 [1.0002ms] [-] SELECT * FROM `t_wg_client` LIMIT 1 +[2024-03-08 10:42:30.950] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:42:30.950] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 10:42:30.951] INFO sqlite@v1.5.5/migrator.go:413 [999.9µs] [rows:0] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 10:42:30.951] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 10:42:30.951] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 10:42:30.953] INFO sqlite@v1.5.5/migrator.go:423 [1.001ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 10:42:30.955] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:42:30.955] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 10:42:30.956] INFO sqlite@v1.5.5/migrator.go:413 [579.9µs] [rows:0] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 10:42:30.957] INFO sqlite@v1.5.5/migrator.go:423 [503.5µs] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 10:42:30.957] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 10:42:30.958] INFO sqlite@v1.5.5/migrator.go:423 [1.5626ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 10:42:30.960] INFO sqlite@v1.5.5/migrator.go:219 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND (sql LIKE "%CONSTRAINT ""fk_t_wg_server_clients"" %" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %" OR sql LIKE "%CONSTRAINT `fk_t_wg_server_clients`%" OR sql LIKE "%CONSTRAINT [fk_t_wg_server_clients]%" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %") +[2024-03-08 10:42:30.960] INFO sqlite@v1.5.5/migrator.go:32 [520.4µs] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_setting" +[2024-03-08 10:42:30.960] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_setting" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:42:30.960] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 +[2024-03-08 10:42:30.961] INFO script/db_migrate.go:60 [0s] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 +[2024-03-08 10:42:30.961] INFO script/db_migrate.go:97 [0s] [rows:1] SELECT count(*) FROM `t_wg_server` +[2024-03-08 10:42:31.934] ERROR repository/system.go:28 record not found -> SELECT * FROM `t_setting` WHERE code = "SERVER_SETTING" ORDER BY `t_setting`.`id` LIMIT 1 +[2024-03-08 10:42:31.937] INFO repository/system.go:59 [2.2855ms] [rows:1] INSERT INTO `t_setting` (`id`,`created_at`,`updated_at`,`code`,`data`,`describe`) VALUES ("5a18e3d7545d452fbc8ba5568a786a8d","2024-03-08 10:42:31","2024-03-08 10:42:31","SERVER_SETTING","{""MTU"":1450,""configFilePath"":""/etc/wireguard/wg0.conf"",""dnsServer"":""10.10.10.1/24"",""endpointAddress"":""222.183.237.53"",""firewallMark"":"""",""persistentKeepalive"":15,""table"":""""}","服务端全局配置") +[2024-03-08 10:42:31.939] INFO repository/server.go:40 [1.6029ms] [rows:1] INSERT INTO `t_wg_server` (`id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script`) VALUES ("2cc89e0b665c47b683a4042b8654062a","2024-03-08 10:42:31","2024-03-08 10:42:31","10.10.10.1/24",51820,"sO8kK0Jzw/TGRKJ9hl7bWq19NnkcOF/Zq0gzkbnh8Xw=","lYUdv0QUgrHsLzFl05l56UA9XaKEtB+eraxIOMLXjis=","","","") +[2024-03-08 10:45:01.868] INFO repository/user.go:55 [503.7µs] [rows:1] SELECT * FROM `t_user` WHERE account = "Admin" ORDER BY `t_user`.`id` LIMIT 1 +[2024-03-08 10:45:24.815] INFO repository/user.go:44 [862.1µs] [rows:1] SELECT * FROM `t_user` WHERE id = "0dbdde3660934396b79a6bad002d82a8" ORDER BY `t_user`.`id` LIMIT 1 +[2024-03-08 10:45:24.815] INFO repository/server.go:26 [504.3µs] [rows:1] SELECT `t_wg_server`.`id`,`t_wg_server`.`ip_scope`,`t_wg_server`.`listen_port`,`t_wg_server`.`private_key`,`t_wg_server`.`public_key`,`t_wg_server`.`post_up_script`,`t_wg_server`.`pre_down_script`,`t_wg_server`.`post_down_script` FROM `t_wg_server` ORDER BY `t_wg_server`.`id` LIMIT 1 +[2024-03-08 10:59:48.534] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_user" +[2024-03-08 10:59:48.547] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_user" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:59:48.547] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_user` LIMIT 1 +[2024-03-08 10:59:48.547] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:59:48.547] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 10:59:48.549] INFO sqlite@v1.5.5/migrator.go:413 [1.0406ms] [rows:0] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 10:59:48.549] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 10:59:48.549] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_user` +[2024-03-08 10:59:48.550] INFO sqlite@v1.5.5/migrator.go:423 [1.0002ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 10:59:48.552] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:59:48.552] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 10:59:48.553] INFO sqlite@v1.5.5/migrator.go:413 [998.6µs] [rows:1] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 10:59:48.553] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 10:59:48.554] INFO sqlite@v1.5.5/migrator.go:423 [1.0002ms] [rows:1] DROP TABLE `t_user` +[2024-03-08 10:59:48.555] INFO sqlite@v1.5.5/migrator.go:423 [1.0082ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 10:59:48.557] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_server" +[2024-03-08 10:59:48.557] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_server" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:59:48.557] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_server` LIMIT 1 +[2024-03-08 10:59:48.557] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:59:48.557] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_server" AND name = "t_wg_server" +[2024-03-08 10:59:48.559] INFO sqlite@v1.5.5/migrator.go:413 [1.0431ms] [rows:1] CREATE TABLE `t_wg_server__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`ip_scope` varchar(30) NOT NULL,`listen_port` int(10) NOT NULL,`private_key` text NOT NULL,`public_key` text NOT NULL,`post_up_script` text,`pre_down_script` text,`post_down_script` text,PRIMARY KEY (`id`)) +[2024-03-08 10:59:48.559] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_wg_server__temp`(`id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script`) SELECT `id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script` FROM `t_wg_server` +[2024-03-08 10:59:48.559] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_wg_server` +[2024-03-08 10:59:48.560] INFO sqlite@v1.5.5/migrator.go:423 [1.013ms] [rows:1] ALTER TABLE `t_wg_server__temp` RENAME TO `t_wg_server` +[2024-03-08 10:59:48.562] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_client" +[2024-03-08 10:59:48.562] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_client" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:59:48.562] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_client` LIMIT 1 +[2024-03-08 10:59:48.562] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:59:48.563] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 10:59:48.564] INFO sqlite@v1.5.5/migrator.go:413 [990.7µs] [rows:1] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 10:59:48.564] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 10:59:48.564] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 10:59:48.565] INFO sqlite@v1.5.5/migrator.go:423 [999.4µs] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 10:59:48.567] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 10:59:48.567] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 10:59:48.568] INFO sqlite@v1.5.5/migrator.go:413 [0s] [rows:0] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 10:59:48.568] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 10:59:48.568] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 10:59:48.570] INFO sqlite@v1.5.5/migrator.go:423 [1.0004ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 10:59:48.571] INFO sqlite@v1.5.5/migrator.go:219 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND (sql LIKE "%CONSTRAINT ""fk_t_wg_server_clients"" %" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %" OR sql LIKE "%CONSTRAINT `fk_t_wg_server_clients`%" OR sql LIKE "%CONSTRAINT [fk_t_wg_server_clients]%" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %") +[2024-03-08 10:59:48.571] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_setting" +[2024-03-08 10:59:48.572] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_setting" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 10:59:48.572] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 +[2024-03-08 10:59:48.572] INFO script/db_migrate.go:61 [0s] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 +[2024-03-08 10:59:48.572] INFO script/db_migrate.go:98 [0s] [rows:1] SELECT count(*) FROM `t_wg_server` +[2024-03-08 11:00:08.344] INFO repository/user.go:44 [368.3µs] [rows:1] SELECT * FROM `t_user` WHERE id = "0dbdde3660934396b79a6bad002d82a8" ORDER BY `t_user`.`id` LIMIT 1 +[2024-03-08 11:00:08.344] INFO repository/system.go:28 [503.5µs] [rows:1] SELECT * FROM `t_setting` WHERE code = "SERVER_SETTING" ORDER BY `t_setting`.`id` LIMIT 1 +[2024-03-08 11:01:14.450] INFO sqlite@v1.5.5/migrator.go:32 [542.5µs] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_user" +[2024-03-08 11:01:14.464] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_user" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:14.464] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_user` LIMIT 1 +[2024-03-08 11:01:14.465] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:14.465] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 11:01:14.466] INFO sqlite@v1.5.5/migrator.go:413 [1.0136ms] [rows:0] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 11:01:14.467] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 11:01:14.467] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_user` +[2024-03-08 11:01:14.469] INFO sqlite@v1.5.5/migrator.go:423 [1.5163ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 11:01:14.471] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:14.471] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 11:01:14.472] INFO sqlite@v1.5.5/migrator.go:413 [0s] [rows:1] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 11:01:14.473] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 11:01:14.473] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_user` +[2024-03-08 11:01:14.474] INFO sqlite@v1.5.5/migrator.go:423 [1.0006ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 11:01:14.477] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_server" +[2024-03-08 11:01:14.477] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_server" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:14.478] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_server` LIMIT 1 +[2024-03-08 11:01:14.478] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:14.478] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_server" AND name = "t_wg_server" +[2024-03-08 11:01:14.479] INFO sqlite@v1.5.5/migrator.go:413 [990.8µs] [rows:1] CREATE TABLE `t_wg_server__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`ip_scope` varchar(30) NOT NULL,`listen_port` int(10) NOT NULL,`private_key` text NOT NULL,`public_key` text NOT NULL,`post_up_script` text,`pre_down_script` text,`post_down_script` text,PRIMARY KEY (`id`)) +[2024-03-08 11:01:14.479] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_wg_server__temp`(`id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script`) SELECT `id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script` FROM `t_wg_server` +[2024-03-08 11:01:14.480] INFO sqlite@v1.5.5/migrator.go:423 [1.0006ms] [rows:1] DROP TABLE `t_wg_server` +[2024-03-08 11:01:14.481] INFO sqlite@v1.5.5/migrator.go:423 [1.0088ms] [rows:1] ALTER TABLE `t_wg_server__temp` RENAME TO `t_wg_server` +[2024-03-08 11:01:14.483] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_client" +[2024-03-08 11:01:14.483] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_client" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:14.483] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_client` LIMIT 1 +[2024-03-08 11:01:14.484] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:14.484] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 11:01:14.485] INFO sqlite@v1.5.5/migrator.go:413 [1.1802ms] [rows:1] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 11:01:14.485] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 11:01:14.485] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 11:01:14.487] INFO sqlite@v1.5.5/migrator.go:423 [1.0094ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 11:01:14.489] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:14.489] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 11:01:14.490] INFO sqlite@v1.5.5/migrator.go:413 [0s] [rows:0] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 11:01:14.491] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 11:01:14.491] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 11:01:14.492] INFO sqlite@v1.5.5/migrator.go:423 [1.008ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 11:01:14.494] INFO sqlite@v1.5.5/migrator.go:219 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND (sql LIKE "%CONSTRAINT ""fk_t_wg_server_clients"" %" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %" OR sql LIKE "%CONSTRAINT `fk_t_wg_server_clients`%" OR sql LIKE "%CONSTRAINT [fk_t_wg_server_clients]%" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %") +[2024-03-08 11:01:14.496] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_setting" +[2024-03-08 11:01:14.496] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_setting" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:14.496] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 +[2024-03-08 11:01:14.496] INFO script/db_migrate.go:61 [0s] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 +[2024-03-08 11:01:14.496] INFO script/db_migrate.go:98 [0s] [rows:1] SELECT count(*) FROM `t_wg_server` +[2024-03-08 11:01:35.507] INFO sqlite@v1.5.5/migrator.go:32 [59.2µs] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_user" +[2024-03-08 11:01:35.518] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_user" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:35.519] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_user` LIMIT 1 +[2024-03-08 11:01:35.519] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:35.520] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 11:01:35.521] INFO sqlite@v1.5.5/migrator.go:413 [1.1159ms] [rows:0] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 11:01:35.521] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 11:01:35.521] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_user` +[2024-03-08 11:01:35.522] INFO sqlite@v1.5.5/migrator.go:423 [1.1247ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 11:01:35.524] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:35.524] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 11:01:35.525] INFO sqlite@v1.5.5/migrator.go:413 [599.3µs] [rows:1] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 11:01:35.526] INFO sqlite@v1.5.5/migrator.go:423 [503.5µs] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 11:01:35.526] INFO sqlite@v1.5.5/migrator.go:423 [602µs] [rows:1] DROP TABLE `t_user` +[2024-03-08 11:01:35.528] INFO sqlite@v1.5.5/migrator.go:423 [1.452ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 11:01:35.530] INFO sqlite@v1.5.5/migrator.go:32 [937.8µs] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_server" +[2024-03-08 11:01:35.530] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_server" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:35.530] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_server` LIMIT 1 +[2024-03-08 11:01:35.530] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:35.530] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_server" AND name = "t_wg_server" +[2024-03-08 11:01:35.531] INFO sqlite@v1.5.5/migrator.go:413 [0s] [rows:1] CREATE TABLE `t_wg_server__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`ip_scope` varchar(30) NOT NULL,`listen_port` int(10) NOT NULL,`private_key` text NOT NULL,`public_key` text NOT NULL,`post_up_script` text,`pre_down_script` text,`post_down_script` text,PRIMARY KEY (`id`)) +[2024-03-08 11:01:35.531] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_wg_server__temp`(`id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script`) SELECT `id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script` FROM `t_wg_server` +[2024-03-08 11:01:35.532] INFO sqlite@v1.5.5/migrator.go:423 [1.0002ms] [rows:1] DROP TABLE `t_wg_server` +[2024-03-08 11:01:35.533] INFO sqlite@v1.5.5/migrator.go:423 [1.508ms] [rows:1] ALTER TABLE `t_wg_server__temp` RENAME TO `t_wg_server` +[2024-03-08 11:01:35.534] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_client" +[2024-03-08 11:01:35.535] INFO migrator/migrator.go:73 [1.0659ms] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_client" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:35.535] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_client` LIMIT 1 +[2024-03-08 11:01:35.535] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:35.535] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 11:01:35.536] INFO sqlite@v1.5.5/migrator.go:413 [0s] [rows:1] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 11:01:35.536] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 11:01:35.537] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 11:01:35.539] INFO sqlite@v1.5.5/migrator.go:423 [1.133ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 11:01:35.539] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 11:01:35.540] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 11:01:35.542] INFO sqlite@v1.5.5/migrator.go:413 [1.0247ms] [rows:0] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 11:01:35.542] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 11:01:35.542] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 11:01:35.543] INFO sqlite@v1.5.5/migrator.go:423 [1.9721ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 11:01:35.544] INFO sqlite@v1.5.5/migrator.go:219 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND (sql LIKE "%CONSTRAINT ""fk_t_wg_server_clients"" %" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %" OR sql LIKE "%CONSTRAINT `fk_t_wg_server_clients`%" OR sql LIKE "%CONSTRAINT [fk_t_wg_server_clients]%" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %") +[2024-03-08 11:01:35.544] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_setting" +[2024-03-08 11:01:35.545] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_setting" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 11:01:35.545] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 +[2024-03-08 11:01:35.545] INFO script/db_migrate.go:61 [0s] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 +[2024-03-08 11:01:35.545] INFO script/db_migrate.go:98 [0s] [rows:1] SELECT count(*) FROM `t_wg_server` +[2024-03-08 11:01:44.066] INFO repository/user.go:44 [511.7µs] [rows:1] SELECT * FROM `t_user` WHERE id = "0dbdde3660934396b79a6bad002d82a8" ORDER BY `t_user`.`id` LIMIT 1 +[2024-03-08 11:01:44.067] INFO repository/system.go:28 [503.3µs] [rows:1] SELECT * FROM `t_setting` WHERE code = "SERVER_SETTING" ORDER BY `t_setting`.`id` LIMIT 1 +[2024-03-08 11:01:47.455] INFO repository/user.go:44 [348.5µs] [rows:1] SELECT * FROM `t_user` WHERE id = "0dbdde3660934396b79a6bad002d82a8" ORDER BY `t_user`.`id` LIMIT 1 +[2024-03-08 11:01:47.456] INFO repository/server.go:26 [504.2µs] [rows:1] SELECT `t_wg_server`.`id`,`t_wg_server`.`ip_scope`,`t_wg_server`.`listen_port`,`t_wg_server`.`private_key`,`t_wg_server`.`public_key`,`t_wg_server`.`post_up_script`,`t_wg_server`.`pre_down_script`,`t_wg_server`.`post_down_script` FROM `t_wg_server` ORDER BY `t_wg_server`.`id` LIMIT 1 +[2024-03-08 14:59:07.136] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_user" +[2024-03-08 14:59:07.148] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_user" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 14:59:07.148] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_user` LIMIT 1 +[2024-03-08 14:59:07.149] INFO sqlite@v1.5.5/migrator.go:79 [999.3µs] [rows:1] PRAGMA foreign_keys +[2024-03-08 14:59:07.149] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 14:59:07.150] INFO sqlite@v1.5.5/migrator.go:413 [1.0706ms] [rows:0] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 14:59:07.151] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 14:59:07.151] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_user` +[2024-03-08 14:59:07.152] INFO sqlite@v1.5.5/migrator.go:423 [1.0101ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 14:59:07.155] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 14:59:07.155] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_user" AND name = "t_user" +[2024-03-08 14:59:07.156] INFO sqlite@v1.5.5/migrator.go:413 [0s] [rows:1] CREATE TABLE `t_user__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`avatar` varchar(255) NOT NULL,`name` varchar(50) NOT NULL,`account` varchar(50) NOT NULL,`email` varchar(255),`password` varchar(255) NOT NULL,`is_admin` int(1) NOT NULL,`status` tinyint(1) NOT NULL,PRIMARY KEY (`id`)) +[2024-03-08 14:59:07.157] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_user__temp`(`id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status`) SELECT `id`,`created_at`,`updated_at`,`avatar`,`name`,`account`,`email`,`password`,`is_admin`,`status` FROM `t_user` +[2024-03-08 14:59:07.157] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_user` +[2024-03-08 14:59:07.160] INFO sqlite@v1.5.5/migrator.go:423 [3.1008ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-08 14:59:07.162] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_server" +[2024-03-08 14:59:07.162] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_server" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 14:59:07.162] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_server` LIMIT 1 +[2024-03-08 14:59:07.162] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 14:59:07.163] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_server" AND name = "t_wg_server" +[2024-03-08 14:59:07.164] INFO sqlite@v1.5.5/migrator.go:413 [1.0062ms] [rows:1] CREATE TABLE `t_wg_server__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`ip_scope` varchar(30) NOT NULL,`listen_port` int(10) NOT NULL,`private_key` text NOT NULL,`public_key` text NOT NULL,`post_up_script` text,`pre_down_script` text,`post_down_script` text,PRIMARY KEY (`id`)) +[2024-03-08 14:59:07.164] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] INSERT INTO `t_wg_server__temp`(`id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script`) SELECT `id`,`created_at`,`updated_at`,`ip_scope`,`listen_port`,`private_key`,`public_key`,`post_up_script`,`pre_down_script`,`post_down_script` FROM `t_wg_server` +[2024-03-08 14:59:07.164] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:1] DROP TABLE `t_wg_server` +[2024-03-08 14:59:07.166] INFO sqlite@v1.5.5/migrator.go:423 [2.0002ms] [rows:1] ALTER TABLE `t_wg_server__temp` RENAME TO `t_wg_server` +[2024-03-08 14:59:07.167] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_client" +[2024-03-08 14:59:07.167] INFO migrator/migrator.go:73 [0s] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_wg_client" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 14:59:07.169] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_client` LIMIT 1 +[2024-03-08 14:59:07.169] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 14:59:07.169] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 14:59:07.170] INFO sqlite@v1.5.5/migrator.go:413 [1.0749ms] [rows:1] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 14:59:07.170] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 14:59:07.170] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 14:59:07.172] INFO sqlite@v1.5.5/migrator.go:423 [2.1557ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 14:59:07.174] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-08 14:59:07.174] INFO sqlite@v1.5.5/migrator.go:368 [0s] [-] SELECT sql FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND name = "t_wg_client" +[2024-03-08 14:59:07.176] INFO sqlite@v1.5.5/migrator.go:413 [531.7µs] [rows:0] CREATE TABLE `t_wg_client__temp` (`id` varchar(36) NOT NULL,`created_at` datetime,`updated_at` datetime,`server_id` varchar(36) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100),`subnet_range` varchar(255),`ip_allocation` varchar(30) NOT NULL,`allowed_ips` varchar(30) NOT NULL,`extra_allowed_ips` varchar(30),`endpoint` varchar(255),`use_server_dns` int(1),`enable_after_creation` int(1),`keys` text,`user_id` char(36) NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_t_wg_server_clients` FOREIGN KEY (`server_id`) REFERENCES `t_wg_server`(`id`)) +[2024-03-08 14:59:07.176] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] INSERT INTO `t_wg_client__temp`(`id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id`) SELECT `id`,`created_at`,`updated_at`,`server_id`,`name`,`email`,`subnet_range`,`ip_allocation`,`allowed_ips`,`extra_allowed_ips`,`endpoint`,`use_server_dns`,`enable_after_creation`,`keys`,`user_id` FROM `t_wg_client` +[2024-03-08 14:59:07.176] INFO sqlite@v1.5.5/migrator.go:423 [516.1µs] [rows:0] DROP TABLE `t_wg_client` +[2024-03-08 14:59:07.177] INFO sqlite@v1.5.5/migrator.go:423 [1.0676ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-08 14:59:07.179] INFO sqlite@v1.5.5/migrator.go:219 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "t_wg_client" AND (sql LIKE "%CONSTRAINT ""fk_t_wg_server_clients"" %" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %" OR sql LIKE "%CONSTRAINT `fk_t_wg_server_clients`%" OR sql LIKE "%CONSTRAINT [fk_t_wg_server_clients]%" OR sql LIKE "%CONSTRAINT fk_t_wg_server_clients %") +[2024-03-08 14:59:07.179] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_setting" +[2024-03-08 14:59:07.179] INFO migrator/migrator.go:73 [534.1µs] [rows:1] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "t_setting" AND sql IS NOT NULL order by type = "table" desc +[2024-03-08 14:59:07.179] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 +[2024-03-08 14:59:07.179] INFO script/db_migrate.go:61 [0s] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 +[2024-03-08 14:59:07.180] INFO script/db_migrate.go:98 [0s] [rows:1] SELECT count(*) FROM `t_wg_server` diff --git a/repository/server.go b/repository/server.go index 8504ee5..7add245 100644 --- a/repository/server.go +++ b/repository/server.go @@ -3,6 +3,7 @@ package repository import ( "gorm.io/gorm" "wireguard-dashboard/client" + "wireguard-dashboard/http/param" "wireguard-dashboard/model/entity" "wireguard-dashboard/model/vo" ) @@ -28,14 +29,26 @@ func (r server) GetServer() (data *vo.Server, err error) { } // Save -// @description: 新增/更新服务端信息 +// @description: 新增服务端信息 // @receiver r // @param ent // @return err func (r server) Save(ent *entity.Server) (err error) { - if ent.Id != "" { - return r.Model(&entity.Server{}).Updates(&ent).Error - } - return r.Model(&entity.Server{}).Create(&ent).Error } + +// Update +// @description: 更新服务端信息 +// @receiver r +// @param p +// @return err +func (r server) Update(p param.SaveServer) (err error) { + update := map[string]any{ + "ip_scope": p.IpScope, + "listen_port": p.ListenPort, + "post_up_script": p.PostUpScript, + "pre_down_script": p.PreDownScript, + "post_down_script": p.PostDownScript, + } + return r.Model(&entity.Server{}).Where("id = ?", p.Id).Updates(&update).Error +} diff --git a/route/server.go b/route/server.go index 1eae386..4c51d77 100644 --- a/route/server.go +++ b/route/server.go @@ -9,6 +9,7 @@ import ( func ServerApi(r *gin.Engine) { apiGroup := r.Group("server", middleware.Authorization()) { - apiGroup.GET("", api.Server().GetServer) // 获取服务端信息 + apiGroup.GET("", api.Server().GetServer) // 获取服务端信息 + apiGroup.GET("global-setting", api.Server().GetGlobalSetting) // 获取服务端全局配置 } } diff --git a/script/db_migrate.go b/script/db_migrate.go index d5a68cd..0e6840f 100644 --- a/script/db_migrate.go +++ b/script/db_migrate.go @@ -5,6 +5,7 @@ import ( "gitee.ltd/lxh/logger/log" "github.com/spf13/cast" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" + "os" "wireguard-dashboard/client" "wireguard-dashboard/component" "wireguard-dashboard/constant" @@ -163,9 +164,17 @@ func (s Script) InitServer() error { "Server": serverConfig, } + var templatePath, outFilePath string + if os.Getenv("GIN_MODE") != "release" { + templatePath = "E:\\Workspace\\Go\\wireguard-dashboard\\template\\wg.conf" + outFilePath = "E:\\Workspace\\Go\\wireguard-dashboard\\wg0.conf" + } else { + templatePath = "./template/wg.conf" + outFilePath = cast.ToString(data["configFilePath"]) + } + // 数据库保存完毕,应用配置到配置文件当中 - err = component.Wireguard().Apply("E:\\Workspace\\Go\\wireguard-dashboard\\template\\wg.conf", - "E:\\Workspace\\Go\\wireguard-dashboard\\wg0.conf", execData) + err = component.Wireguard().Apply(templatePath, outFilePath, execData) if err != nil { log.Errorf("应用配置文件失败: %v", err.Error()) return err