18
18
)
19
19
20
20
const (
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/
22
22
)
23
23
24
24
type Export struct {
@@ -36,12 +36,14 @@ type Options struct {
36
36
MaximumBlockSize uint32
37
37
38
38
MaximumRequestSize int
39
+ SupportsMultiConn bool
39
40
}
40
41
41
42
func Handle (conn net.Conn , exports []* Export , options * Options ) error {
42
43
if options == nil {
43
44
options = & Options {
44
- ReadOnly : false ,
45
+ ReadOnly : false ,
46
+ SupportsMultiConn : true ,
45
47
}
46
48
}
47
49
@@ -54,11 +56,11 @@ func Handle(conn net.Conn, exports []*Export, options *Options) error {
54
56
}
55
57
56
58
if options .MaximumBlockSize == 0 {
57
- options .MaximumBlockSize = DefaultMaximumRequestSize
59
+ options .MaximumBlockSize = defaultMaximumRequestSize
58
60
}
59
61
60
62
if options .MaximumRequestSize == 0 {
61
- options .MaximumRequestSize = DefaultMaximumRequestSize
63
+ options .MaximumRequestSize = defaultMaximumRequestSize
62
64
}
63
65
64
66
// Negotiation
145
147
}
146
148
147
149
{
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
+
148
155
info := & bytes.Buffer {}
149
156
if err := binary .Write (info , binary .BigEndian , protocol.NegotiationReplyInfo {
150
157
Type : protocol .NEGOTIATION_TYPE_INFO_EXPORT ,
151
158
Size : uint64 (size ),
152
- TransmissionFlags : 0 ,
159
+ TransmissionFlags : transmissionFlags ,
153
160
}); err != nil {
154
161
return err
155
162
}
335
342
}
336
343
337
344
length := requestHeader .Length
338
- if length > DefaultMaximumRequestSize {
345
+ if length > defaultMaximumRequestSize {
339
346
return ErrInvalidRequestSize
340
347
}
341
348
0 commit comments