Skip to content

Commit

Permalink
3.18.4 virtual private network
Browse files Browse the repository at this point in the history
  • Loading branch information
TenderIronh committed Jul 14, 2024
1 parent e7b696c commit 9dda148
Show file tree
Hide file tree
Showing 62 changed files with 3,842 additions and 895 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ libs/
openp2p.app.jks
openp2p.aar
openp2p-sources.jar
build.gradle
wintun/
wintun.dll
.vscode/
app/.idea/
*_debug_bin*
cmd/openp2p
14 changes: 8 additions & 6 deletions README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

[查看详细](#安全性)
### 4. 轻量
文件大小2MB+,运行内存2MB+;全部在应用层实现,没有虚拟网卡,没有内核程序
文件大小2MB+,运行内存2MB+;它可以仅跑在应用层,或者配合wintun驱动使用组网功能
### 5. 跨平台
因为轻量,所以很容易支持各个平台。支持主流的操作系统:Windows,Linux,MacOS;和主流的cpu架构:386、amd64、arm、arm64、mipsle、mipsle64、mips、mips64
因为轻量,所以很容易支持各个平台。支持主流的操作系统:Windows,Linux,MacOS;和主流的cpu架构:386、amd64、arm、arm64、mipsle、mipsle64、mips、mips64、s390x、ppc64le
### 6. 高效
P2P直连可以让你的设备跑满带宽。不论你的设备在任何网络环境,无论NAT1-4(Cone或Symmetric),UDP或TCP打洞,UPNP,IPv6都支持。依靠Quic协议优秀的拥塞算法,能在糟糕的网络环境获得高带宽低延时。

Expand Down Expand Up @@ -128,13 +128,15 @@ CGO_ENABLED=0 env GOOS=linux GOARCH=amd64 go build -o openp2p --ldflags '-s -w '
6. 客户端提供WebUI
7. ~~支持自有服务器,开源服务器程序~~(100%)
8. 共享节点调度模型优化,对不同的运营商优化
9. 方便二次开发,提供API和lib
9. ~~方便二次开发,提供API和lib~~(100%)
10. ~~应用层支持UDP协议,实现很简单,但UDP应用较少暂不急~~(100%)
11. 底层通信支持KCP协议,目前仅支持Quic;KCP专门对延时优化,被游戏加速器广泛使用,可以牺牲一定的带宽降低延时
11. ~~底层通信支持KCP协议,目前仅支持Quic;KCP专门对延时优化,被游戏加速器广泛使用,可以牺牲一定的带宽降低延时~~(100%)
12. ~~支持Android系统,让旧手机焕发青春变成移动网关~~(100%)
13. 支持Windows网上邻居共享文件
14. 内网直连优化,用处不大,估计就用户测试时用到
13. ~~支持Windows网上邻居共享文件~~(100%)
14. ~~内网直连优化~~(100%)
15. ~~支持UPNP~~(100%)
16. ~~支持Android~~(100%)
17. 支持IOS

远期计划:
1. 利用区块链技术去中心化,让共享设备的用户有收益,从而促进更多用户共享,达到正向闭环。
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ The code is open source, the P2P tunnel uses TLS1.3+AES double encryption, and t
[details](#Safety)

### 4. Lightweight
2MB+ filesize, 2MB+ memory. It runs at appllication layer, no vitrual NIC, no kernel driver.
2MB+ filesize, 2MB+ memory. It could only runs at application layer, or uses wintun driver for SDWAN.

### 5. 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.
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、s390x、ppc64le.

### 6. 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),UDP or TCP punching,UPNP,IPv6. Relying on the excellent congestion algorithm of the Quic protocol, high bandwidth and low latency can be obtained in a bad network environment.
Expand Down Expand Up @@ -136,14 +136,15 @@ Short-Term:
6. Provide WebUI on client side.
7. ~~Support private server, open source server program.~~(100%)
8. Optimize our share scheduling model for different network operators.
9. Provide REST APIs and libary for secondary development.
9. ~~Provide REST APIs and libary for secondary development.~~(100%)
10. ~~Support UDP at application layer, it is easy to implement but not urgent due to only a few applicaitons using UDP protocol.~~(100%)
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.
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. ~~(100%)
12. ~~Support Android platform, let the phones to be mobile gateway.~~(100%)
13. Support SMB Windows neighborhood.
14. Direct connection on intranet, for testing.
13. ~~Support SMB Windows neighborhood.~~(100%)
14. ~~Direct connection on intranet, for testing.~~(100%)
15. ~~Support UPNP.~~(100%)

16. ~~Support Android~~(100%)
17. Support IOS

Long-Term:
1. Use blockchain technology to decentralize, so that users who share equipment have benefits, thereby promoting more users to share, and achieving a positive closed loop.
Expand Down
5 changes: 3 additions & 2 deletions USAGE-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ nohup ./openp2p -d -node OFFICEPC1 -token TOKEN &
```
{
"network": {
"Node": "hhd1207-222",
"Node": "YOUR-NODE-NAME",
"Token": "TOKEN",
"ShareBandwidth": 0,
"ServerHost": "api.openp2p.cn",
Expand Down Expand Up @@ -87,7 +87,8 @@ systemctl stop firewalld.service
systemctl start firewalld.service
firewall-cmd --state
```

## 停止
TODO: windows linux macos
## 卸载
```
./openp2p uninstall
Expand Down
2 changes: 1 addition & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Configuration example
```
{
"network": {
"Node": "hhd1207-222",
"Node": "YOUR-NODE-NAME",
"Token": "TOKEN",
"ShareBandwidth": 0,
"ServerHost": "api.openp2p.cn",
Expand Down
10 changes: 0 additions & 10 deletions app/.idea/runConfigurations.xml

This file was deleted.

6 changes: 5 additions & 1 deletion app/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## Build
depends on openjdk 11, gradle 8.1.3, ndk 21
```
cd core
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
go get -v golang.org/x/mobile/bind
cd core
gomobile bind -target android -v
if [[ $? -ne 0 ]]; then
echo "build error"
Expand Down
123 changes: 62 additions & 61 deletions app/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
signingConfigs {
release {
storeFile file('C:\\work\\src\\openp2p-client\\app\\openp2p.jks')
storePassword 'YOUR-PASSWORD'
keyAlias 'openp2p.keys'
keyPassword 'YOUR-PASSWORD'
}
}
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "cn.openp2p"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "2718281828"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation files('libs\\openp2p-sources.jar')
plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
signingConfigs {
release {
storeFile file('C:\\work\\src\\openp2p-client\\app\\openp2p.jks')
storePassword 'YOUR-PASSWORD'
keyAlias 'openp2p.keys'
keyPassword 'YOUR-PASSWORD'
}
}
compileSdkVersion 31
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "cn.openp2p"
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "2718281828"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
namespace "cn.openp2p"
}

buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation files('libs\\openp2p-sources.jar')
}
15 changes: 11 additions & 4 deletions app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.openp2p">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
android:allowBackup="true"
Expand All @@ -27,13 +26,21 @@

<activity
android:name=".ui.login.LoginActivity"
android:label="@string/app_name">
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="BootReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>

</manifest>
27 changes: 27 additions & 0 deletions app/app/src/main/java/cn/openp2p/BootReceiver.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cn.openp2p

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.net.VpnService
import android.os.Build
import android.os.Bundle
import android.util.Log
import cn.openp2p.ui.login.LoginActivity
class BootReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
// Logger.log("pp onReceive "+intent.action.toString())
Log.i("onReceive","start "+intent.action.toString())
// if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
// Log.i("onReceive","match "+intent.action.toString())
// VpnService.prepare(context)
// val intent = Intent(context, OpenP2PService::class.java)
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// context.startForegroundService(intent)
// } else {
// context.startService(intent)
// }
// }
Log.i("onReceive","end "+intent.action.toString())
}
}
Loading

0 comments on commit 9dda148

Please sign in to comment.