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
f87c8290
authored
Dec 25, 2020
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
version v1.0.2
- 加入用户验证 - 优化前端
parent
67ac824a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
161 additions
and
12 deletions
code/application.go
code/login.go
code/webloghandler.go
main.go
web/views/index.html
web/views/innnerip.html
web/views/login.html
web/views/page.html
web/views/server_direc.html
code/application.go
View file @
f87c8290
...
...
@@ -10,17 +10,51 @@ import (
"time"
)
func
GetApp
(
directory
string
,
port
int
)
*
iris
.
Application
{
type
User
struct
{
Username
string
Password
string
}
func
GetApp
(
directory
string
)
*
iris
.
Application
{
app
:=
iris
.
New
()
w
:=
&
WebHandler
{
"E:
\\
test_logs"
}
app
.
Get
(
"/index"
,
w
.
Indexhandle2
)
w
:=
&
WebHandler
{
directory
}
app
.
Get
(
"/"
,
func
(
ctx
iris
.
Context
)
{
w
.
loginhandle
(
ctx
,
nil
)
})
app
.
Post
(
"/login"
,
func
(
ctx
iris
.
Context
)
{
var
user
User
ctx
.
ReadForm
(
&
user
)
//user.Username = "zzl"
//user.Password = "Lx@520m!@@#"
if
ok2
,
msg
:=
VerifyUser
(
user
.
Username
,
user
.
Password
);
ok2
{
ctx
.
SetCookieKV
(
"sessionid"
,
msg
)
ctx
.
Redirect
(
"/index"
,
301
)
}
else
{
fmt
.
Println
(
"验证不通过"
)
w
.
loginhandle
(
ctx
,
msg
)
}
})
app
.
Use
(
func
(
ctx
iris
.
Context
)
{
sessionid
:=
ctx
.
GetCookie
(
"sessionid"
)
ok1
,
msg
:=
VerifySessionID
(
sessionid
)
fmt
.
Println
(
msg
)
if
ok1
{
ctx
.
Next
()
}
else
{
w
.
loginhandle
(
ctx
,
"未登录"
)
}
})
app
.
Get
(
"/index"
,
w
.
Indexhandle2
)
app
.
Get
(
"/ws"
,
genCtxHand
(
directory
,
manager
.
filemap
))
go
manager
.
start
()
return
app
}
func
genCtxHand
(
directory
string
,
file_map
map
[
string
]
map
[
Client
]
bool
)
func
(
ctx
iris
.
Context
)
{
f
:=
func
(
ctx
iris
.
Context
)
{
w
:=
ctx
.
ResponseWriter
()
...
...
code/login.go
View file @
f87c8290
...
...
@@ -11,11 +11,7 @@ var userMap = make(map[string]string)
var
sessionIdMap
=
make
(
map
[
string
]
string
)
func
init
()
{
userMap
[
"zzl"
]
=
"THhANTIwbSFAQCM="
userMap
[
"lcg"
]
=
"THhANTIwbSFAQCM="
userMap
[
"zgj"
]
=
"THhANTIwbSFAQCM="
userMap
[
"ljm"
]
=
"THhANTIwbSFAQCM="
userMap
[
"opt"
]
=
"THhANTIwbSFAQCM="
userMap
[
"weblog"
]
=
"MTIzNDU2"
sessionIdMap
[
"S1oI0nPch9PzJ0ClGEODdzbqcq85JK7YwnLesuTWayU="
]
=
""
}
...
...
code/webloghandler.go
View file @
f87c8290
...
...
@@ -64,6 +64,9 @@ func (wbh *WebHandler) indexhandle(w http.ResponseWriter, r *http.Request) {
}
func
(
wbh
*
WebHandler
)
loginhandle
(
ctx
iris
.
Context
,
data
interface
{})
{
return_res
(
ctx
.
ResponseWriter
(),
"web/views/login.html"
,
data
)
}
func
(
wbh
*
WebHandler
)
Indexhandle2
(
ctx
iris
.
Context
)
{
innerip
:=
ctx
.
URLParam
(
"innerip"
)
server_direc
:=
ctx
.
URLParam
(
"server_direc"
)
...
...
main.go
View file @
f87c8290
...
...
@@ -9,7 +9,7 @@ import (
// example
func
main
()
{
Directory
:=
"E:
\\
test_logs"
// directory of the log
TestPort
:=
9997
addrs
:=
"0.0.0.0:9997"
logenv
:=
os
.
Getenv
(
"GOLOGENV"
)
if
logenv
==
"TEST"
{
Directory
=
"/data/soft/bigdatav3.0/test_rsync_log"
...
...
@@ -17,7 +17,7 @@ func main() {
if
logenv
==
"PRODUCT"
{
Directory
=
"/data/soft/rsync_log"
}
app
:=
code
.
GetApp
(
Directory
,
TestPort
)
app
.
Run
(
iris
.
Addr
(
"0.0.0.0:9997"
),
iris
.
WithCharset
(
"UTF-8"
))
app
:=
code
.
GetApp
(
Directory
)
app
.
Run
(
iris
.
Addr
(
addrs
),
iris
.
WithCharset
(
"UTF-8"
))
}
web/views/index.html
View file @
f87c8290
...
...
@@ -20,6 +20,18 @@
</script>
<style>
html
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
}
body
{
width
:
100%
;
height
:
100%
;
font-family
:
'Open Sans'
,
sans-serif
;
margin
:
0
;
background-color
:
#cccccc
;
}
a
:active
,
a
:visited
,
a
:link
{
...
...
web/views/innnerip.html
View file @
f87c8290
...
...
@@ -19,6 +19,18 @@
</script>
<style>
html
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
}
body
{
width
:
100%
;
height
:
100%
;
font-family
:
'Open Sans'
,
sans-serif
;
margin
:
0
;
background-color
:
#cccccc
;
}
a
:active
,
a
:visited
,
a
:link
{
...
...
web/views/login.html
0 → 100644
View file @
f87c8290
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Login
</title>
</head>
<body>
<style>
html
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
}
body
{
width
:
100%
;
height
:
100%
;
font-family
:
'Open Sans'
,
sans-serif
;
margin
:
0
;
background-color
:
#181818
;
}
#login
{
position
:
absolute
;
top
:
50%
;
left
:
50%
;
margin
:
-150px
0
0
-150px
;
width
:
300px
;
height
:
300px
;
}
#login
h1
{
color
:
#fff
;
text-shadow
:
0
0
10px
;
letter-spacing
:
1px
;
text-align
:
center
;
}
h1
{
font-size
:
2em
;
margin
:
0.67em
0
;
}
input
{
width
:
278px
;
height
:
18px
;
margin-bottom
:
10px
;
outline
:
none
;
padding
:
10px
;
font-size
:
13px
;
color
:
#fff
;
text-shadow
:
1px
1px
1px
;
border-top
:
1px
solid
#312E3D
;
border-left
:
1px
solid
#312E3D
;
border-right
:
1px
solid
#312E3D
;
border-bottom
:
1px
solid
#56536A
;
border-radius
:
4px
;
background-color
:
#2D2D3F
;
}
.but
{
width
:
300px
;
min-height
:
20px
;
display
:
block
;
background-color
:
#4a77d4
;
border
:
1px
solid
#3762bc
;
color
:
#fff
;
padding
:
9px
14px
;
font-size
:
15px
;
line-height
:
normal
;
border-radius
:
5px
;
margin
:
0
;
}
</style>
<div
id=
"login"
>
<h1>
Login
</h1>
<form
method=
"post"
,
action=
"login"
>
<input
type=
"text"
required=
"required"
placeholder=
"用户名"
name=
"username"
>
<input
type=
"password"
required=
"required"
placeholder=
"密码"
name=
"password"
>
<h5
style=
"color: red"
>
{{ . }}
</h5>
<button
class=
"but"
type=
"submit"
>
登录
</button>
</form>
</div>
</body>
</html>
\ No newline at end of file
web/views/page.html
View file @
f87c8290
...
...
@@ -53,7 +53,7 @@
function
reConnect
()
{
setTimeout
(
function
()
{
connect
();
},
1000
);
},
1000
0
);
}
connect
()
...
...
web/views/server_direc.html
View file @
f87c8290
...
...
@@ -19,6 +19,18 @@
</script>
<style>
html
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
}
body
{
width
:
100%
;
height
:
100%
;
font-family
:
'Open Sans'
,
sans-serif
;
margin
:
0
;
background-color
:
#cccccc
;
}
a
:active
,
a
:visited
,
a
:link
{
...
...
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