Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
9ff2bac8
o2oa
项目概览
fuyue82
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9ff2bac8
编写于
9月 04, 2020
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
part1
上级
9497c4a6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
99 addition
and
7 deletion
+99
-7
o2server/pom.xml
o2server/pom.xml
+9
-0
o2server/x_console/src/main/java/com/x/server/console/server/web/Proxy.java
.../src/main/java/com/x/server/console/server/web/Proxy.java
+52
-0
o2server/x_console/src/main/java/com/x/server/console/server/web/WebServerTools.java
.../java/com/x/server/console/server/web/WebServerTools.java
+38
-7
未找到文件。
o2server/pom.xml
浏览文件 @
9ff2bac8
...
...
@@ -144,6 +144,10 @@
<groupId>
org.eclipse.jetty
</groupId>
<artifactId>
jetty-quickstart
</artifactId>
</dependency>
<dependency>
<groupId>
org.eclipse.jetty
</groupId>
<artifactId>
jetty-proxy
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
core
</artifactId>
...
...
@@ -545,6 +549,11 @@
<artifactId>
jetty-quickstart
</artifactId>
<version>
9.4.20.v20190813
</version>
</dependency>
<dependency>
<groupId>
org.eclipse.jetty
</groupId>
<artifactId>
jetty-proxy
</artifactId>
<version>
9.4.31.v20200723
</version>
</dependency>
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
core
</artifactId>
...
...
o2server/x_console/src/main/java/com/x/server/console/server/web/Proxy.java
0 → 100644
浏览文件 @
9ff2bac8
package
com.x.server.console.server.web
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.eclipse.jetty.proxy.ProxyServlet
;
public
class
Proxy
extends
ProxyServlet
{
private
static
final
long
serialVersionUID
=
2737360000716631564L
;
@Override
protected
String
rewriteTarget
(
HttpServletRequest
request
)
{
String
url
=
request
.
getRequestURL
().
toString
();
return
target
(
url
,
this
.
getServletConfig
().
getInitParameter
(
"port"
));
}
private
String
target
(
String
url
,
String
port
)
{
int
x
=
StringUtils
.
indexOf
(
url
,
":"
,
8
);
int
y
=
StringUtils
.
indexOf
(
url
,
"/"
,
8
);
if
((
x
>
0
)
&&
(
y
>
0
))
{
return
url
.
substring
(
0
,
x
)
+
port
(
url
,
port
)
+
url
.
substring
(
y
);
}
else
if
(
y
>
0
)
{
return
url
.
substring
(
0
,
y
)
+
port
(
url
,
port
)
+
url
.
substring
(
y
);
}
else
{
return
null
;
}
}
private
String
port
(
String
url
,
String
port
)
{
if
(
StringUtils
.
startsWithIgnoreCase
(
url
,
"https://"
))
{
if
(
StringUtils
.
equals
(
port
,
"443"
))
{
return
""
;
}
}
else
if
(
StringUtils
.
startsWithIgnoreCase
(
url
,
"http://"
))
{
if
(
StringUtils
.
equals
(
port
,
"80"
))
{
return
""
;
}
}
return
":"
+
port
;
}
// @Test
// public void test1() {
// System.out.println(target("http://www.o2oa.net:20030/111/22?1=1", "80"));
// System.out.println(target("http://www.o2oa.net:20030/111/22?1=1", "81"));
// System.out.println(target("https://www.o2oa.net:20030/111/22?1=1", "80"));
// System.out.println(target("https://www.o2oa.net:20030/111/22?1=1", "443"));
// System.out.println(target("https://www.o2oa.net:20030/111/22?1=1", "4430"));
// }
}
o2server/x_console/src/main/java/com/x/server/console/server/web/WebServerTools.java
浏览文件 @
9ff2bac8
...
...
@@ -104,6 +104,16 @@ public class WebServerTools extends JettySeverTools {
}
/* stat end */
server
.
setHandler
(
context
);
if
(
BooleanUtils
.
isTrue
(
webServer
.
getProxyCenterEnable
()))
{
proxyCenter
(
context
);
}
if
(
BooleanUtils
.
isTrue
(
webServer
.
getProxyApplicationEnable
()))
{
proxyApplication
(
context
,
Config
.
dir_store
().
toPath
());
proxyApplication
(
context
,
Config
.
dir_custom
().
toPath
());
}
server
.
setDumpAfterStart
(
false
);
server
.
setDumpBeforeStop
(
false
);
server
.
setStopAtShutdown
(
true
);
...
...
@@ -117,6 +127,27 @@ public class WebServerTools extends JettySeverTools {
return
server
;
}
private
static
void
proxyCenter
(
WebAppContext
context
)
throws
Exception
{
ServletHolder
proxyHolder
=
new
ServletHolder
(
Proxy
.
class
);
proxyHolder
.
setInitParameter
(
"port"
,
Config
.
currentNode
().
getCenter
().
getPort
()
+
""
);
context
.
addServlet
(
proxyHolder
,
"/"
+
x_program_center
.
class
.
getSimpleName
()
+
"/*"
);
}
private
static
void
proxyApplication
(
WebAppContext
context
,
Path
path
)
throws
Exception
{
try
(
Stream
<
Path
>
stream
=
Files
.
list
(
path
))
{
stream
.
filter
(
o
->
StringUtils
.
endsWithIgnoreCase
(
o
.
getFileName
().
toString
(),
".war"
))
.
map
(
Path:
:
getFileName
).
map
(
Path:
:
toString
).
map
(
FilenameUtils:
:
getBaseName
).
forEach
(
o
->
{
try
{
ServletHolder
proxyHolder
=
new
ServletHolder
(
Proxy
.
class
);
proxyHolder
.
setInitParameter
(
"port"
,
Config
.
currentNode
().
getApplication
().
getPort
()
+
""
);
context
.
addServlet
(
proxyHolder
,
"/"
+
x_program_center
.
class
.
getSimpleName
()
+
"/*"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
});
}
}
private
static
void
copyDefaultHtml
()
throws
Exception
{
File
file
=
new
File
(
Config
.
dir_config
(),
"default.html"
);
if
(
file
.
exists
()
&&
file
.
isFile
())
{
...
...
@@ -205,16 +236,16 @@ public class WebServerTools extends JettySeverTools {
/* 密码规则 */
map
.
put
(
"passwordRegex"
,
Config
.
person
().
getPasswordRegex
());
map
.
put
(
"passwordRegexHint"
,
Config
.
person
().
getPasswordRegexHint
());
/*RSA
*/
/* RSA
*/
File
publicKeyFile
=
new
File
(
Config
.
base
(),
"config/public.key"
);
if
(
publicKeyFile
.
exists
()
&&
publicKeyFile
.
isFile
())
{
String
publicKey
=
FileUtils
.
readFileToString
(
publicKeyFile
,
"utf-8"
);
byte
[]
publicKeyB
=
Base64
.
decodeBase64
(
publicKey
);
publicKey
=
new
String
(
Base64
.
encodeBase64
(
publicKeyB
));
map
.
put
(
"publicKey"
,
publicKey
);
String
publicKey
=
FileUtils
.
readFileToString
(
publicKeyFile
,
"utf-8"
);
byte
[]
publicKeyB
=
Base64
.
decodeBase64
(
publicKey
);
publicKey
=
new
String
(
Base64
.
encodeBase64
(
publicKeyB
));
map
.
put
(
"publicKey"
,
publicKey
);
}
FileUtils
.
writeStringToFile
(
file
,
gson
.
toJson
(
map
),
DefaultCharset
.
charset
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录