MCPcopy Create free account
hub / github.com/DoNewsCode/core / peerInfo

Function peerInfo

otmongo/hook.go:87–99  ·  view source on GitHub ↗
(evt *event.CommandStartedEvent)

Source from the content-addressed store, hash-verified

85}
86
87func peerInfo(evt *event.CommandStartedEvent) (hostname string, port uint16) {
88 hostname = evt.ConnectionID
89 strPort := "27017"
90 if idx := strings.IndexByte(hostname, '['); idx >= 0 {
91 hostname = hostname[:idx]
92 }
93 if idx := strings.IndexByte(hostname, ':'); idx >= 0 {
94 strPort = hostname[idx+1:]
95 hostname = hostname[:idx]
96 }
97 uintPort, _ := strconv.ParseUint(strPort, 10, 32)
98 return hostname, uint16(uintPort)
99}

Callers 1

StartedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected