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
Hide 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 (
...
@@ -11,11 +11,11 @@ import (
"log"
"log"
"regexp"
"regexp"
"sync"
"sync"
.
"web_log/config"
)
)
//var userMap = make(map[string]string)
//var userMap = make(map[string]string)
var
sessionIdMap
=
make
(
map
[
string
]
string
)
var
sessionIdMap
=
make
(
map
[
string
]
string
)
var
configPath
string
=
"E:
\\
gotest
\\
test.json"
type
Configs
map
[
string
]
json
.
RawMessage
type
Configs
map
[
string
]
json
.
RawMessage
type
MainConfig
struct
{
type
MainConfig
struct
{
...
@@ -27,18 +27,17 @@ var confs Configs
...
@@ -27,18 +27,17 @@ var confs Configs
var
instanceOnce
sync
.
Once
var
instanceOnce
sync
.
Once
func
init
()
{
func
init
()
{
//userMap["weblog"] = "MTIzNDU2"
sessionIdMap
[
"S1oI0nPch9PzJ0ClGEODdzbqcq85JK7YwnLesuTWayU="
]
=
""
sessionIdMap
[
"S1oI0nPch9PzJ0ClGEODdzbqcq85JK7YwnLesuTWayU="
]
=
""
}
}
//初始化读取配置文件
//初始化读取配置文件
func
Init
(
path
string
)
*
MainConfig
{
func
ReadUserConfig
(
path
string
)
*
MainConfig
{
if
conf
!=
nil
&&
path
!=
c
onfigPath
{
if
conf
!=
nil
&&
path
!=
UserC
onfigPath
{
log
.
Printf
(
"the config is already initialized, oldPath=%s, path=%s"
,
c
onfigPath
,
path
)
log
.
Printf
(
"the config is already initialized, oldPath=%s, path=%s"
,
UserC
onfigPath
,
path
)
}
}
instanceOnce
.
Do
(
func
()
{
instanceOnce
.
Do
(
func
()
{
allConfigs
,
mainConfig
:=
LoadConfig
(
path
)
allConfigs
,
mainConfig
:=
LoadConfig
(
path
)
c
onfigPath
=
path
UserC
onfigPath
=
path
conf
=
mainConfig
conf
=
mainConfig
confs
=
allConfigs
confs
=
allConfigs
})
})
...
@@ -48,7 +47,7 @@ func Init(path string) *MainConfig {
...
@@ -48,7 +47,7 @@ func Init(path string) *MainConfig {
//获取配置文件路径
//获取配置文件路径
func
ConfigPath
()
string
{
func
ConfigPath
()
string
{
return
c
onfigPath
return
UserC
onfigPath
}
}
/**
/**
...
@@ -64,7 +63,7 @@ func VerifyUser(name string, pwd string) (result bool, msg string) {
...
@@ -64,7 +63,7 @@ func VerifyUser(name string, pwd string) (result bool, msg string) {
}
}
path
:=
ConfigPath
()
path
:=
ConfigPath
()
//初始化配置文件
//初始化配置文件
Init
(
path
)
ReadUserConfig
(
path
)
// 密码md5加密
// 密码md5加密
pwd
=
EnMD5PwdCode
(
pwd
)
pwd
=
EnMD5PwdCode
(
pwd
)
if
mapPwd
,
ok
:=
confs
[
name
];
ok
{
if
mapPwd
,
ok
:=
confs
[
name
];
ok
{
...
...
main.go
View file @
80a811ce
package
main
package
main
import
(
import
(
"fmt"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12"
"os"
"web_log/code"
"web_log/code"
"web_log/config"
)
)
// example
// example
func
main
()
{
func
main
()
{
Directory
:=
"E:
\\
test_logs"
// directory of the log
addrs
:=
"0.0.0.0:9997"
addrs
:=
"0.0.0.0:9997"
logenv
:=
os
.
Getenv
(
"GOLOGENV"
)
if
logenv
==
"TEST"
{
config
.
InitConfig
()
Directory
=
"/data/soft/bigdatav3.0/test_rsync_log"
fmt
.
Printf
(
"查看日志目录: %s
\n
用户配置文件: %s"
,
config
.
Directory
,
config
.
UserConfigPath
)
}
app
:=
code
.
GetApp
(
config
.
Directory
)
if
logenv
==
"PRODUCT"
{
Directory
=
"/data/soft/rsync_log"
}
app
:=
code
.
GetApp
(
Directory
)
app
.
Run
(
iris
.
Addr
(
addrs
),
iris
.
WithCharset
(
"UTF-8"
))
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