1 Star 0 Fork 0

leminewx/polarisprotocol

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
metadata.go 831 Bytes
Copy Edit Raw Blame History
wenxian authored 2024-01-12 17:14 +08:00 . 优化协议
package connection
import (
"net"
"strings"
"gitee.com/leminewx/polarisprotocol/v1/protocol"
)
type metadata struct {
LocalIp string // 本端IP
RemoteIp string // 对端IP
LocalAddr string // 本端地址
RemoteAddr string // 对端地址
LocalIdentity protocol.Identity // 本端身份
RemoteIdentity protocol.Identity // 对端身份
}
func newMetadata(conn net.Conn, localIdentity, remoteIdentity protocol.Identity) *metadata {
return &metadata{
LocalIp: strings.Split(conn.LocalAddr().String(), ":")[0],
RemoteIp: strings.Split(conn.RemoteAddr().String(), ":")[0],
LocalAddr: conn.LocalAddr().String(),
RemoteAddr: conn.RemoteAddr().String(),
LocalIdentity: localIdentity,
RemoteIdentity: remoteIdentity,
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/leminewx/polarisprotocol.git
git@gitee.com:leminewx/polarisprotocol.git
leminewx
polarisprotocol
polarisprotocol
edd3e93176c7

Search