rm some config save

This commit is contained in:
TenderIronh
2025-12-10 16:49:01 +08:00
parent 47220fe38b
commit a1621bcfdd
4 changed files with 103 additions and 4 deletions

40
Changelog.md Normal file
View File

@@ -0,0 +1,40 @@
ChangeLog
v3.24.33更新 (2025.12.10)
Feature
1. 安装和升级下载文件到临时目录
1. openwrt默认100k日志文件
1. 使用系统dns失败时将使用223.5.5.5和8.8.8.8安卓和部分系统有dns问题
1. IPv6刷新时上报到服务器
1. 设备间连接可以设置强制使用v6
1. 编译环境使用go1.25
Issue
1. 修复加载系统证书池bug
1. 修复初始化时崩溃
1. 修复安卓处理多个网络资源bug
1. 修复端口转发编辑目标设备bug
1. 修复某些特殊情况IPv6直连失败
v3.24.23更新 (2025.9.4)
Feature
1. 公网UDP直连
1. upnp定期续期
1. 支持边缘服务器
1. 优化mp分配算法
1. 公网IP不变不再检测nat类型
Issue
1. 修复客户端某些特殊情况卡死bug
1. 修复wintun mtu不生效bug增加缓冲区大小
1. 修复广播bug
1. 修复配置文件清空bug
v3.24.13更新 (2025.6.4)
Feature
1. 虚拟网卡状态上报
1. OpenWrt自动安装tun
1. docker容器运行路径改为/usr/local/openp2p/
Issue
1. 优化客户端卡死问题

View File

@@ -210,7 +210,6 @@ func (c *Config) add(app AppConfig, override bool) {
}
c.mtx.Lock()
defer c.mtx.Unlock()
defer c.save()
if override {
for i := 0; i < len(c.Apps); i++ {
if c.Apps[i].PeerNode == app.PeerNode && c.Apps[i].Protocol == app.Protocol && c.Apps[i].SrcPort == app.SrcPort {
@@ -220,12 +219,14 @@ func (c *Config) add(app AppConfig, override bool) {
}
}
c.Apps = append(c.Apps, &app)
if app.SrcPort != 0 {
c.save()
}
}
func (c *Config) delete(app AppConfig) {
c.mtx.Lock()
defer c.mtx.Unlock()
defer c.save()
for i := 0; i < len(c.Apps); i++ {
if (app.SrcPort != 0 && c.Apps[i].Protocol == app.Protocol && c.Apps[i].SrcPort == app.SrcPort) || // normal app
(app.SrcPort == 0 && c.Apps[i].SrcPort == 0 && c.Apps[i].PeerNode == app.PeerNode) { // memapp
@@ -234,9 +235,12 @@ func (c *Config) delete(app AppConfig) {
} else {
c.Apps = append(c.Apps[:i], c.Apps[i+1:]...)
}
return
break
}
}
if app.SrcPort != 0 {
c.save()
}
}
func (c *Config) save() {

View File

@@ -211,6 +211,8 @@ func handlePush(subType uint16, msg []byte) error {
gConf.Network.specTunnel = int(req.TunnelIndex)
case MsgPushSDWanRefresh:
GNetwork.write(MsgSDWAN, MsgSDWANInfoReq, nil)
case MsgPushNat4Detect:
handleNat4Detect(msg)
default:
i, ok := GNetwork.msgMap.Load(pushHead.From)
if !ok {
@@ -222,6 +224,45 @@ func handlePush(subType uint16, msg []byte) error {
return err
}
func handleNat4Detect(msg []byte) (err error) {
gLog.d("handleNat4Detect")
nd := Nat4Detect{}
if err = json.Unmarshal(msg[openP2PHeaderSize:], &nd); err != nil {
gLog.e("Unmarshal %v:%s %s", reflect.TypeOf(nd), err, string(msg[openP2PHeaderSize:]))
return err
}
detectNatPort := func(protocol, server string, serverPort, localPort int) int {
natPort := 0
if protocol == "tcp" {
_, natPort, _, _ = natDetectTCP(server, serverPort, localPort)
} else {
_, natPort, _ = natDetectUDP(server, serverPort, localPort)
}
// gLog.i("%s %s %d %d %d", protocol, server, serverPort, localPort, natPort)
return natPort
}
result := ""
if nd.Num > 0 {
for i := 0; i < int(nd.Num); i++ {
natPort := detectNatPort(nd.Protocol, nd.Server, int(nd.ServerPort), int(nd.LocalPort)+i)
if i > 0 {
result += ","
}
result += fmt.Sprintf("%d", natPort)
}
} else {
for idx, item := range nd.CustomData {
natPort := detectNatPort(item.Protocol, item.Server, int(item.ServerPort), int(item.LocalPort))
if idx > 0 {
result += ","
}
result += fmt.Sprintf("%d", natPort)
}
}
return GNetwork.write(MsgReport, MsgPushReportLog, &result)
}
func handleEditApp(msg []byte) (err error) {
gLog.i("MsgPushEditApp")
newApp := AppInfo{}

View File

@@ -10,7 +10,7 @@ import (
"time"
)
const OpenP2PVersion = "3.24.28"
const OpenP2PVersion = "3.24.33"
const ProductName string = "openp2p"
const LeastSupportVersion = "3.0.0"
const SyncServerTimeVersion = "3.9.0"
@@ -119,6 +119,7 @@ const (
MsgPushSpecTunnel = 20
MsgPushReportHeap = 21
MsgPushSDWanRefresh = 22
MsgPushNat4Detect = 23
)
// MsgP2P sub type message
@@ -566,6 +567,19 @@ type SpecTunnel struct {
TunnelIndex uint32 `json:"tunnelIndex,omitempty"`
}
type Nat4Detect struct {
CustomData []*Nat4DetectItem
Num int32 `json:"num,omitempty"`
*Nat4DetectItem
}
type Nat4DetectItem struct {
Protocol string `json:"protocol,omitempty"`
Server string `json:"server,omitempty"`
ServerPort int32 `json:"serverPort,omitempty"`
LocalPort int32 `json:"localPort,omitempty"`
}
const rootCA = `-----BEGIN CERTIFICATE-----
MIIDhTCCAm0CFHm0cd8dnGCbUW/OcS56jf0gvRk7MA0GCSqGSIb3DQEBCwUAMH4x
CzAJBgNVBAYTAkNOMQswCQYDVQQIDAJHRDETMBEGA1UECgwKb3BlbnAycC5jbjET