MCPcopy
hub / github.com/nats-io/nats.go / processExpectedInfo

Method processExpectedInfo

nats.go:2873–2903  ·  view source on GitHub ↗

processExpectedInfo will look for the expected first INFO message sent when a connection is established. The lock should be held entering.

()

Source from the content-addressed store, hash-verified

2871// processExpectedInfo will look for the expected first INFO message
2872// sent when a connection is established. The lock should be held entering.
2873func (nc *Conn) processExpectedInfo() error {
2874 c := &control{}
2875
2876 // Read the protocol
2877 err := nc.readOp(c)
2878 if err != nil {
2879 return err
2880 }
2881
2882 // The nats protocol should send INFO first always.
2883 if c.op != _INFO_OP_ {
2884 return ErrNoInfoReceived
2885 }
2886
2887 // Parse the protocol
2888 if err := nc.processInfo(c.args); err != nil {
2889 return err
2890 }
2891
2892 if nc.Opts.Nkey != "" && nc.info.Nonce == "" {
2893 return ErrNkeysNotSupported
2894 }
2895
2896 // For websocket connections, we already switched to TLS if need be,
2897 // so we are done here.
2898 if nc.ws {
2899 return nil
2900 }
2901
2902 return nc.checkForSecure()
2903}
2904
2905// Sends a protocol control message by queuing into the bufio writer
2906// and kicking the flush Go routine. These writes are protected.

Callers 1

processConnectInitMethod · 0.95

Calls 3

readOpMethod · 0.95
processInfoMethod · 0.95
checkForSecureMethod · 0.95

Tested by

no test coverage detected