MCPcopy Index your code
hub / github.com/google/seesaw / serve

Method serve

engine/sync.go:267–298  ·  view source on GitHub ↗

serve accepts connections from the given TCP listener and dispatches each connection to the RPC server. Connections are only accepted from localhost and the seesaw node that we are configured to peer with.

(l *net.TCPListener)

Source from the content-addressed store, hash-verified

265// connection to the RPC server. Connections are only accepted from localhost
266// and the seesaw node that we are configured to peer with.
267func (s *syncServer) serve(l *net.TCPListener) error {
268 defer l.Close()
269
270 s.server = rpc.NewServer()
271 s.server.Register(&SeesawSync{s})
272
273 for {
274 c, err := l.AcceptTCP()
275 if err != nil {
276 if ne, ok := err.(net.Error); ok && ne.Temporary() {
277 time.Sleep(100 * time.Millisecond)
278 continue
279 }
280 return err
281 }
282 raddr := c.RemoteAddr().String()
283 host, _, err := net.SplitHostPort(raddr)
284 if err != nil {
285 log.Errorf("Failed to parse remote address %q: %v", raddr, err)
286 c.Close()
287 continue
288 }
289 rip := net.ParseIP(host)
290 if rip == nil || (!rip.IsLoopback() && !rip.Equal(s.engine.config.Peer.IPv4Addr) && !rip.Equal(s.engine.config.Peer.IPv6Addr)) {
291 log.Warningf("Rejecting connection from non-peer (%s)...", rip)
292 c.Close()
293 continue
294 }
295 log.Infof("Sync connection established from %s", rip)
296 go s.server.ServeConn(c)
297 }
298}
299
300// notify queues a synchronisation notification with each of the active
301// synchronisation sessions.

Callers 2

syncRPCMethod · 0.80
newSyncTestFunction · 0.80

Calls 4

RegisterMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.65
EqualMethod · 0.45

Tested by 1

newSyncTestFunction · 0.64