Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
flyseaskying
lanproxy
提交
e4ec1106
L
lanproxy
项目概览
flyseaskying
/
lanproxy
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
lanproxy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e4ec1106
编写于
10月 11, 2019
作者:
F
fei.feng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改配置文件存储目录
上级
de17318d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
67 addition
and
37 deletion
+67
-37
proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java
.../java/org/fengfei/lanproxy/server/config/ProxyConfig.java
+67
-37
未找到文件。
proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java
浏览文件 @
e4ec1106
...
@@ -25,60 +25,72 @@ import com.google.gson.reflect.TypeToken;
...
@@ -25,60 +25,72 @@ import com.google.gson.reflect.TypeToken;
* server config
* server config
*
*
* @author fengfei
* @author fengfei
*
*/
*/
public
class
ProxyConfig
implements
Serializable
{
public
class
ProxyConfig
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** 配置文件为config.json */
/**
public
static
final
String
CONFIG_FILE
;
* 配置文件为config.json
*/
public
static
String
configFile
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ProxyConfig
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ProxyConfig
.
class
);
static
{
/**
* 代理服务器绑定主机host
// 代理配置信息存放在用户根目录下
*/
String
dataPath
=
System
.
getProperty
(
"user.home"
)
+
"/"
+
".lanproxy/"
;
File
file
=
new
File
(
dataPath
);
if
(!
file
.
isDirectory
())
{
file
.
mkdir
();
}
CONFIG_FILE
=
dataPath
+
"/config.json"
;
}
/** 代理服务器绑定主机host */
private
String
serverBind
;
private
String
serverBind
;
/** 代理服务器与代理客户端通信端口 */
/**
* 代理服务器与代理客户端通信端口
*/
private
Integer
serverPort
;
private
Integer
serverPort
;
/** 配置服务绑定主机host */
/**
* 配置服务绑定主机host
*/
private
String
configServerBind
;
private
String
configServerBind
;
/** 配置服务端口 */
/**
* 配置服务端口
*/
private
Integer
configServerPort
;
private
Integer
configServerPort
;
/** 配置服务管理员用户名 */
/**
* 配置服务管理员用户名
*/
private
String
configAdminUsername
;
private
String
configAdminUsername
;
/** 配置服务管理员密码 */
/**
* 配置服务管理员密码
*/
private
String
configAdminPassword
;
private
String
configAdminPassword
;
/** 代理客户端,支持多个客户端 */
/**
* 代理客户端,支持多个客户端
*/
private
List
<
Client
>
clients
;
private
List
<
Client
>
clients
;
/** 更新配置后保证在其他线程即时生效 */
/**
private
static
ProxyConfig
instance
=
new
ProxyConfig
();;
* 更新配置后保证在其他线程即时生效
*/
private
static
ProxyConfig
instance
=
new
ProxyConfig
();
;
/** 代理服务器为各个代理客户端(key)开启对应的端口列表(value) */
/**
* 代理服务器为各个代理客户端(key)开启对应的端口列表(value)
*/
private
volatile
Map
<
String
,
List
<
Integer
>>
clientInetPortMapping
=
new
HashMap
<
String
,
List
<
Integer
>>();
private
volatile
Map
<
String
,
List
<
Integer
>>
clientInetPortMapping
=
new
HashMap
<
String
,
List
<
Integer
>>();
/** 代理服务器上的每个对外端口(key)对应的代理客户端背后的真实服务器信息(value) */
/**
* 代理服务器上的每个对外端口(key)对应的代理客户端背后的真实服务器信息(value)
*/
private
volatile
Map
<
Integer
,
String
>
inetPortLanInfoMapping
=
new
HashMap
<
Integer
,
String
>();
private
volatile
Map
<
Integer
,
String
>
inetPortLanInfoMapping
=
new
HashMap
<
Integer
,
String
>();
/** 配置变化监听器 */
/**
* 配置变化监听器
*/
private
List
<
ConfigChangedListener
>
configChangedListeners
=
new
ArrayList
<
ConfigChangedListener
>();
private
List
<
ConfigChangedListener
>
configChangedListeners
=
new
ArrayList
<
ConfigChangedListener
>();
private
ProxyConfig
()
{
private
ProxyConfig
()
{
...
@@ -87,6 +99,15 @@ public class ProxyConfig implements Serializable {
...
@@ -87,6 +99,15 @@ public class ProxyConfig implements Serializable {
this
.
serverPort
=
Config
.
getInstance
().
getIntValue
(
"server.port"
);
this
.
serverPort
=
Config
.
getInstance
().
getIntValue
(
"server.port"
);
this
.
serverBind
=
Config
.
getInstance
().
getStringValue
(
"server.bind"
,
"0.0.0.0"
);
this
.
serverBind
=
Config
.
getInstance
().
getStringValue
(
"server.bind"
,
"0.0.0.0"
);
// 代理配置信息存放在用户根目录下
String
dataPath
=
System
.
getProperty
(
"user.home"
)
+
"/"
+
".lanproxy/"
+
serverPort
+
"/"
;
File
file
=
new
File
(
dataPath
);
if
(!
file
.
isDirectory
())
{
file
.
mkdir
();
}
configFile
=
dataPath
+
"/config.json"
;
// 配置服务器主机和端口配置初始化
// 配置服务器主机和端口配置初始化
this
.
configServerPort
=
Config
.
getInstance
().
getIntValue
(
"config.server.port"
);
this
.
configServerPort
=
Config
.
getInstance
().
getIntValue
(
"config.server.port"
);
this
.
configServerBind
=
Config
.
getInstance
().
getStringValue
(
"config.server.bind"
,
"0.0.0.0"
);
this
.
configServerBind
=
Config
.
getInstance
().
getStringValue
(
"config.server.bind"
,
"0.0.0.0"
);
...
@@ -159,7 +180,7 @@ public class ProxyConfig implements Serializable {
...
@@ -159,7 +180,7 @@ public class ProxyConfig implements Serializable {
*/
*/
public
void
update
(
String
proxyMappingConfigJson
)
{
public
void
update
(
String
proxyMappingConfigJson
)
{
File
file
=
new
File
(
CONFIG_FILE
);
File
file
=
new
File
(
configFile
);
try
{
try
{
if
(
proxyMappingConfigJson
==
null
&&
file
.
exists
())
{
if
(
proxyMappingConfigJson
==
null
&&
file
.
exists
())
{
InputStream
in
=
new
FileInputStream
(
file
);
InputStream
in
=
new
FileInputStream
(
file
);
...
@@ -305,19 +326,24 @@ public class ProxyConfig implements Serializable {
...
@@ -305,19 +326,24 @@ public class ProxyConfig implements Serializable {
* 代理客户端
* 代理客户端
*
*
* @author fengfei
* @author fengfei
*
*/
*/
public
static
class
Client
implements
Serializable
{
public
static
class
Client
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** 客户端备注名称 */
/**
* 客户端备注名称
*/
private
String
name
;
private
String
name
;
/** 代理客户端唯一标识key */
/**
* 代理客户端唯一标识key
*/
private
String
clientKey
;
private
String
clientKey
;
/** 代理客户端与其后面的真实服务器映射关系 */
/**
* 代理客户端与其后面的真实服务器映射关系
*/
private
List
<
ClientProxyMapping
>
proxyMappings
;
private
List
<
ClientProxyMapping
>
proxyMappings
;
private
int
status
;
private
int
status
;
...
@@ -360,17 +386,22 @@ public class ProxyConfig implements Serializable {
...
@@ -360,17 +386,22 @@ public class ProxyConfig implements Serializable {
* 代理客户端与其后面真实服务器映射关系
* 代理客户端与其后面真实服务器映射关系
*
*
* @author fengfei
* @author fengfei
*
*/
*/
public
static
class
ClientProxyMapping
{
public
static
class
ClientProxyMapping
{
/** 代理服务器端口 */
/**
* 代理服务器端口
*/
private
Integer
inetPort
;
private
Integer
inetPort
;
/** 需要代理的网络信息(代理客户端能够访问),格式 192.168.1.99:80 (必须带端口) */
/**
* 需要代理的网络信息(代理客户端能够访问),格式 192.168.1.99:80 (必须带端口)
*/
private
String
lan
;
private
String
lan
;
/** 备注名称 */
/**
* 备注名称
*/
private
String
name
;
private
String
name
;
public
Integer
getInetPort
()
{
public
Integer
getInetPort
()
{
...
@@ -403,7 +434,6 @@ public class ProxyConfig implements Serializable {
...
@@ -403,7 +434,6 @@ public class ProxyConfig implements Serializable {
* 配置更新回调
* 配置更新回调
*
*
* @author fengfei
* @author fengfei
*
*/
*/
public
static
interface
ConfigChangedListener
{
public
static
interface
ConfigChangedListener
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录