1818)
1919
2020const (
21- DefaultMaximumRequestSize = 32 * 1024 * 1024 // Support for a 32M maximum packet size is expected: https://sourceforge.net/p/nbd/mailman/message/35081223/
21+ defaultMaximumRequestSize = 32 * 1024 * 1024 // Support for a 32M maximum packet size is expected: https://sourceforge.net/p/nbd/mailman/message/35081223/
2222)
2323
2424type Export struct {
@@ -36,12 +36,14 @@ type Options struct {
3636 MaximumBlockSize uint32
3737
3838 MaximumRequestSize int
39+ SupportsMultiConn bool
3940}
4041
4142func Handle (conn net.Conn , exports []* Export , options * Options ) error {
4243 if options == nil {
4344 options = & Options {
44- ReadOnly : false ,
45+ ReadOnly : false ,
46+ SupportsMultiConn : true ,
4547 }
4648 }
4749
@@ -54,11 +56,11 @@ func Handle(conn net.Conn, exports []*Export, options *Options) error {
5456 }
5557
5658 if options .MaximumBlockSize == 0 {
57- options .MaximumBlockSize = DefaultMaximumRequestSize
59+ options .MaximumBlockSize = defaultMaximumRequestSize
5860 }
5961
6062 if options .MaximumRequestSize == 0 {
61- options .MaximumRequestSize = DefaultMaximumRequestSize
63+ options .MaximumRequestSize = defaultMaximumRequestSize
6264 }
6365
6466 // Negotiation
145147 }
146148
147149 {
150+ transmissionFlags := uint16 (0 )
151+ if options .SupportsMultiConn {
152+ transmissionFlags = protocol .NEGOTIATION_REPLY_FLAGS_HAS_FLAGS | protocol .NEGOTIATION_REPLY_FLAGS_CAN_MULTI_CONN
153+ }
154+
148155 info := & bytes.Buffer {}
149156 if err := binary .Write (info , binary .BigEndian , protocol.NegotiationReplyInfo {
150157 Type : protocol .NEGOTIATION_TYPE_INFO_EXPORT ,
151158 Size : uint64 (size ),
152- TransmissionFlags : 0 ,
159+ TransmissionFlags : transmissionFlags ,
153160 }); err != nil {
154161 return err
155162 }
335342 }
336343
337344 length := requestHeader .Length
338- if length > DefaultMaximumRequestSize {
345+ if length > defaultMaximumRequestSize {
339346 return ErrInvalidRequestSize
340347 }
341348
0 commit comments