fix http_post_api wrong src dst

This commit is contained in:
Kusakabe Si 2021-12-24 19:28:01 +00:00
parent a70eb72dfa
commit 78322227ef
3 changed files with 8 additions and 5 deletions

View File

@ -912,8 +912,8 @@ func (device *Device) RoutinePostPeerInfo(startchan <-chan struct{}) {
if peer.IsPeerAlive() {
pong := mtypes.PongMsg{
RequestID: 0,
Src_nodeID: device.ID,
Dst_nodeID: id,
Src_nodeID: id,
Dst_nodeID: device.ID,
Timediff: peer.SingleWayLatency.Load().(float64),
TimeToAlive: time.Since(*peer.LastPacketReceivedAdd1Sec.Load().(*time.Time)).Seconds() + device.EdgeConfig.DynamicRoute.PeerAliveTimeout,
}

View File

@ -40,7 +40,7 @@ DynamicRoute:
PSKey: yl/4SNFee7+kNekajVCrK0toqXJ4mlT4IN0klyAgyqU=
EndpointV4: 127.0.0.1:3456
PubKeyV4: 1NS6MxL2LUIlMsppJ5JfHnlofQfCxDUzaItBGwz+jBo=
EndpointV6: "[::1]:12345"
EndpointV6: ""
PubKeyV6: gSBwlJH4aUPRfSP4ZHKAnXIkPZuVaEhsLBispLYFiwo=
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
SkipLocalIP: false

View File

@ -491,7 +491,10 @@ func edge_post_nodeinfo(w http.ResponseWriter, r *http.Request) {
applied_pones := make([]mtypes.PongMsg, 0, len(client_report.Pongs))
for _, pong_msg := range client_report.Pongs {
if pong_msg.Src_nodeID != NodeID {
if pong_msg.Dst_nodeID != NodeID {
if httpobj.http_sconfig.LogLevel.LogControl {
fmt.Printf("Control: Dropped because not correct dst: Recv %v S:%v D:%v From: %v IP:%v(HTTP)\n", pong_msg.ToString(), pong_msg.Src_nodeID.ToString(), pong_msg.Dst_nodeID.ToString(), NodeID.ToString(), r.RemoteAddr)
}
continue
}
@ -503,7 +506,7 @@ func edge_post_nodeinfo(w http.ResponseWriter, r *http.Request) {
}
applied_pones = append(applied_pones, pong_msg)
if httpobj.http_sconfig.LogLevel.LogControl {
fmt.Printf("Control: Recv %v S:%v D:%v From: %v(HTTP) IP:%v\n", pong_msg.ToString(), pong_msg.Src_nodeID.ToString(), pong_msg.Dst_nodeID.ToString(), NodeID.ToString(), r.RemoteAddr)
fmt.Printf("Control: Recv %v S:%v D:%v From: %v IP:%v(HTTP)\n", pong_msg.ToString(), pong_msg.Src_nodeID.ToString(), pong_msg.Dst_nodeID.ToString(), NodeID.ToString(), r.RemoteAddr)
}
}
}