Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b33f7212
提交
b33f7212
authored
6月 30, 2014
作者:
noelgrandin@gmail.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optionally persist session history in the H2 console. (patch from Martin Grajcar)
上级
2462af05
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
70 行增加
和
1 行删除
+70
-1
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+61
-0
WebSession.java
h2/src/main/org/h2/server/web/WebSession.java
+8
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
b33f7212
...
...
@@ -18,6 +18,7 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul><li>
The LIRS cache now re-sizes the internal hash map if needed.
<ul><li>
Optionally persist session history in the H2 console. (patch from Martin Grajcar)
</li></ul>
<h2>
Version 1.4.179 Beta (2014-06-23)
</h2>
...
...
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
b33f7212
...
...
@@ -48,6 +48,8 @@ import org.h2.util.Utils;
*/
public
class
WebServer
implements
Service
{
private
static
final
String
COMMAND_HISTORY
=
"commandHistory"
;
static
final
String
TRANSFER
=
"transfer"
;
static
final
String
[][]
LANGUAGES
=
{
...
...
@@ -157,6 +159,8 @@ public class WebServer implements Service {
private
TranslateThread
translateThread
;
private
boolean
allowChunked
=
true
;
private
String
serverPropertiesDir
=
Constants
.
SERVER_PROPERTIES_DIR
;
/** null means the history is not allowed to be stored */
private
String
commandHistoryString
;
/**
* Read the given file from the file system or from the resources.
...
...
@@ -291,6 +295,7 @@ public class WebServer implements Service {
"webSSL"
,
false
);
allowOthers
=
SortedProperties
.
getBooleanProperty
(
prop
,
"webAllowOthers"
,
false
);
commandHistoryString
=
prop
.
getProperty
(
COMMAND_HISTORY
);
for
(
int
i
=
0
;
args
!=
null
&&
i
<
args
.
length
;
i
++)
{
String
a
=
args
[
i
];
if
(
Tool
.
isOption
(
a
,
"-webPort"
))
{
...
...
@@ -524,6 +529,59 @@ public class WebServer implements Service {
return
port
;
}
public
boolean
isCommandHistoryAllowed
()
{
return
commandHistoryString
!=
null
;
}
public
void
setCommandHistoryAllowed
(
boolean
allowed
)
{
if
(
allowed
)
{
if
(
commandHistoryString
==
null
)
{
commandHistoryString
=
""
;
}
}
else
{
commandHistoryString
=
null
;
}
}
public
ArrayList
<
String
>
getCommandHistoryList
()
{
ArrayList
<
String
>
result
=
New
.
arrayList
();
if
(
commandHistoryString
==
null
)
{
return
result
;
}
// Split the commandHistoryString on non-escaped semicolons and unescape it.
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
end
=
0
;
;
end
++)
{
if
(
end
==
commandHistoryString
.
length
()
||
commandHistoryString
.
charAt
(
end
)
==
';'
)
{
if
(
sb
.
length
()
>
0
)
{
result
.
add
(
sb
.
toString
());
sb
.
delete
(
0
,
sb
.
length
());
}
if
(
end
==
commandHistoryString
.
length
())
{
break
;
}
}
else
if
(
commandHistoryString
.
charAt
(
end
)
==
'\\'
&&
end
<
commandHistoryString
.
length
()
-
1
)
{
sb
.
append
(
commandHistoryString
.
charAt
(++
end
));
}
else
{
sb
.
append
(
commandHistoryString
.
charAt
(
end
));
}
}
return
result
;
}
public
void
saveCommandHistoryList
(
ArrayList
<
String
>
commandHistory
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
s
:
commandHistory
)
{
if
(
sb
.
length
()
>
0
)
{
sb
.
append
(
';'
);
}
sb
.
append
(
s
.
replace
(
"\\"
,
"\\\\"
).
replace
(
";"
,
"\\;"
));
}
commandHistoryString
=
sb
.
toString
();
saveProperties
(
null
);
}
/**
* Get the connection information for this setting.
*
...
...
@@ -632,6 +690,9 @@ public class WebServer implements Service {
prop
.
setProperty
(
"webSSL"
,
""
+
SortedProperties
.
getBooleanProperty
(
old
,
"webSSL"
,
ssl
));
if
(
commandHistoryString
!=
null
)
{
prop
.
setProperty
(
COMMAND_HISTORY
,
commandHistoryString
);
}
}
ArrayList
<
ConnectionInfo
>
settings
=
getSettings
();
int
len
=
settings
.
size
();
...
...
h2/src/main/org/h2/server/web/WebSession.java
浏览文件 @
b33f7212
...
...
@@ -56,7 +56,7 @@ class WebSession {
private
final
WebServer
server
;
private
final
ArrayList
<
String
>
commandHistory
=
New
.
arrayList
()
;
private
final
ArrayList
<
String
>
commandHistory
;
private
Connection
conn
;
private
DatabaseMetaData
meta
;
...
...
@@ -66,6 +66,10 @@ class WebSession {
WebSession
(
WebServer
server
)
{
this
.
server
=
server
;
/* This must be stored in the session rather than in the server.
* Otherwise, one client could allow saving history for others (insecure).
*/
this
.
commandHistory
=
server
.
getCommandHistoryList
();
}
/**
...
...
@@ -172,6 +176,9 @@ class WebSession {
commandHistory
.
remove
(
idx
);
}
commandHistory
.
add
(
sql
);
if
(
server
.
isCommandHistoryAllowed
())
{
server
.
saveCommandHistoryList
(
commandHistory
);
}
}
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论