Browse Source

style: Up conf

lejianwen 11 months ago
parent
commit
829f8799dd
2 changed files with 34 additions and 30 deletions
  1. 20 19
      conf/config.yaml
  2. 14 11
      config/config.go

+ 20 - 19
conf/config.yaml

@@ -40,24 +40,6 @@ proxy:
40
 jwt:
40
 jwt:
41
   key: ""
41
   key: ""
42
   expire-duration: 360000
42
   expire-duration: 360000
43
-redis:
44
-  addr: "127.0.0.1:6379"
45
-  password: ""
46
-  db: 0
47
-cache:
48
-  type: "file"
49
-  file-dir: "./runtime/cache"
50
-  redis-addr: "127.0.0.1:6379"
51
-  redis-pwd: ""
52
-  redis-db: 0
53
-oss:
54
-  access-key-id: ""
55
-  access-key-secret: ""
56
-  host: ""
57
-  callback-url: ""
58
-  expire-time: 30
59
-  max-byte: 10240
60
-
61
 ldap:
43
 ldap:
62
   enable: false
44
   enable: false
63
   url: "ldap://ldap.example.com:389"
45
   url: "ldap://ldap.example.com:389"
@@ -70,7 +52,7 @@ ldap:
70
   user:
52
   user:
71
     base-dn: "ou=users,dc=example,dc=com"
53
     base-dn: "ou=users,dc=example,dc=com"
72
     enable-attr: ""       #The attribute name of the user for enabling, in AD it is "userAccountControl", empty means no enable attribute, all users are enabled
54
     enable-attr: ""       #The attribute name of the user for enabling, in AD it is "userAccountControl", empty means no enable attribute, all users are enabled
73
-    enable-attr-value: "" # The value of the enable attribute when the user is enabled. If you are using AD, just set random value, it will be ignored. 
55
+    enable-attr-value: "" # The value of the enable attribute when the user is enabled. If you are using AD, just set random value, it will be ignored.
74
     filter: "(cn=*)"
56
     filter: "(cn=*)"
75
     username: "uid"       # The attribute name of the user for usernamem if you are using AD, it should be "sAMAccountName"
57
     username: "uid"       # The attribute name of the user for usernamem if you are using AD, it should be "sAMAccountName"
76
     email: "mail"
58
     email: "mail"
@@ -78,3 +60,22 @@ ldap:
78
     last-name: "sn"
60
     last-name: "sn"
79
     sync: false         # If true, the user will be synchronized to the database when the user logs in. If false, the user will be synchronized to the database when the user be created.
61
     sync: false         # If true, the user will be synchronized to the database when the user logs in. If false, the user will be synchronized to the database when the user be created.
80
     admin-group: "cn=admin,dc=example,dc=com" # The group name of the admin group, if the user is in this group, the user will be an admin.
62
     admin-group: "cn=admin,dc=example,dc=com" # The group name of the admin group, if the user is in this group, the user will be an admin.
63
+
64
+redis:
65
+  addr: "127.0.0.1:6379"
66
+  password: ""
67
+  db: 0
68
+cache:
69
+  type: "file"
70
+  file-dir: "./runtime/cache"
71
+  redis-addr: "127.0.0.1:6379"
72
+  redis-pwd: ""
73
+  redis-db: 0
74
+oss:
75
+  access-key-id: ""
76
+  access-key-secret: ""
77
+  host: ""
78
+  callback-url: ""
79
+  expire-time: 30
80
+  max-byte: 10240
81
+

+ 14 - 11
config/config.go

@@ -2,7 +2,6 @@ package config
2
 
2
 
3
 import (
3
 import (
4
 	"fmt"
4
 	"fmt"
5
-	"github.com/fsnotify/fsnotify"
6
 	"github.com/spf13/viper"
5
 	"github.com/spf13/viper"
7
 	"strings"
6
 	"strings"
8
 )
7
 )
@@ -38,7 +37,7 @@ type Config struct {
38
 	Jwt      Jwt
37
 	Jwt      Jwt
39
 	Rustdesk Rustdesk
38
 	Rustdesk Rustdesk
40
 	Proxy    Proxy
39
 	Proxy    Proxy
41
-	Ldap	 Ldap
40
+	Ldap     Ldap
42
 }
41
 }
43
 
42
 
44
 // Init 初始化配置
43
 // Init 初始化配置
@@ -57,15 +56,19 @@ func Init(rowVal *Config, path string) *viper.Viper {
57
 		panic(fmt.Errorf("Fatal error config file: %s \n", err))
56
 		panic(fmt.Errorf("Fatal error config file: %s \n", err))
58
 	}
57
 	}
59
 	v.WatchConfig()
58
 	v.WatchConfig()
60
-	v.OnConfigChange(func(e fsnotify.Event) {
61
-		//配置文件修改监听
62
-		fmt.Println("config file changed:", e.Name)
63
-		if err2 := v.Unmarshal(rowVal); err2 != nil {
64
-			fmt.Println(err2)
65
-		}
66
-		rowVal.Rustdesk.LoadKeyFile()
67
-		rowVal.Rustdesk.ParsePort()
68
-	})
59
+
60
+	/*
61
+		//监听配置修改没什么必要
62
+		v.OnConfigChange(func(e fsnotify.Event) {
63
+			//配置文件修改监听
64
+			fmt.Println("config file changed:", e.Name)
65
+			if err2 := v.Unmarshal(rowVal); err2 != nil {
66
+				fmt.Println(err2)
67
+			}
68
+			rowVal.Rustdesk.LoadKeyFile()
69
+			rowVal.Rustdesk.ParsePort()
70
+		})
71
+	*/
69
 	if err := v.Unmarshal(rowVal); err != nil {
72
 	if err := v.Unmarshal(rowVal); err != nil {
70
 		fmt.Println(err)
73
 		fmt.Println(err)
71
 	}
74
 	}