From 4597a1d4429d21f4e09db07a1fc1a5d794ee41fd Mon Sep 17 00:00:00 2001 From: coward Date: Thu, 7 Mar 2024 17:33:49 +0800 Subject: [PATCH] =?UTF-8?q?:see=5Fno=5Fevil:=E6=B7=BB=E5=8A=A0.conf?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=A6=81=E6=AD=A2=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + logs/runtime-hyxc.log | 48 +++++++++++++++++++++++++++++++++++++++++++ template/wg.conf | 18 ---------------- wg0.conf | 10 --------- 4 files changed, 49 insertions(+), 28 deletions(-) delete mode 100644 template/wg.conf delete mode 100644 wg0.conf diff --git a/.gitignore b/.gitignore index 2e6c6d4..8d5aa12 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ go.work wg.db *.db *.yaml +*.conf diff --git a/logs/runtime-hyxc.log b/logs/runtime-hyxc.log index 713f8b8..4236756 100644 --- a/logs/runtime-hyxc.log +++ b/logs/runtime-hyxc.log @@ -833,3 +833,51 @@ [2024-03-07 17:30:39.258] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 [2024-03-07 17:30:39.258] INFO script/db_migrate.go:58 [0s] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 [2024-03-07 17:30:39.258] INFO script/db_migrate.go:95 [524.9µs] [rows:1] SELECT count(*) FROM `t_wg_server` +[2024-03-07 17:30:58.790] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_user" +[2024-03-07 17:30:58.805] 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-07 17:30:58.805] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_user` LIMIT 1 +[2024-03-07 17:30:58.805] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-07 17:30:58.805] 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-07 17:30:58.807] INFO sqlite@v1.5.5/migrator.go:413 [999.8µs] [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-07 17:30:58.807] 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-07 17:30:58.808] INFO sqlite@v1.5.5/migrator.go:423 [999.3µs] [rows:1] DROP TABLE `t_user` +[2024-03-07 17:30:58.809] INFO sqlite@v1.5.5/migrator.go:423 [504µs] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-07 17:30:58.812] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-07 17:30:58.812] 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-07 17:30:58.813] 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-07 17:30:58.813] 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-07 17:30:58.814] INFO sqlite@v1.5.5/migrator.go:423 [1.5063ms] [rows:1] DROP TABLE `t_user` +[2024-03-07 17:30:58.815] INFO sqlite@v1.5.5/migrator.go:423 [1.0059ms] [rows:1] ALTER TABLE `t_user__temp` RENAME TO `t_user` +[2024-03-07 17:30:58.817] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_server" +[2024-03-07 17:30:58.818] INFO migrator/migrator.go:73 [1.0008ms] [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-07 17:30:58.818] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_server` LIMIT 1 +[2024-03-07 17:30:58.818] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-07 17:30:58.818] 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-07 17:30:58.819] INFO sqlite@v1.5.5/migrator.go:413 [999.2µ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-07 17:30:58.819] 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-07 17:30:58.820] INFO sqlite@v1.5.5/migrator.go:423 [1.0002ms] [rows:0] DROP TABLE `t_wg_server` +[2024-03-07 17:30:58.821] INFO sqlite@v1.5.5/migrator.go:423 [999.8µs] [rows:0] ALTER TABLE `t_wg_server__temp` RENAME TO `t_wg_server` +[2024-03-07 17:30:58.823] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_wg_client" +[2024-03-07 17:30:58.823] 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-07 17:30:58.823] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_wg_client` LIMIT 1 +[2024-03-07 17:30:58.823] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-07 17:30:58.823] 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-07 17:30:58.825] INFO sqlite@v1.5.5/migrator.go:413 [506.3µ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-07 17:30:58.826] 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-07 17:30:58.827] INFO sqlite@v1.5.5/migrator.go:423 [999.7µs] [rows:0] DROP TABLE `t_wg_client` +[2024-03-07 17:30:58.828] INFO sqlite@v1.5.5/migrator.go:423 [1.0009ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-07 17:30:58.830] INFO sqlite@v1.5.5/migrator.go:79 [0s] [rows:1] PRAGMA foreign_keys +[2024-03-07 17:30:58.831] 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-07 17:30:58.832] INFO sqlite@v1.5.5/migrator.go:413 [1.0003ms] [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-07 17:30:58.833] 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-07 17:30:58.833] INFO sqlite@v1.5.5/migrator.go:423 [0s] [rows:0] DROP TABLE `t_wg_client` +[2024-03-07 17:30:58.835] INFO sqlite@v1.5.5/migrator.go:423 [1.5172ms] [rows:0] ALTER TABLE `t_wg_client__temp` RENAME TO `t_wg_client` +[2024-03-07 17:30:58.837] 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-07 17:30:58.837] INFO sqlite@v1.5.5/migrator.go:32 [0s] [-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="t_setting" +[2024-03-07 17:30:58.837] 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-07 17:30:58.837] INFO sqlite@v1.5.5/migrator.go:125 [0s] [-] SELECT * FROM `t_setting` LIMIT 1 +[2024-03-07 17:30:58.838] INFO script/db_migrate.go:58 [1ms] [rows:1] SELECT count(*) FROM `t_user` WHERE is_admin = 1 +[2024-03-07 17:30:58.838] INFO script/db_migrate.go:95 [0s] [rows:1] SELECT count(*) FROM `t_wg_server` +[2024-03-07 17:30:59.921] 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-07 17:30:59.924] INFO repository/system.go:59 [2.1686ms] [rows:1] INSERT INTO `t_setting` (`id`,`created_at`,`updated_at`,`code`,`data`,`describe`) VALUES ("b456253c6cdf4575acf6f22c0443b37e","2024-03-07 17:30:59","2024-03-07 17:30:59","SERVER_SETTING","{""MTU"":1450,""configFilePath"":""/etc/wireguard/wg0.conf"",""dnsServer"":""10.10.10.1/24"",""endpointAddress"":""222.183.239.10"",""firewallMark"":"""",""persistentKeepalive"":15,""table"":""""}","服务端全局配置") +[2024-03-07 17:30:59.927] INFO repository/server.go:40 [2.224ms] [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 ("613572f5d1be4b5ea866915894e80479","2024-03-07 17:30:59","2024-03-07 17:30:59","10.10.10.1/24",51820,"uIcQM4koYm5AFVy5DdJS+IXm/HdPDclz5iI2bcOFKF4=","77ZVC/0KnC6wfPTXiYqvuPfW3PcsgUpoa5fRCvIhpE8=","","","") diff --git a/template/wg.conf b/template/wg.conf deleted file mode 100644 index 0afb7b5..0000000 --- a/template/wg.conf +++ /dev/null @@ -1,18 +0,0 @@ -[Interface] -Address = {{ .Server.Address }} -ListenPort = {{ .Server.ListenPort }} -PrivateKey = {{ .Server.PrivateKey }} -MTU = {{ .Server.MTU }} -PostUp = {{ .Server.PostUp }} -PreDown = {{ .Server.PreDown }} -PostDown = {{ .Server.PostDown }} -Table = {{ .Server.Table }} - -{{ range .Clients }} -[Peer] -PublicKey = {{ .Client.PublicKey }} -PresharedKey = {{ .Client.PresharedKey }} -AllowedIPs = {{ .Client.AllowedIPs }} -PersistentKeepalive = {{ .Client.PersistentKeepalive }} -Endpoint = {{ .Client.Endpoint }} -{{ end }} \ No newline at end of file diff --git a/wg0.conf b/wg0.conf deleted file mode 100644 index 484ad12..0000000 --- a/wg0.conf +++ /dev/null @@ -1,10 +0,0 @@ -[Interface] -Address = -ListenPort = -PrivateKey = -MTU = -PostUp = -PreDown = -PostDown = -Table = -