Skip to content

Commit

Permalink
i18n支持
Browse files Browse the repository at this point in the history
  • Loading branch information
fengfei committed Sep 13, 2017
1 parent 34cab56 commit ece971f
Show file tree
Hide file tree
Showing 25 changed files with 486 additions and 150 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
lanproxy
--------

[README EN](README_en.md) | [中文文档](README.md)

lanproxy是一个将局域网个人电脑、服务器代理到公网的内网穿透工具,目前仅支持tcp流量转发,可支持任何tcp上层协议(访问内网网站、本地支付接口调试、ssh访问、远程桌面...)。目前市面上提供类似服务的有花生壳、TeamView、GoToMyCloud等等,但要使用第三方的公网服务器就必须为第三方付费,并且这些服务都有各种各样的限制,此外,由于数据包会流经第三方,因此对数据安全也是一大隐患。

### 相关地址
Expand Down Expand Up @@ -49,9 +51,11 @@ config.admin.password=admin

代理配置,打开地址 http://ip:8090 ,使用上面配置中配置的用户名密码登录,进入如下代理配置界面

![webconfig](webconfig01.jpeg)
![webconfig](readme_zh_client_list.png)

![webconfig](readme_zh_proxy_list.png)

![webconfig](webconfig02.jpeg)
![webconfig](readme_zh_stat_list.png)

> 一个server可以支持多个客户端连接
> 配置数据存放在 ~/.lanproxy/config.json 文件中
Expand Down
84 changes: 84 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
### Lanproxy

[README](README_en.md) | [中文文档](README.md)

Lanproxy is a reverse proxy to help you expose a local server behind a NAT or firewall to the internet. it supports any protocols over tcp (http https ssh ...)

### Features

- Secure tunnels to localhost
- Supports any protocols over tcp (http https ssh ...)
- Supports web config pages, easy to configure management
- Written by java netty framework, high performance

### What can I do with Lanproxy

- Demo without deploying
- Simplify mobile device testing
- Build webhook integrations with ease
- Run personal cloud services from your own private network

### Architecture
![lanproxy](lanproxy.png)

### Configure

#### Server

proxy-server config file is **conf/config.properties**

```properties
server.bind=0.0.0.0

#Plain tcp port
server.port=4900

#ssl
server.ssl.enable=true
server.ssl.bind=0.0.0.0
server.ssl.port=4993
server.ssl.jksPath=test.jks
server.ssl.keyStorePassword=123456
server.ssl.keyManagerPassword=123456
server.ssl.needsClientAuth=false

#web config pages
config.server.bind=0.0.0.0
config.server.port=8090
config.admin.username=admin
config.admin.password=admin

```

> Visit your config web service using url http://ip:8090
![webconfig](readme_en_client_list.png)

![webconfig](readme_en_proxy_list.png)

![webconfig](readme_en_stat_list.png)

#### client

proxy-client config file is **conf/config.properties**

```properties
#get from proxy-server client list page
client.key=
ssl.enable=true
ssl.jksPath=test.jks
ssl.keyStorePassword=123456

#your proxy server ip
server.host=

#proxy-server ssl port is 4993,plain port is 4900
server.port=4993
```

### Run

- Get release package from https://github.com/ffay/lanproxy/releases
- Java env is required
- Linux(mac)run bin/startup.sh
- Windows run bin/startup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,15 @@ public void update(String proxyMappingConfigJson) {
this.inetPortLanInfoMapping = inetPortLanInfoMapping;
this.clients = clients;

try {
FileOutputStream out = new FileOutputStream(file);
out.write(proxyMappingConfigJson.getBytes(Charset.forName("UTF-8")));
out.flush();
out.close();
} catch (Exception e) {
throw new RuntimeException(e);
if (proxyMappingConfigJson != null) {
try {
FileOutputStream out = new FileOutputStream(file);
out.write(proxyMappingConfigJson.getBytes(Charset.forName("UTF-8")));
out.flush();
out.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

notifyconfigChangedListeners();
Expand Down
Empty file.
54 changes: 54 additions & 0 deletions proxy-server/webpages/i18n/lang_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
login=Sign in
logout=Sign out
username=Username
password=Password

title=LanProxy - help you expose a local server behind a NAT or firewall to the internet

menu.client.list=Client list
menu.client.add=New client
menu.client.config=Client config
menu.client.statistics=Statistics

public.confirm.delete=Delete?
public.options=Options
public.edit=Edit
public.submit=Submit
public.delete=Delete
public.ok=Ok
public.cancel=Cancel
public.back=Back
public.notice.updatesuccess=Update successfully
public.notice.addsuccess=Add successfully
public.tips=Tips

client.list=Client list
client.name=Client name
client.key=Client key
client.add=New client
client.name.placeholder=
client.key.placeholder=
client.randomkey=Generate a random key
client.notice.inputname=Client name is required
client.notice.inputkey=Client key is required
client.notice.addsuccess=New client has been added successfully
client.edit=Edit client

lan.proxyconfig=Proxy config
lan.addnewconfig=New proxy config
lan.editconfig=Edit proxy config
lan.name=Proxy name
lan.inetport=Internet port
lan.inetport.placeholder=
lan.ip=Backend ip
lan.ip.placeholder=127.0.0.1:80
lan.notice.inputname=Proxy config name is required
lan.notice.inputinetport=Internet port is required
lan.notice.inputlan=Backend server ip:port is required
lan.notice.errorlan=Error backend info, should be ip:port
lan.notice.errorport=Error port

statistics.inetport=Internet port
statistics.inflow=Inflow data
statistics.outflow=Outflow data
statistics.channels=Current channels
Empty file.
53 changes: 53 additions & 0 deletions proxy-server/webpages/i18n/lang_zh_CN.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
login=登录
logout=退出
username=用户名
password=密码

title=LanProxy-内网穿透工具

menu.client.list=客户端管理
menu.client.add=添加客户端
menu.client.config=配置管理
menu.client.statistics=数据统计

public.confirm.delete=确定删除?
public.options=操作
public.submit=提交
public.edit=编辑
public.delete=删除
public.ok=确定
public.cancel=取消
public.back=返回
public.notice.updatesuccess=更新成功
public.tips=提示

client.list=客户端列表
client.name=客户端名称
client.key=客户端密钥
client.add=添加客户端
client.name.placeholder=请输入客户端名称
client.key.placeholder=请输入客户端密钥
client.randomkey=生成随机密钥
client.notice.inputname=请输入客户端备注名称
client.notice.inputkey=请输入客户端通信密钥
client.notice.addsuccess=客户端添加成功
client.edit=编辑客户端

lan.proxyconfig=代理配置
lan.addnewconfig=添加配置
lan.editconfig=编辑配置
lan.name=代理名称
lan.inetport=公网端口
lan.inetport.placeholder=请输入公网出口端口,请确保端口没有被其他程序占用
lan.ip=后端IP端口
lan.ip.placeholder=请输入后端代理信息,格式:127.0.0.1:80
lan.notice.inputname=请输入代理信息备注名称
lan.notice.inputinetport=请输入公网出口端口
lan.notice.inputlan=请输入后端代理信息
lan.notice.errorlan=后端代理信息格式错误
lan.notice.errorport=端口错误

statistics.inetport=出口端口
statistics.inflow=流入数据
statistics.outflow=流出数据
statistics.channels=当前连接
62 changes: 52 additions & 10 deletions proxy-server/webpages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}

.wrapper {
background: #393D49!important;
background: #393D49 !important;
background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);
opacity: 0.8;
Expand Down Expand Up @@ -150,21 +150,25 @@
<h1>LanProxy.org</h1>

<div class="form">
<input type="text" class="username" placeholder="用户名">
<input type="password" class="password" placeholder="密码">
<button type="submit" id="login-button">登录</button>
<input type="text" class="username" placeholder="">
<input type="password" class="password" placeholder="">
<button type="submit" id="login-button"></button>
</div>
</div>
</div>

<script src="jquery/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="jquery/jquery.i18n.properties.min.js" type="text/javascript"></script>
<script>
$('#login-button').click(function(event) {
$('#login-button').click(function(event) {
$.ajax({
type : "POST",
url : "/login",
contentType : "application/json; charset=utf-8",
data : JSON.stringify({username: $(".username").val(), password:$(".password").val()}),
data : JSON.stringify({
username : $(".username").val(),
password : $(".password").val()
}),
dataType : "json",
success : function(data) {
if (data.code == 20000) {
Expand All @@ -185,10 +189,48 @@ <h1>LanProxy.org</h1>
document.cookie = name + "=" + escape(value) + ";expires="
+ exp.toGMTString();
}

$(document).keyup(function(event){
if(event.keyCode ==13){
$("#login-button").trigger("click");

$(document).keyup(function(event) {
if (event.keyCode == 13) {
$("#login-button").trigger("click");
}
});

/**
* 设置语言类型: 默认为英文
*/
var i18nLanguage = "en";

/*
设置一下网站支持的语言种类
zh-CN(中文简体)、en(英语)
*/
var webLanguage = [ 'zh-CN', 'en' ];

function initWebLanguage() {
var navLanguage = navigator.language;
console.log("user set browser language is " + navLanguage);
if (navLanguage) {
var charSize = $.inArray(navLanguage, webLanguage);
if (charSize > -1) {
i18nLanguage = navLanguage;
}
}
}

initWebLanguage();

jQuery.i18n.properties({
name : 'lang', //资源文件名称
path : '/i18n/', //资源文件路径
mode : 'map', //用Map的方式使用资源文件中的值
language : i18nLanguage,
encoding: 'UTF-8',
callback : function() {//加载成功后设置显示内容
$('title').html($.i18n.prop('login')+" - LanProxy");
$('#login-button').html($.i18n.prop('login'));
$(".username").attr("placeholder", $.i18n.prop('username'));
$(".password").attr("placeholder", $.i18n.prop('password'));
}
});
</script>
Expand Down
9 changes: 9 additions & 0 deletions proxy-server/webpages/jquery/jquery.i18n.properties.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ece971f

Please sign in to comment.