Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
web_log
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
80a811ce
authored
Dec 28, 2020
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
增加用户配置文件
parent
6c742843
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
18 deletions
code/login.go
main.go
code/login.go
View file @
80a811ce
...
...
@@ -11,11 +11,11 @@ import (
"log"
"regexp"
"sync"
.
"web_log/config"
)
//var userMap = make(map[string]string)
var
sessionIdMap
=
make
(
map
[
string
]
string
)
var
configPath
string
=
"E:
\\
gotest
\\
test.json"
type
Configs
map
[
string
]
json
.
RawMessage
type
MainConfig
struct
{
...
...
@@ -27,18 +27,17 @@ var confs Configs
var
instanceOnce
sync
.
Once
func
init
()
{
//userMap["weblog"] = "MTIzNDU2"
sessionIdMap
[
"S1oI0nPch9PzJ0ClGEODdzbqcq85JK7YwnLesuTWayU="
]
=
""
}
//初始化读取配置文件
func
Init
(
path
string
)
*
MainConfig
{
if
conf
!=
nil
&&
path
!=
c
onfigPath
{
log
.
Printf
(
"the config is already initialized, oldPath=%s, path=%s"
,
c
onfigPath
,
path
)
func
ReadUserConfig
(
path
string
)
*
MainConfig
{
if
conf
!=
nil
&&
path
!=
UserC
onfigPath
{
log
.
Printf
(
"the config is already initialized, oldPath=%s, path=%s"
,
UserC
onfigPath
,
path
)
}
instanceOnce
.
Do
(
func
()
{
allConfigs
,
mainConfig
:=
LoadConfig
(
path
)
c
onfigPath
=
path
UserC
onfigPath
=
path
conf
=
mainConfig
confs
=
allConfigs
})
...
...
@@ -48,7 +47,7 @@ func Init(path string) *MainConfig {
//获取配置文件路径
func
ConfigPath
()
string
{
return
c
onfigPath
return
UserC
onfigPath
}
/**
...
...
@@ -64,7 +63,7 @@ func VerifyUser(name string, pwd string) (result bool, msg string) {
}
path
:=
ConfigPath
()
//初始化配置文件
Init
(
path
)
ReadUserConfig
(
path
)
// 密码md5加密
pwd
=
EnMD5PwdCode
(
pwd
)
if
mapPwd
,
ok
:=
confs
[
name
];
ok
{
...
...
main.go
View file @
80a811ce
package
main
import
(
"fmt"
"github.com/kataras/iris/v12"
"os"
"web_log/code"
"web_log/config"
)
// example
func
main
()
{
Directory
:=
"E:
\\
test_logs"
// directory of the log
addrs
:=
"0.0.0.0:9997"
logenv
:=
os
.
Getenv
(
"GOLOGENV"
)
if
logenv
==
"TEST"
{
Directory
=
"/data/soft/bigdatav3.0/test_rsync_log"
}
if
logenv
==
"PRODUCT"
{
Directory
=
"/data/soft/rsync_log"
}
app
:=
code
.
GetApp
(
Directory
)
config
.
InitConfig
()
fmt
.
Printf
(
"查看日志目录: %s
\n
用户配置文件: %s"
,
config
.
Directory
,
config
.
UserConfigPath
)
app
:=
code
.
GetApp
(
config
.
Directory
)
app
.
Run
(
iris
.
Addr
(
addrs
),
iris
.
WithCharset
(
"UTF-8"
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment