说明
75
README.md
@@ -22,18 +22,10 @@
|
||||
|
||||
[README](README.md) | [中文说明](README_zh.md)
|
||||
|
||||
Users are responsible for complying with local laws and regulations. It must not be used for illegal or criminal purposes.
|
||||
|
||||
</div>
|
||||
|
||||
## Platforms
|
||||
|
||||
| | amd64 | x86 | arm64 | arm |
|
||||
|-------|-------|-------|-------|-------|
|
||||
| Windows | ✔ | ✔ |✔ |✔ |
|
||||
| Linux | ✔ | |✔ |✔ |
|
||||
| Linux Musl | ✔ | |✔ |✔ |
|
||||
| Openwrt | ✔ | |✔ |✔ |
|
||||
| Android(soon) | ✔ | | | |
|
||||
|
||||
## Overview
|
||||
|
||||
Using P2P or server relay, connect multiple LANs to enable communication between any networked devices across these LANs.
|
||||
@@ -42,41 +34,42 @@ Using P2P or server relay, connect multiple LANs to enable communication between
|
||||
<p><img src="./readme/linker.jpg"></p>
|
||||
</div>
|
||||
|
||||
## Legal Compliance
|
||||
The authors and contributors of this project are not liable for any direct, indirect, incidental, special, or consequential damages arising from the use, modification, copying, or distribution of this code. Under no circumstances shall the authors or contributors be held liable for any contractual, tort, or other legal responsibilities.
|
||||
## Platforms
|
||||
|
||||
Users of this project are responsible for ensuring compliance with local laws and regulations. The authors and contributors assume no responsibility for any illegal activities or legal issues resulting from the use of this code. Users must ensure lawful usage within their jurisdiction.
|
||||
| | amd64 | x86 | arm64 | arm |
|
||||
|-------|-------|-------|-------|-------|
|
||||
| Windows | ✔ | ✔ |✔ | |
|
||||
| Linux | ✔ | |✔ |✔ |
|
||||
| Linux Musl | ✔ | |✔ |✔ |
|
||||
| Openwrt | ✔ | |✔ |✔ |
|
||||
| Android | ✔ | | | |
|
||||
|
||||
This code is strictly intended for legal, ethical, and compliant purposes. The authors prohibit any use for illegal activities, attacks, abuse, or other malicious actions, including but not limited to unauthorized access, network attacks, etc.
|
||||
|
||||
For user convenience, this project provides **public messenger servers** and **public relay servers**. When using these services, users must comply with local laws and regulations. The authors, contributors, and server providers are not responsible for any illegal activities or legal issues arising from the use of these public servers.
|
||||
|
||||
## Features
|
||||
- [x] Encrypted configuration files
|
||||
- [x] Encrypted communication (SSL for all traffic)
|
||||
- [x] Hole-punching support: TCP (including IPv6) and UDP
|
||||
- [x] Hole-punching library: Use `linker.tunnel` in your projects
|
||||
- [x] Relay connections with seamless switch to direct P2P once a hole is punched
|
||||
- [x] Cross-LAN networking: Virtual NIC for building LANs between clients (P2P, point-to-network, network-to-network)
|
||||
- [x] Virtual NIC library: Use `linker.tun` in your projects
|
||||
- [x] Port forwarding: Forward local ports to remote client ports
|
||||
- [x] Server penetration: Register ports/domains on a server to access internal services
|
||||
- [x] Permission management: Master client controls permissions, exports/configures sub-client settings
|
||||
- [x] Custom authentication: Validate connections via `HTTP POST` for beacon, relay, and penetration
|
||||
- [x] Traffic statistics: Track beacon, relay, and penetration traffic on servers
|
||||
- [x] Network configuration: Master client sets up networks, auto-assigns IPs to all clients
|
||||
- [x] Distributed architecture: Multiple relay nodes for massive scalability
|
||||
- [x] SOCKS5 proxy: Dynamic port forwarding without specifying ports
|
||||
- [x] Easy integration: Use `linker.messenger.entry` to embed into your projects
|
||||
- [x] CDKEY,It can temporarily lift certain restrictions
|
||||
|
||||
## Quick Integration
|
||||
In a .NET 8+ project, install the NuGet package `linker.messenger.entry`
|
||||
```
|
||||
LinkerMessengerEntry.Initialize();
|
||||
LinkerMessengerEntry.Build();
|
||||
LinkerMessengerEntry.Setup(ExcludeModule.None);
|
||||
```
|
||||
##### P2P & Relaying
|
||||
- [x] Hole punching connections, supporting TCP, UDP, IPv4, and IPv6
|
||||
- [x] Relay connections, with self-hosted relay nodes and support for multiple relay nodes
|
||||
|
||||
##### Communication
|
||||
- [x] Cross-region networking: peer-to-peer, peer-to-network, network-to-network, automatic virtual IP allocation, subnet mapping (resolving multi-LAN subnet conflicts)
|
||||
- [x] Port forwarding: forwards a client's port to another client's port
|
||||
- [x] Server penetration: access internal network services via ports or domains (supports scheduled tasks for timed auto-enabling/disabling)
|
||||
- [x] SOCKS5 proxy: while port forwarding requires specifying ports, the SOCKS5 proxy can handle all ports
|
||||
|
||||
##### Other
|
||||
- [x] Encrypted configuration files
|
||||
- [x] Permission management: the main client has full control, allowing the export and configuration of sub-client settings and delegated admin rights
|
||||
- [x] Custom authentication: via HTTP POST, you can define verification rules for allowing connection beacons, relays, and intranet penetration
|
||||
- [x] Traffic statistics: monitors traffic for beacons, relays, and intranet penetration on the server
|
||||
- [x] CD-KEY: temporarily unlocks certain restrictions, such as relays and intranet penetration
|
||||
|
||||
## Development
|
||||
- [x] Uses the linker.tunnel library for hole punching
|
||||
- [x] Uses the linker.tun virtual NIC library, including Linux TUN and Windows Wintun adapters, NAT conversion, and subnet mapping
|
||||
- [x] Uses the linker.snat library for NAT conversion
|
||||
- [x] Uses linker.messenger.entry for full-feature integration
|
||||
|
||||
|
||||
## Network Mapping
|
||||
Network mapping can help you resolve conflicts between multiple internal network.
|
||||
@@ -85,7 +78,7 @@ Network mapping can help you resolve conflicts between multiple internal network
|
||||
<p><img src="./readme/mapto.jpg"></p>
|
||||
</div>
|
||||
|
||||
## SNAT
|
||||
## Src NAT
|
||||
Built-in SNAT enables you to use the point-to-site functionality even on Windows 7/8 and Windows Server 2008/2012 where NetNat is unavailable.
|
||||
|
||||
<div align="center">
|
||||
|
64
README_zh.md
@@ -22,61 +22,53 @@
|
||||
|
||||
[README](README.md) | [中文说明](README_zh.md)
|
||||
|
||||
使用人员有责任和义务遵守当地法律条规,请勿用于违法犯罪
|
||||
|
||||
</div>
|
||||
|
||||
## 大概意思
|
||||
|
||||
使用p2p或者中继转发,让你的各个局域网连通起来,让各个局域网内的任意联网设备都可以相互连通
|
||||
|
||||
<div align="center">
|
||||
<p><img src="./readme/linker.jpg"></p>
|
||||
</div>
|
||||
|
||||
## 支持平台
|
||||
|
||||
| | amd64 | x86 | arm64 | arm |
|
||||
|-------|-------|-------|-------|-------|
|
||||
| Windows | ✔ | ✔ |✔ |✔ |
|
||||
| Windows | ✔ | ✔ |✔ | |
|
||||
| Linux | ✔ | |✔ |✔ |
|
||||
| Linux Musl | ✔ | |✔ |✔ |
|
||||
| Openwrt | ✔ | |✔ |✔ |
|
||||
| Android(很快) | ✔ | | | |
|
||||
| Android | ✔ | | | |
|
||||
|
||||
## 大概意思
|
||||
|
||||
使用p2p或者服务器转发,让你的各个局域网连通起来,让各个局域网内的任意联网设备都可以相互连通
|
||||
## 主要功能
|
||||
|
||||
<div align="center">
|
||||
<p><img src="./readme/linker.jpg"></p>
|
||||
</div>
|
||||
##### 打洞中继
|
||||
- [x] 打洞连接,支持TCP、UDP、IPV4、IPV6
|
||||
- [x] 中继连接,自建中继节点,支持多中继节点
|
||||
|
||||
## 遵纪守法
|
||||
本项目的作者和贡献者不对因使用、修改、复制或分发本代码而产生的任何形式的直接、间接、偶然、特殊或后果性损害负责。无论在何种情况下,无论是合同责任、侵权行为或其他任何法律责任,作者和贡献者均不承担任何责任
|
||||
|
||||
使用本项目代码的用户有责任确保其使用符合当地法律法规。作者和贡献者不对任何违法行为或因使用本代码而可能发生的法律问题负责。用户应确保在符合法律的范围内使用本项目。
|
||||
|
||||
本项目的代码仅限用于合法、道德和合规的目的。作者严禁任何用户将其用于非法活动、攻击行为、滥用或其他不当用途,包括但不限于未经授权的访问、网络攻击等行为。
|
||||
|
||||
为方便用户使用,本项目提供**公开信标服务器**、**公开中继服务器**,使用**公开信标服务器**、**公开中继服务器**时请遵守当地法律法规,作者和贡献者和服务器提供者不对任何违法行为或因使用**公开信标服务器**、**公开中继服务器**而可能发生的法律问题负责
|
||||
|
||||
## 已有功能
|
||||
- [x] 配置加密,配置文件加密
|
||||
- [x] 通信加密,所有通信均`ssl加密`
|
||||
- [x] 打洞连接,`TCP打洞、UDP打洞,(支持IPV6)`
|
||||
- [x] 打洞类库,你可以使用`linker.tunnel`打洞库到你的项目中
|
||||
- [x] 中继连接,先中继连接,然后偷偷打洞,打洞成功则无缝切换线路
|
||||
- [x] 异地组网,使用虚拟网卡,将各个客户端组建为局域网络,`点对点`,`点对网`,`网对网`
|
||||
- [x] 网卡类库,你可以使用`linker.tun` tun网卡库到你的项目中
|
||||
##### 通信方式
|
||||
- [x] 异地组网,点对点、点对网、网对网、自动分配虚拟IP、网段映射(处理多局域网网段冲突)
|
||||
- [x] 端口转发,将客户端的端口转发到其它客户端的端口
|
||||
- [x] 服务器穿透,在服务器注册端口或域名,通过访问服务器端口或域名,访问内网服务(支持`计划任务`,定时定长自动开启关闭)
|
||||
- [x] 服务器穿透,使用端口或域名访问内网服务(支持计划任务,定时定长自动开启关闭)
|
||||
- [x] socks5代理,端口转发需要指定端口,而`socks5代理`可以代理所有端口
|
||||
|
||||
##### 其它功能
|
||||
- [x] 配置文件加密
|
||||
- [x] 权限管理,主客户端拥有完全权限,可导出、配置子客户端配置,分配其管理权限
|
||||
- [x] 自定义验证,通过`HTTP POST`让你可以自定义认证是否允许`连接信标`,`中继`,`内网穿透`
|
||||
- [x] 流量统计,统计服务器`信标`、`中继`、`内网穿透` 的流量情况
|
||||
- [x] 网络配置,主客户端设置网络,所有客户端自动分配IP
|
||||
- [x] 分布式,多中继服务器节点,承载海量设备
|
||||
- [x] socks5代理,端口转发需要指定端口,而`socks5代理`可以代理所有端口
|
||||
- [x] 集成linker,使用`linker.messenger.entry`入口库,轻松集成到你的项目中
|
||||
- [x] CDKEY,可以临时解锁一些限制,中继,内外穿透什么的
|
||||
|
||||
## 轻松集成
|
||||
在.NET8+项目中,nuget 安装 `linker.messenger.entry`
|
||||
```
|
||||
LinkerMessengerEntry.Initialize();
|
||||
LinkerMessengerEntry.Build();
|
||||
LinkerMessengerEntry.Setup(ExcludeModule.None);
|
||||
```
|
||||
## 二开集成
|
||||
- [x] 使用`linker.tunnel`打洞库
|
||||
- [x] 使用`linker.tun`虚拟网卡库,包含`linux tun`、`windows wintun`网卡,NAT转换,网段映射
|
||||
- [x] 使用`linker.snat`NAT转换库
|
||||
- [x] 使用`linker.messenger.entry`集成完整功能
|
||||
|
||||
## 网段映射
|
||||
网段映射可以帮你解决多个内网网段冲突的问题
|
||||
|
@@ -440,6 +440,10 @@ namespace linker.app
|
||||
return new List<LinkerTunDeviceForwardItem>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加路由
|
||||
/// </summary>
|
||||
/// <param name="ips"></param>
|
||||
public void AddRoute(LinkerTunDeviceRouteItem[] ips)
|
||||
{
|
||||
routes = ips.Select(c => new LinkerTunDeviceRouteItem { Address = c.Address, PrefixLength = c.PrefixLength }).ToArray();
|
||||
|
@@ -4,7 +4,7 @@ sidebar_position: 11
|
||||
|
||||
# 11、傻瓜特别版(共享局域网)
|
||||
|
||||
:::tip[说明]
|
||||
:::tip[不开源不免费,有需要请联系作者]
|
||||
|
||||
### 共享端
|
||||
|
||||
|
@@ -7,4 +7,10 @@ sidebar_position: 12
|
||||
:::tip[说明]
|
||||
1. 为什么会定位不准确,显示了别的国家的国旗,但是设备名那里显示的又是正确的IP
|
||||
>因为定位查询用的是`http://ip-api.com/json`和`https://api.myip.la/en?json`接口,可能走了科学发展之路
|
||||
|
||||
2. WIN11 22H2 连接不了SMB文件共享服务,需要powershell 执行以下命令
|
||||
```
|
||||
Set-SmbClientConfiguration -RequireSecuritySignature $false
|
||||
Set-SmbClientConfiguration -EnableInsecureGuestLogons $true
|
||||
```
|
||||
:::
|
@@ -7,6 +7,7 @@ sidebar_position: 1
|
||||
:::danger[特别声明]
|
||||
1. 因为没有签名,又需要较高的权限,所以可能存在报毒的情况,请手动在安全软件中添加白名单
|
||||
2. 如有疑问,可右上角移步软件源码,公开透明
|
||||
3. 使用人员有责任和义务遵守当地法律条规,请勿用于违法犯罪
|
||||
:::
|
||||
|
||||
:::tip[说明]
|
||||
@@ -16,44 +17,11 @@ sidebar_position: 1
|
||||
使用p2p或者服务器转发,让你的各个局域网连通起来,让各个局域网内的任意联网设备都可以相互连通
|
||||

|
||||
|
||||
#### 1.2、超级叠甲
|
||||
|
||||
本项目的作者和贡献者不对因使用、修改、复制或分发本代码而产生的任何形式的直接、间接、偶然、特殊或后果性损害负责。无论在何种情况下,无论是合同责任、侵权行为或其他任何法律责任,作者和贡献者均不承担任何责任。
|
||||
|
||||
使用本项目代码的用户有责任确保其使用符合当地法律法规。作者和贡献者不对任何违法行为或因使用本代码而可能发生的法律问题负责。用户应确保在符合法律的范围内使用本项目。
|
||||
|
||||
本项目的代码仅限用于合法、道德和合规的目的。作者严禁任何用户将其用于非法活动、攻击行为、滥用或其他不当用途,包括但不限于未经授权的访问、网络攻击等行为。
|
||||
|
||||
为方便用户使用,本项目提供**公开信标服务器**、**公开中继服务器**,使用**公开信标服务器**、**公开中继服务器**时请遵守当地法律法规,作者和贡献者和服务器提供者不对任何违法行为或因使用**公开信标服务器**、**公开中继服务器**而可能发生的法律问题负责
|
||||
|
||||
|
||||
#### 1.3、主要功能
|
||||
- [x] 配置加密,配置文件加密
|
||||
- [x] 通信加密,所有通信均`ssl加密`
|
||||
- [x] 打洞连接,TCP(支持IPV6)打洞、UDP打洞
|
||||
- [x] 打洞类库,你可以使用`linker.tunnel`打洞库到你的项目中
|
||||
- [x] 中继连接,先中继连接,然后偷偷打洞,打洞成功则无缝切换线路
|
||||
- [x] 异地组网,使用虚拟网卡,将各个客户端组建为局域网络,`点对点`,`点对网`,`网对网`
|
||||
- [x] 网卡类库,你可以使用`linker.tun` tun网卡库到你的项目中
|
||||
- [x] 端口转发,将客户端的端口转发到其它客户端的端口
|
||||
- [x] 服务器穿透,在服务器注册端口或域名,通过访问服务器端口或域名,访问内网服务
|
||||
- [x] 权限管理,主客户端拥有完全权限,可导出、配置子客户端配置,分配其管理权限
|
||||
- [x] 自定义验证,通过`HTTP POST`让你可以自定义认证是否允许`连接信标`,`中继`,`内网穿透`
|
||||
- [x] 流量统计,统计服务器`信标`、`中继`、`内网穿透` 的流量情况
|
||||
- [x] 网络配置,主客户端设置网络,所有客户端自动分配IP
|
||||
- [x] 分布式,多中继服务器节点,承载海量设备
|
||||
- [x] socks5代理,端口转发需要指定端口,而socks5代理可以代理所有端口
|
||||
- [x] 集成linker,使用`linker.messenger.entry`入口库,轻松集成到你的项目中
|
||||
- [x] CDKEY,可以临时解锁一些限制,中继,内外穿透什么的
|
||||
|
||||
#### 1.4、加入组织
|
||||
#### 1.2、加入组织
|
||||
<a href="https://jq.qq.com/?_wv=1027&k=ucoIVfz4" target="_blank">你可以加入QQ群:1121552990</a>
|
||||
|
||||
--
|
||||
|
||||
#### 1.5、感谢支持
|
||||
|
||||
<a href="https://mi-d.cn" target="_blank"><img src="https://mi-d.cn/wp-content/uploads/2021/12/cropped-1639494965-网站LOGO无字.png" width="40" style={{verticalAlign: 'middle'}} /> 米多贝克</a>
|
||||
:::
|
||||
|
||||
:::danger[win10以下]
|
||||
|
8
src/linker.doc.web/docs/2、安装运行/_category_.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"label": "2、安装运行",
|
||||
"position": 2,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "首次安装运行时需要看的."
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
Before Width: | Height: | Size: 195 KiB After Width: | Height: | Size: 195 KiB |
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"label": "2、首次运行",
|
||||
"position": 2,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "首次运行时需要看的."
|
||||
}
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
---
|
||||
sidebar_position: 22
|
||||
sidebar_position: 100
|
||||
---
|
||||
|
||||
# 8.22、单独使用虚拟网卡
|
||||
# 8.100、单独使用虚拟网卡
|
||||
|
||||
## 1、说明
|
||||
|
47
src/linker.doc.web/docs/8、集成和二次开发/8.101、单独使用应用层SNAT.md
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
sidebar_position: 101
|
||||
---
|
||||
|
||||
# 8.101、单独使用应用层SNAT
|
||||
|
||||
:::tip[说明]
|
||||
有效解决win7/8,win server2008/2012无法使用`NetNat`的问题
|
||||
|
||||
如果你使用的是`linker.tun`类库,已经集成应用层SNAT,使用`LinkerTunDeviceAdapter.SetSystemNat`使用系统NAT和`LinkerTunDeviceAdapter.SetAppNat`使用应用层SNAT即可
|
||||
|
||||
|
||||
去<a href="https://reqrypt.org/windivert.html">windivert</a>下载抓包驱动,放置合适的`WinDivert.dll`和`WinDivert.sys`到程序根目录,然后 nuget 安装 `linker.snat`,然后编写代码
|
||||
|
||||
```c#
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//初始化
|
||||
LinkerSrcNat linkerSrcNat = new LinkerSrcNat();
|
||||
bool result = linkerSrcNat.Setup(new SetupInfo{
|
||||
//虚拟网卡IP
|
||||
Src = IPAddress.Parse("10.18.18.2"),
|
||||
//仅访问192.168.1.0/24时NAT
|
||||
Dsts = new AddrInfo[]{
|
||||
new AddrInfo(IPAddress.Parse("192.168.1.0"),24)
|
||||
},
|
||||
//本机局域网IP,用于替换为源IP
|
||||
InterfaceIp = IPAddress.Parse("192.168.1.2")
|
||||
},out string error);
|
||||
|
||||
//在将TCP/IP数据包写入网卡前增加一个操作
|
||||
if(linkerSrcNat.Inject(packet) == false)
|
||||
{
|
||||
//不需要NAT或者NAT失败,这里可以继续把数据包写入虚拟网卡
|
||||
}
|
||||
|
||||
//关闭
|
||||
linkerSrcNat.Shutdown();
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
:::
|
46
src/linker.doc.web/docs/8、集成和二次开发/8.102、单独使用网段映射.md
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
sidebar_position: 102
|
||||
---
|
||||
|
||||
# 8.102、单独使用网段映射
|
||||
|
||||
:::tip[说明]
|
||||
有效解决使用虚拟网卡组网时,多个设备内网网段冲突的问题
|
||||
|
||||
如果你使用的是`linker.tun`类库,已经集成网段映射,使用`LinkerTunDeviceAdapter.SetMap`设置映射即可
|
||||
|
||||
在nuget 安装 `linker.snat`,然后编写代码
|
||||
|
||||
```c#
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//初始化
|
||||
LinkerDstMapping linkerDstMapping = new LinkerDstMapping();
|
||||
|
||||
//在喜欢的时候设置映射,随时都可以,设置为空数组就不启用了
|
||||
linkerDstMapping.SetDsts(new DstMapInfo[]{
|
||||
new DstMapInfo{
|
||||
//一个假IP。比如对方访问 192.168.188.2
|
||||
FakeIP = IPAddress.Parse("192.168.188.0"),
|
||||
//真实IP,实际访问到的IP
|
||||
RealIP = IPAddress.Parse("192.168.1.0"),
|
||||
//掩码,24替换前三段
|
||||
//当问192.168.188.2的时候,将会访问到192.168.1.2
|
||||
PrefixLength = 24,
|
||||
}
|
||||
});
|
||||
|
||||
//在收到对方发来的数据包写入网卡前使用,替换为真IP
|
||||
linkerDstMapping.ToRealDst(packet);
|
||||
//在从虚拟网卡读取到数据包发送给对方之前调用,还原为假IP
|
||||
linkerDstMapping.ToFakeDst(packet);
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
:::
|
@@ -1,8 +1,8 @@
|
||||
---
|
||||
sidebar_position: 33
|
||||
sidebar_position: 200
|
||||
---
|
||||
|
||||
# 8.33、组网和内网穿透流程图
|
||||
# 8.200、组网和内网穿透流程图.md
|
||||
|
||||
:::tip[说明]
|
||||
|
@@ -13,20 +13,20 @@ const FeatureList = [
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '打洞、中继、和穿透',
|
||||
title: '打洞、中继、内网穿透',
|
||||
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
|
||||
description: (
|
||||
<>
|
||||
TCP+UDP打洞、服务器中继、服务器穿透,简单几步,将打洞和中继集成到你自己的项目中
|
||||
TCP+UDP打洞、服务器中继、服务器穿透,喜欢啥就用啥
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '组网和转发',
|
||||
title: '异地组网',
|
||||
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
|
||||
description: (
|
||||
<>
|
||||
虚拟网卡组网,端口转发访问,均支持TCP+UDP及其上层协议
|
||||
虚拟网卡组网,点对点,点对网,网对网,还有网段映射(多局域网网段冲突也不怕)
|
||||
</>
|
||||
),
|
||||
},
|
||||
|
@@ -24,13 +24,6 @@ namespace linker.messenger.decenter
|
||||
this.signInClientStore = signInClientStore;
|
||||
|
||||
SyncTask();
|
||||
signInClientState.OnSignInSuccess += (times) =>
|
||||
{
|
||||
foreach (IDecenter item in decenters)
|
||||
{
|
||||
item.PushVersion.Increment();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -103,7 +96,7 @@ namespace linker.messenger.decenter
|
||||
{
|
||||
if (versionMultipleManager.HasValueChange(item.Name))
|
||||
{
|
||||
Task.Run(item.ProcData).ContinueWith((result) => { operatingMultipleManager.StopOperation(item.Name); });
|
||||
Task.Run(item.ProcData).ContinueWith((result) => { operatingMultipleManager.StopOperation(item.Name); });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -112,6 +105,23 @@ namespace linker.messenger.decenter
|
||||
}
|
||||
}
|
||||
}
|
||||
private async Task CheckData()
|
||||
{
|
||||
foreach (IDecenter item in decenters)
|
||||
{
|
||||
MessageResponeInfo resp = await messengerSender.SendReply(new MessageRequestWrap
|
||||
{
|
||||
Connection = signInClientState.Connection,
|
||||
MessengerId = (ushort)DecenterMessengerIds.Check,
|
||||
Payload = serializer.Serialize(item.Name),
|
||||
});
|
||||
if (resp.Code != MessageResponeCodes.OK || resp.Data.Span.SequenceEqual(Helper.TrueArray) == false)
|
||||
{
|
||||
item.PushVersion.Increment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SyncData()
|
||||
{
|
||||
List<IDecenter> updates = decenters.Where(c => c.PushVersion.Restore()).ToList();
|
||||
@@ -155,7 +165,7 @@ namespace linker.messenger.decenter
|
||||
task.Decenter.DataVersion.Increment();
|
||||
versionMultipleManager.Increment(task.Decenter.Name);
|
||||
}
|
||||
foreach (var task in pullTasks.Where(c => c.Task.Result.Code == MessageResponeCodes.TIMEOUT))
|
||||
foreach (var task in pullTasks.Where(c => c.Task.Result.Code != MessageResponeCodes.OK || c.Task.Result.Data.Span.SequenceEqual(Helper.FalseArray)))
|
||||
{
|
||||
task.Decenter.PushVersion.Increment();
|
||||
}
|
||||
@@ -164,6 +174,21 @@ namespace linker.messenger.decenter
|
||||
|
||||
private void SyncTask()
|
||||
{
|
||||
TimerHelper.SetIntervalLong(async () =>
|
||||
{
|
||||
if (signInClientState.Connected == false) return;
|
||||
try
|
||||
{
|
||||
await CheckData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG)
|
||||
{
|
||||
LoggerHelper.Instance.Error(ex);
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
TimerHelper.SetIntervalLong(async () =>
|
||||
{
|
||||
if (signInClientState.Connected == false) return;
|
||||
@@ -181,6 +206,14 @@ namespace linker.messenger.decenter
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
|
||||
signInClientState.OnSignInSuccess += (times) =>
|
||||
{
|
||||
foreach (IDecenter item in decenters)
|
||||
{
|
||||
item.PushVersion.Increment();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class DecenterSyncTaskInfo
|
||||
|
@@ -95,21 +95,6 @@ namespace linker.messenger.decenter
|
||||
}));
|
||||
}
|
||||
|
||||
private void ClearTask()
|
||||
{
|
||||
TimerHelper.SetIntervalLong(() =>
|
||||
{
|
||||
List<string> removes = decenters.Values.SelectMany(c => c.Values).Where(c => c.SignIn.Connected == false).Select(c => c.SignIn.Id).ToList();
|
||||
foreach (ConcurrentDictionary<string, DecenterCacheInfo> dic in decenters.Values)
|
||||
{
|
||||
foreach (string id in removes)
|
||||
{
|
||||
dic.TryRemove(id, out _);
|
||||
}
|
||||
}
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
[MessengerId((ushort)DecenterMessengerIds.AddForward)]
|
||||
public void AddForward(IConnection connection)
|
||||
{
|
||||
@@ -153,6 +138,32 @@ namespace linker.messenger.decenter
|
||||
}
|
||||
|
||||
|
||||
[MessengerId((ushort)DecenterMessengerIds.Check)]
|
||||
public void Check(IConnection connection)
|
||||
{
|
||||
string name = serializer.Deserialize<string>(connection.ReceiveRequestWrap.Payload.Span);
|
||||
if (decenters.TryGetValue(name, out ConcurrentDictionary<string, DecenterCacheInfo> dic) && dic.ContainsKey(connection.Id))
|
||||
{
|
||||
connection.Write(Helper.TrueArray);
|
||||
return;
|
||||
}
|
||||
connection.Write(Helper.FalseArray);
|
||||
}
|
||||
|
||||
private void ClearTask()
|
||||
{
|
||||
TimerHelper.SetIntervalLong(() =>
|
||||
{
|
||||
List<string> removes = decenters.Values.SelectMany(c => c.Values).Where(c => c.SignIn.Connected == false).Select(c => c.SignIn.Id).ToList();
|
||||
foreach (ConcurrentDictionary<string, DecenterCacheInfo> dic in decenters.Values)
|
||||
{
|
||||
foreach (string id in removes)
|
||||
{
|
||||
dic.TryRemove(id, out _);
|
||||
}
|
||||
}
|
||||
}, 30000);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DecenterClientMessenger : IMessenger
|
||||
|
@@ -12,6 +12,8 @@
|
||||
Notify = 2814,
|
||||
PullPage = 2815,
|
||||
|
||||
Check = 2816,
|
||||
|
||||
Max = 2899
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ namespace linker.snat
|
||||
masks = maps.Select(x => NetworkHelper.ToPrefixValue(x.PrefixLength)).ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// 缓缓为假IP
|
||||
/// 转换为假IP
|
||||
/// </summary>
|
||||
/// <param name="packet">TCP/IP</param>
|
||||
public void ToFakeDst(ReadOnlyMemory<byte> packet)
|
||||
@@ -56,7 +56,7 @@ namespace linker.snat
|
||||
/// 转换为真IP
|
||||
/// </summary>
|
||||
/// <param name="packet">TCP/IP</param>
|
||||
/// <param name="checksum">是否计算校验和</param>
|
||||
/// <param name="checksum">是否计算校验和,如果使用了应用层NAT,可以交给应用层NAT去计算校验和</param>
|
||||
public void ToRealDst(ReadOnlyMemory<byte> packet,bool checksum = true)
|
||||
{
|
||||
//只支持映射IPV4
|
||||
|
@@ -1,10 +1,8 @@
|
||||
using linker.libs;
|
||||
using linker.libs.timer;
|
||||
using linker.snat;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using static linker.snat.LinkerDstMapping;
|
||||
using static linker.snat.LinkerSrcNat;
|
||||
|
||||
namespace linker.tun
|
||||
{
|
||||
@@ -93,7 +91,7 @@ namespace linker.tun
|
||||
/// <param name="deviceName">网卡IP</param>
|
||||
/// <param name="address">网卡IP</param>
|
||||
/// <param name="prefixLength">掩码。一般24即可</param>
|
||||
/// <param name="mtu">mtu</param>
|
||||
/// <param name="mtu">mtu,建议1420</param>
|
||||
public bool Setup(string deviceName, IPAddress address, byte prefixLength, int mtu)
|
||||
{
|
||||
if (operatingManager.StartOperation() == false)
|
||||
@@ -310,7 +308,7 @@ namespace linker.tun
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 写入网卡
|
||||
/// 写入一个TCP/IP数据包
|
||||
/// </summary>
|
||||
/// <param name="buffer"></param>
|
||||
/// <returns></returns>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
v1.7.7
|
||||
2025-05-03 11:31:09
|
||||
2025-05-05 01:42:35
|
||||
1. 一些累计更新
|
||||
2. 优化ssl证书,兼容安卓
|
||||
3. 打洞和中继优化,显示loading,增加手动尝试打洞
|
||||
|