-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hhd
committed
Nov 24, 2021
0 parents
commit 954dfba
Showing
47 changed files
with
3,625 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
__debug_bin | ||
__debug_bin.exe | ||
# .vscode | ||
openp2p | ||
openp2p.exe* | ||
*.log | ||
go.sum | ||
*.tar.gz | ||
*.zip | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 OpenP2P.cn | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
[English](/README.md)|中文 | ||
## OpenP2P是什么 | ||
它是一个开源、免费、轻量级的P2P共享网络。任何设备接入OpenP2P,就可以随时随地访问它们。 | ||
|
||
## 为什么选择OpenP2P | ||
### 免费 | ||
完全免费,满足大部分用户的核心白票需求。不像其它类似的产品,我们不需要有公网IP的服务器,不需要花钱买服务。 | ||
### 安全 | ||
代码开源,接受各位大佬检验。下面详细展开 | ||
### 轻量 | ||
文件大小2MB+,运行内存2MB+;全部在应用层实现,没有虚拟网卡,没有内核程序 | ||
### 跨平台 | ||
因为轻量,所以很容易支持各个平台。支持主流的操作系统:Windows,Linux,MacOS;和主流的cpu架构:386、amd64、arm、arm64、mipsle、mipsle64、mips、mips64 | ||
### 高效 | ||
P2P直连可以让你的设备跑满带宽。不论你的设备在任何网络环境,无论NAT1-4(Cone或Symmetric),都支持。依靠Quic协议优秀的拥塞算法,能在糟糕的网络环境获得高带宽低延时。 | ||
|
||
### 二次开发 | ||
基于OpenP2P只需数行代码,就能让原来只能局域网通信的程序,变成任何内网都能通信 | ||
|
||
## 快速入门 | ||
以一个最常见的例子说明OpenP2P如何使用:远程办公,在家里连入办公室Windows电脑。 | ||
相信很多人在疫情下远程办公是刚需。 | ||
1. 先确认办公室电脑已开启远程桌面功能(如何开启参考官方说明https://docs.microsoft.com/zh-cn/windows-server/remote/remote-desktop-services/clients/remote-desktop-allow-access) | ||
2. 在办公室下载最新的OpenP2P(补上URL),解压出来,在命令行执行 | ||
``` | ||
openp2p.exe -d -node OFFICEPC1 -user USERNAME1 -password PASSWORD1 | ||
``` | ||
|
||
`切记将标记大写的参数改成自己的` | ||
|
||
![image](/doc/images/officelisten.png) | ||
3. 在家里下载最新的OpenP2P(补上URL),解压出来,在命令行执行 | ||
``` | ||
openp2p.exe -d -node HOMEPC123 -user USERNAME1 -password PASSWORD1 --peernode OFFICEPC1 --dstip 127.0.0.1 --dstport 3389 --srcport 23389 --protocol tcp | ||
``` | ||
`切记将标记大写的参数改成自己的` | ||
![image](/doc/images/homeconnect.png) | ||
![image](/doc/images/mem.png) | ||
`LISTEN ON PORT 23389 START` 看到这行日志表示P2PApp建立成功,监听23389端口。只需连接本机的127.0.0.1:23389就相当于连接公司Windows电脑的3389端口。 | ||
|
||
4. 在家里Windows电脑,按Win+R输入mstsc打开远程桌面,输入127.0.0.1:23389 /admin | ||
![image](/doc/images/mstscconnect.png) | ||
|
||
![image](/doc/images/afterconnect.png) | ||
|
||
## [详细使用说明](/USAGE-ZH.md) | ||
## 典型应用场景 | ||
特别适合大流量的内网访问 | ||
### 远程办公 | ||
Windows MSTSC、VNC等远程桌面,SSH,内网各种ERP系统 | ||
### 远程访问NAS | ||
管理大量视频、图片 | ||
### 远程监控摄像头 | ||
### 远程刷机 | ||
### 远程数据备份 | ||
--- | ||
## 概要设计 | ||
### 原型 | ||
![image](/doc/images/prototype.png) | ||
### 客户端架构 | ||
![image](/doc/images/architecture.png) | ||
### P2PApp | ||
它是项目里最重要的概念,一个P2PApp就是把远程的一个服务(mstsc/ssh等)通过P2P网络映射到本地监听。二次开发或者我们提供的Restful API,主要工作就是管理P2PApp | ||
![image](/doc/images/appdetail.png) | ||
## 共享 | ||
默认会开启共享限速10mbps,只有你用户下提供了共享节点才能使用别人的共享节点。这非常公平,也是这个项目的初衷。 | ||
我们建议你在带宽足够的地方(比如办公室,家里的百兆光纤)加入共享网络。 | ||
如果你仍然不想共享任何节点,请查看运行参数 | ||
## 安全性 | ||
加入OpenP2P共享网络的节点,只能凭授权访问。共享节点只会中转数据,别人无法访问内网任何资源。 | ||
### TLS1.3+AES | ||
两个节点间通信数据走业界最安全的TLS1.3通道。通信内容还会使用AES加密,双重安全,密钥是通过服务端作换。有效阻止中间人攻击 | ||
### 共享的中转节点是否会获得我的数据 | ||
没错,中转节点天然就是一个中间人,所以才加上AES加密通信内容保证安全。中转节点是无法获取明文的 | ||
|
||
### 中转节点是如何校验权限的 | ||
服务端有个调度模型,根据带宽、ping值、稳定性、服务时长,尽可能地使共享节点均匀地提供服务。连接共享节点使用TOTP密码,hmac-sha256算法校验,它是一次性密码,和我们平时使用的手机验证码或银行密码器一样的原理。 | ||
|
||
## 编译 | ||
cd到代码根目录,执行 | ||
``` | ||
export GOPROXY=https://goproxy.io,direct | ||
go mod tidy | ||
go build | ||
``` | ||
|
||
## TODO | ||
近期计划: | ||
1. 支持IPv6 | ||
2. 支持随系统自动启动,安装成系统服务 | ||
3. 提供一些免费服务器给特别差的网络,如广电网络 | ||
4. 建立网站,用户可以在网站管理所有P2PApp和设备。查看设备在线状态,升级,增删查改重启P2PApp等 | ||
5. 建立公众号,用户可在微信公众号管理所有P2PApp和设备 | ||
6. 客户端提供WebUI | ||
7. 支持自有服务器高并发连接 | ||
8. 共享节点调度模型优化,对不同的运营商优化 | ||
9. 方便二次开发,提供API和lib | ||
10. 应用层支持UDP协议,实现很简单,但UDP应用较少暂不急 | ||
11. 底层通信支持KCP协议,目前仅支持Quic;KCP专门对延时优化,被游戏加速器广泛使用,可以牺牲一定的带宽降低延时 | ||
12. 支持Android系统,让旧手机焕发青春变成移动网关 | ||
13. 支持Windows网上邻居共享文件 | ||
14. 内网直连优化,用处不大,估计就用户测试时用到 | ||
|
||
远期计划: | ||
1. 彻底地分布式去中心化设计 | ||
2. 企业级支持,可以更好地管理大量设备,和更安全更细的权限控制 | ||
|
||
## 参与贡献 | ||
TODO或ISSUE里如果有你擅长的领域,或者你有特别好的主意,可以加入OpenP2P项目,贡献你的代码。待项目茁壮成长后,你们就是知名开源项目的主要代码贡献者,岂不快哉。 | ||
## 商业合作 | ||
它是一个中国人发起的项目,更懂国内网络环境,更懂用户需求,更好的企业级支持 | ||
## 技术交流 | ||
QQ群:16947733 | ||
邮箱:[email protected] [email protected] | ||
第一时间获得最新版本消息,以及一些最新IT业界动态 | ||
微信公众号:openp2p | ||
微博:https://weibo.com/openp2p | ||
## 免责声明 | ||
本项目开源供大家学习和免费使用,禁止用于非法用途,任何不当使用本项目或意外造成的损失,本项目及相关人员不会承担任何责任。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
English|[中文](/README-ZH.md) | ||
## What is OpenP2P | ||
It is an open source, free, and lightweight P2P sharing network. As long as any device joins in, you can access them anywhere | ||
## Why OpenP2P | ||
### Free | ||
Totaly free, fullfills most of users(especially free-rider). Unlike other similar products, we don't need a server with public IP, and don't need to pay for services. | ||
|
||
### Safe | ||
Open source, trustable(see details below) | ||
|
||
### Lightweight | ||
2MB+ filesize, 2MB+ memory. It runs at appllication layer, no vitrual NIC, no kernel driver. | ||
|
||
### Cross-platform | ||
Benefit from lightweight, it easily supports most of major OS, like Windows, Linux, MacOS, also most of CPU architecture, like 386、amd64、arm、arm64、mipsle、mipsle64、mips、mips64. | ||
|
||
### Efficient | ||
P2P direct connection lets your devices make good use of bandwidth. Your device can be connected in any network environments, even supports NAT1-4 (Cone or Symmetric). Relying on the excellent congestion algorithm of the Quic protocol, high bandwidth and low latency can be obtained in a bad network environment. | ||
|
||
### Integration | ||
Your applicaiton can call OpenP2P with a few code to make any internal networks communicate with each other. | ||
|
||
## Get Started | ||
A common scenario to introduce OpenP2P: remote work. At home connects to office's Linux PC . | ||
Under the outbreak of covid-19 pandemic, surely remote work becomes a fundamental demand. | ||
|
||
1. Make sure your office device(Linux) has opened the access of ssh. | ||
``` | ||
netstat -nl | grep 22 | ||
``` | ||
Output sample | ||
![image](/doc/images/officelisten_linux.png) | ||
|
||
2. Download the latest version of OpenP2P(TBC),unzip the downloaded package, and execute below command line. | ||
``` | ||
tar xvf openp2p0.95.3.linux-amd64.tar.gz | ||
openp2p -d -node OFFICEPC1 -user USERNAME1 -password PASSWORD1 | ||
``` | ||
`Must change the parameters marked in uppercase to your own` | ||
|
||
Output sample | ||
![image](/doc/images/officeexecute_linux.png) | ||
|
||
3. Download the same package of OpenP2P(TBC) on your home device,unzip and execute below command line. | ||
``` | ||
openp2p.exe -d -node HOMEPC123 -user USERNAME1 -password PASSWORD1 --peernode OFFICEPC1 --dstip 127.0.0.1 --dstport 22 --srcport 22022 --protocol tcp | ||
``` | ||
`Must change the parameters marked in uppercase to your own` | ||
Output sample | ||
![image](/doc/images/homeconnect_windows.png) | ||
The log of `LISTEN ON PORT 22022 START` indicates P2PApp runs successfully on your home device, listing port is 22022. Once connects to local ip:port,127.0.0.1:22022, it means the home device has conneccted to the office device's port, 22. | ||
![image](/doc/images/officelisten_2_linux.png) | ||
|
||
|
||
4. Test the connection between office device and home device.In your home deivce, run SSH to login the office device. | ||
``` | ||
ssh -p22022 [email protected]:22022 | ||
``` | ||
![image](/doc/images/sshconnect.png) | ||
|
||
|
||
## [Usage](/USAGE.md) | ||
|
||
## Scenarios | ||
Especially suitable for large traffic intranet access. | ||
### Remote work | ||
Windows MSTSC, VNC and other remote desktops, SSH, various ERP systems in the intranet | ||
|
||
### Remote Access NAS | ||
Manage a large number of videos and pictures | ||
### Remote Access Camera | ||
### Remote Flashing Phone | ||
### Remotely Data Backup | ||
--- | ||
## Overview Design | ||
### Prototype | ||
![image](/doc/images/prototype.png) | ||
### Client architecture | ||
![image](/doc/images/architecture.png) | ||
### P2PApp | ||
P2PAPP is the most import concept in this project, one P2PApp is able to map the remote service(mstsc/ssh) to the local listening. The main job of re-development or restful API we provide is to manage P2PApp. | ||
|
||
![image](/doc/images/appdetail.png) | ||
## Share | ||
10mbps is its default setting of share speed limit. Only when your users have shared their nodes, they are allowed to use others' shared nodes. This is very fair, and it is also the original intention of this project. | ||
We recommend that you join a shared network in a place with sufficient bandwidth (such as an office or home with 100M optical fiber). | ||
If you are still not willing to contribute any node to the OpenP2P share network, please refer to the operating parameters for your own setting. | ||
## Safety | ||
The nodes which have joined the OpenP2P share network can vist each other by authentications. Shared nodes will only relay data, and others cannot access any resources in the intranet. | ||
|
||
### TLS1.3+AES | ||
The communication data between the two nodes uses the industry's most secure TLS1.3 channel. The communication content will also use AES encryption, double security, the key is exchanged through the server. Effectively prevent man-in-the-middle attacks. | ||
|
||
### Will the shared node capture my data? | ||
That's right, the relay node is naturally an man-in-middle, so AES encryption is added to ensure the security of the communication content. The relay node cannot obtain the plaintext. | ||
### How does the shared relay node verify the authority? | ||
The server side has a scheduling model, which calculate bandwith, ping value,stability and service duration to provide a well-proportioned service to every share node. It uses TOTP(Time-based One-time Password) with hmac-sha256 algorithem, its theory as same as the cellphone validation code or bank cipher coder. | ||
|
||
## Build | ||
cd root directory of the socure code and execute | ||
``` | ||
export GOPROXY=https://goproxy.io,direct | ||
go mod tidy | ||
go build | ||
``` | ||
|
||
## TODO | ||
Short-Term: | ||
1. Support IPv6. | ||
2. Support auto run when system boot, setup system service. | ||
3. Provide free servers to some low-performance network. | ||
4. Build website, users can manage all P2PApp and devices via it. View devices' online status, upgrade, restart or CURD P2PApp . | ||
5. Provide wechat official account, user can manage P2PApp nodes and deivce as same as website. | ||
6. Provide WebUI on client side. | ||
7. Support high concurrency on server side. | ||
8. Optimize our share scheduling model for different network operators. | ||
9. Provide REST APIs and libary for secondary development. | ||
10. Support UDP at application layer, it is easy to implement but not urgent due to only a few applicaitons using UDP protocol. | ||
11. Support KCP protocol underlay, currently support Quic only. KCP focus on delay optimization,which has been widely used as game accelerator,it can sacrifice part of bandwidth to reduce timelag. | ||
12. Support Android platform, let the phones to be mobile gateway . | ||
13. Support SMB Windows neighborhood. | ||
14. Direct connection on intranet, for testing. | ||
|
||
|
||
Long-Term: | ||
1. Decentration and distribution. | ||
2. Enterprise-level product can well manage large scale equipment and ACL. | ||
|
||
|
||
## Contribute | ||
If the items in TODO or ISSUE is your domain, or you have sepical good idea, welcome to join this OpenP2P project and contribute your code. When this project grows stronger, you will be the major outstanding contributors. That's cool. | ||
|
||
## Contact | ||
QQ Group: 16947733 | ||
|
||
Email: [email protected] [email protected] | ||
|
||
Get the latest version news, and some of the latest IT industry trends | ||
|
||
WeChat public account: openp2p | ||
|
||
## Disclaimer | ||
This project is open source for everyone to learn and use for free. It is forbidden to be used for illegal purposes. Any loss caused by improper use of this project or accident, this project and related personnel will not bear any responsibility. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 详细运行参数说明 | ||
|
||
## 监听 | ||
``` | ||
openp2p.exe -d -node OFFICEPC1 -user USERNAME1 -password PASSWORD1 | ||
``` | ||
>* -d daemon模式,推荐使用。发现worker进程意外退出就会自动启动新的worker进程 | ||
>* -node 独一无二的节点名字,唯一标识 | ||
>* -user 独一无二的用户名字,该节点属于这个user | ||
>* -password 密码 | ||
>* -sharebandwidth 作为共享节点时提供带宽,默认10mbps. 如果是光纤大带宽,设置越大效果越好 | ||
>* -loglevel 需要查看更多调试日志,设置0;默认是1 | ||
>* -noshare 不共享,该节点只在私有的P2P网络使用。不加入共享的P2P网络,这样也意味着无法使用别人的共享节点 | ||
## 连接 | ||
``` | ||
openp2p.exe -d -node HOMEPC123 -user USERNAME1 -password PASSWORD1 -peernode OFFICEPC1 -dstip 127.0.0.1 -dstport 3389 -srcport 23389 -protocol tcp | ||
``` | ||
>* -peernode 目标节点名字 | ||
>* -dstip 目标服务地址,默认本机127.0.0.1 | ||
>* -dstport 目标服务端口,常见的如windows远程桌面3389,Linux ssh 22 | ||
>* -protocol 目标服务协议 tcp、udp | ||
>* -peeruser 目标用户,如果是同一个用户下的节点,则无需设置 | ||
>* -peerpassword 目标密码,如果是同一个用户下的节点,则无需设置 | ||
>* -f 配置文件,如果希望配置多个P2PApp参考[config.json](/config.json) | ||
## 升级客户端 | ||
``` | ||
# update local client | ||
openp2p update | ||
# update remote client | ||
curl --insecure 'https://openp2p.cn:27182/api/v1/device/YOUR-NODE-NAME/update?user=&password=' | ||
``` | ||
|
||
Windows系统需要设置防火墙放行本程序,程序会自动设置,如果设置失败会影响连接功能。 | ||
Linux系统(Ubuntu和CentOS7)的防火墙默认配置均不会有影响,如果不行可尝试关闭防火墙 | ||
``` | ||
systemctl stop firewalld.service | ||
systemctl start firewalld.service | ||
firewall-cmd --state | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Parameters details | ||
|
||
## Listen | ||
``` | ||
openp2p.exe -d -node OFFICEPC1 -user USERNAME1 -password PASSWORD1 | ||
``` | ||
>* -d daemon mode is recommand. When the worker process is found to exit unexpectedly, a new worker process will be automatically started | ||
>* -node Unique node name, unique identification | ||
>* -user Unique user name, the node belongs to this user | ||
>* -password Password | ||
>* -sharebandwidth Provides bandwidth when used as a shared node, the default is 10mbps. If it is a large bandwidth of optical fiber, the larger the setting, the better the effect | ||
>* -loglevel Need to view more debug logs, set 0; the default is 1 | ||
>* -noshare Not shared, the node is only used in a private P2P network. Do not join the shared P2P network, which also means that you CAN NOT use other people’s shared nodes | ||
## Connect | ||
``` | ||
openp2p.exe -d -node HOMEPC123 -user USERNAME1 -password PASSWORD1 -peernode OFFICEPC1 -dstip 127.0.0.1 -dstport 3389 -srcport 23389 -protocol tcp | ||
``` | ||
>* -peernode Target node name | ||
>* -dstip Target service address, default local 127.0.0.1 | ||
>* -dstport Target service port, such as windows remote desktop 3389, Linux ssh 22 | ||
>* -protocol Target service protocol tcp, udp | ||
>* -peeruser The target user, if it is a node under the same user, no need to set | ||
>* -peerpassword The target password, if it is a node under the same user, no need to set | ||
>* -f Configuration file, if you want to configure multiple P2PApp refer to [config.json](/config.json) | ||
## Client update | ||
``` | ||
# update local client | ||
openp2p update | ||
# update remote client | ||
curl --insecure 'https://openp2p.cn:27182/api/v1/device/YOUR-NODE-NAME/update?user=&password=' | ||
``` | ||
|
||
Windows system needs to set up firewall for this program, the program will automatically set the firewall, if the setting fails, the UDP punching will be affected. | ||
The default firewall configuration of Linux system (Ubuntu and CentOS7) will not have any effect, if not, you can try to turn off the firewall | ||
``` | ||
systemctl stop firewalld.service | ||
systemctl start firewalld.service | ||
firewall-cmd --state | ||
``` |
Oops, something went wrong.