diff --git a/relay_manager.go b/relay_manager.go index 61decee69..bbc151db1 100644 --- a/relay_manager.go +++ b/relay_manager.go @@ -280,7 +280,8 @@ func (rm *relayManager) handleCreateRelayRequest(v cert.Version, h *HostInfo, f msg, err := resp.Marshal() if err != nil { - logMsg.WithError(err).Error("relayManager Failed to marshal Control CreateRelayResponse message to create relay") + logMsg. + WithError(err).Error("relayManager Failed to marshal Control CreateRelayResponse message to create relay") } else { f.SendMessageToHostInfo(header.Control, 0, h, msg, make([]byte, 12), make([]byte, mtu)) rm.l.WithFields(logrus.Fields{ @@ -334,27 +335,29 @@ func (rm *relayManager) handleCreateRelayRequest(v cert.Version, h *HostInfo, f } if v == cert.Version1 { - if !from.Is4() { + if !h.vpnAddrs[0].Is4() { //TODO: log it return } - b := from.As4() + + b := h.vpnAddrs[0].As4() req.OldRelayFromAddr = binary.BigEndian.Uint32(b[:]) b = target.As4() req.OldRelayToAddr = binary.BigEndian.Uint32(b[:]) } else { - req.RelayFromAddr = netAddrToProtoAddr(from) + req.RelayFromAddr = netAddrToProtoAddr(h.vpnAddrs[0]) req.RelayToAddr = netAddrToProtoAddr(target) } msg, err := req.Marshal() if err != nil { - logMsg.WithError(err).Error("relayManager Failed to marshal Control message to create relay") + logMsg. + WithError(err).Error("relayManager Failed to marshal Control message to create relay") } else { f.SendMessageToHostInfo(header.Control, 0, peer, msg, make([]byte, 12), make([]byte, mtu)) rm.l.WithFields(logrus.Fields{ //TODO: IPV6-WORK another lazy used to use the req object - "relayFrom": from, + "relayFrom": h.vpnAddrs[0], "relayTo": target, "initiatorRelayIndex": req.InitiatorRelayIndex, "responderRelayIndex": req.ResponderRelayIndex, @@ -372,7 +375,8 @@ func (rm *relayManager) handleCreateRelayRequest(v cert.Version, h *HostInfo, f } _, err := AddRelay(rm.l, h, f.hostMap, target, &m.InitiatorRelayIndex, ForwardingType, state) if err != nil { - logMsg.WithError(err).Error("relayManager Failed to allocate a local index for relay") + logMsg. + WithError(err).Error("relayManager Failed to allocate a local index for relay") return } } else { @@ -393,28 +397,29 @@ func (rm *relayManager) handleCreateRelayRequest(v cert.Version, h *HostInfo, f } if v == cert.Version1 { - if !from.Is4() { + if !h.vpnAddrs[0].Is4() { //TODO: log it return } - b := from.As4() + b := h.vpnAddrs[0].As4() resp.OldRelayFromAddr = binary.BigEndian.Uint32(b[:]) b = target.As4() resp.OldRelayToAddr = binary.BigEndian.Uint32(b[:]) } else { - resp.RelayFromAddr = netAddrToProtoAddr(from) + resp.RelayFromAddr = netAddrToProtoAddr(h.vpnAddrs[0]) resp.RelayToAddr = netAddrToProtoAddr(target) } msg, err := resp.Marshal() if err != nil { - rm.l.WithError(err).Error("relayManager Failed to marshal Control CreateRelayResponse message to create relay") + rm.l. + WithError(err).Error("relayManager Failed to marshal Control CreateRelayResponse message to create relay") } else { f.SendMessageToHostInfo(header.Control, 0, h, msg, make([]byte, 12), make([]byte, mtu)) rm.l.WithFields(logrus.Fields{ //TODO: IPV6-WORK more lazy, used to use resp object - "relayFrom": from, + "relayFrom": h.vpnAddrs[0], "relayTo": target, "initiatorRelayIndex": resp.InitiatorRelayIndex, "responderRelayIndex": resp.ResponderRelayIndex,