MCPcopy Index your code
hub / github.com/syncthing/syncthing / newMessage

Function newMessage

lib/protocol/protocol.go:896–917  ·  view source on GitHub ↗
(t bep.MessageType)

Source from the content-addressed store, hash-verified

894}
895
896func newMessage(t bep.MessageType) (proto.Message, error) {
897 switch t {
898 case bep.MessageType_MESSAGE_TYPE_CLUSTER_CONFIG:
899 return new(bep.ClusterConfig), nil
900 case bep.MessageType_MESSAGE_TYPE_INDEX:
901 return new(bep.Index), nil
902 case bep.MessageType_MESSAGE_TYPE_INDEX_UPDATE:
903 return new(bep.IndexUpdate), nil
904 case bep.MessageType_MESSAGE_TYPE_REQUEST:
905 return new(bep.Request), nil
906 case bep.MessageType_MESSAGE_TYPE_RESPONSE:
907 return new(bep.Response), nil
908 case bep.MessageType_MESSAGE_TYPE_DOWNLOAD_PROGRESS:
909 return new(bep.DownloadProgress), nil
910 case bep.MessageType_MESSAGE_TYPE_PING:
911 return new(bep.Ping), nil
912 case bep.MessageType_MESSAGE_TYPE_CLOSE:
913 return new(bep.Close), nil
914 default:
915 return nil, errUnknownMessage
916 }
917}
918
919func (c *rawConnection) shouldCompressMessage(msg proto.Message) bool {
920 switch c.compression {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected