MCPcopy
hub / github.com/syncthing/syncthing / newRawConnection

Function newRawConnection

lib/protocol/protocol.go:242–267  ·  view source on GitHub ↗
(deviceID DeviceID, reader io.Reader, writer io.Writer, closer io.Closer, receiver rawModel, connInfo ConnectionInfo, compress Compression)

Source from the content-addressed store, hash-verified

240}
241
242func newRawConnection(deviceID DeviceID, reader io.Reader, writer io.Writer, closer io.Closer, receiver rawModel, connInfo ConnectionInfo, compress Compression) *rawConnection {
243 idString := deviceID.String()
244 cr := &countingReader{Reader: reader, idString: idString}
245 cw := &countingWriter{Writer: writer, idString: idString}
246 registerDeviceMetrics(idString)
247
248 return &rawConnection{
249 ConnectionInfo: connInfo,
250 deviceID: deviceID,
251 idString: deviceID.String(),
252 model: receiver,
253 started: make(chan struct{}),
254 cr: cr,
255 cw: cw,
256 closer: closer,
257 awaiting: make(map[int]chan asyncResult),
258 inbox: make(chan proto.Message),
259 outbox: make(chan asyncMessage),
260 closeBox: make(chan asyncMessage),
261 clusterConfigBox: make(chan *ClusterConfig),
262 dispatcherLoopStopped: make(chan struct{}),
263 closed: make(chan struct{}),
264 compression: compress,
265 loopWG: sync.WaitGroup{},
266 }
267}
268
269// Start creates the goroutines for sending and receiving of messages. It must
270// be called once after creating a connection. It should only be called once,

Callers 1

NewConnectionFunction · 0.85

Calls 2

registerDeviceMetricsFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected