mirror of https://github.com/longhorn/types.git
feat: support v2 cloning
longhorn-7794 Signed-off-by: Phan Le <phan.le@suse.com>
This commit is contained in:
parent
bee68b0a4c
commit
e6646a4307
|
|
@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
|
|||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12imrpc/common.proto\x12\x05imrpc*$\n\x12\x42\x61\x63kendStoreDriver\x12\x06\n\x02v1\x10\x00\x12\x06\n\x02v2\x10\x01*4\n\nDataEngine\x12\x12\n\x0e\x44\x41TA_ENGINE_V1\x10\x00\x12\x12\n\x0e\x44\x41TA_ENGINE_V2\x10\x01\x42/Z-github.com/longhorn/types/pkg/generated/imrpcb\x06proto3')
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12imrpc/common.proto\x12\x05imrpc*$\n\x12\x42\x61\x63kendStoreDriver\x12\x06\n\x02v1\x10\x00\x12\x06\n\x02v2\x10\x01*4\n\nDataEngine\x12\x12\n\x0e\x44\x41TA_ENGINE_V1\x10\x00\x12\x12\n\x0e\x44\x41TA_ENGINE_V2\x10\x01*E\n\tCloneMode\x12\x18\n\x14\x43LONE_MODE_FULL_COPY\x10\x00\x12\x1e\n\x1a\x43LONE_MODE_SNAPSHOT_LINKED\x10\x01\x42/Z-github.com/longhorn/types/pkg/generated/imrpcb\x06proto3')
|
||||
|
||||
_globals = globals()
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
||||
|
|
@ -26,4 +26,6 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|||
_globals['_BACKENDSTOREDRIVER']._serialized_end=65
|
||||
_globals['_DATAENGINE']._serialized_start=67
|
||||
_globals['_DATAENGINE']._serialized_end=119
|
||||
_globals['_CLONEMODE']._serialized_start=121
|
||||
_globals['_CLONEMODE']._serialized_end=190
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -160,6 +160,31 @@ class SPDKServiceStub(object):
|
|||
request_serializer=spdkrpc_dot_spdk__pb2.ReplicaRestoreStatusRequest.SerializeToString,
|
||||
response_deserializer=spdkrpc_dot_spdk__pb2.ReplicaRestoreStatusResponse.FromString,
|
||||
)
|
||||
self.ReplicaSnapshotCloneDstStart = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/ReplicaSnapshotCloneDstStart',
|
||||
request_serializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStartRequest.SerializeToString,
|
||||
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
)
|
||||
self.ReplicaSnapshotCloneDstStatusCheck = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/ReplicaSnapshotCloneDstStatusCheck',
|
||||
request_serializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStatusCheckRequest.SerializeToString,
|
||||
response_deserializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStatusCheckResponse.FromString,
|
||||
)
|
||||
self.ReplicaSnapshotCloneSrcStart = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcStart',
|
||||
request_serializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStartRequest.SerializeToString,
|
||||
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
)
|
||||
self.ReplicaSnapshotCloneSrcStatusCheck = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcStatusCheck',
|
||||
request_serializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStatusCheckRequest.SerializeToString,
|
||||
response_deserializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStatusCheckResponse.FromString,
|
||||
)
|
||||
self.ReplicaSnapshotCloneSrcFinish = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcFinish',
|
||||
request_serializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcFinishRequest.SerializeToString,
|
||||
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
)
|
||||
self.EngineCreate = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/EngineCreate',
|
||||
request_serializer=spdkrpc_dot_spdk__pb2.EngineCreateRequest.SerializeToString,
|
||||
|
|
@ -235,6 +260,11 @@ class SPDKServiceStub(object):
|
|||
request_serializer=spdkrpc_dot_spdk__pb2.SnapshotHashLockStateRequest.SerializeToString,
|
||||
response_deserializer=spdkrpc_dot_spdk__pb2.SnapshotHashLockStateResponse.FromString,
|
||||
)
|
||||
self.EngineSnapshotClone = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/EngineSnapshotClone',
|
||||
request_serializer=spdkrpc_dot_spdk__pb2.EngineSnapshotCloneRequest.SerializeToString,
|
||||
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
)
|
||||
self.EngineList = channel.unary_unary(
|
||||
'/spdkrpc.SPDKService/EngineList',
|
||||
request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
|
||||
|
|
@ -544,6 +574,36 @@ class SPDKServiceServicer(object):
|
|||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReplicaSnapshotCloneDstStart(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReplicaSnapshotCloneDstStatusCheck(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReplicaSnapshotCloneSrcStart(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReplicaSnapshotCloneSrcStatusCheck(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReplicaSnapshotCloneSrcFinish(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def EngineCreate(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
|
|
@ -634,6 +694,12 @@ class SPDKServiceServicer(object):
|
|||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def EngineSnapshotClone(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def EngineList(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
|
|
@ -938,6 +1004,31 @@ def add_SPDKServiceServicer_to_server(servicer, server):
|
|||
request_deserializer=spdkrpc_dot_spdk__pb2.ReplicaRestoreStatusRequest.FromString,
|
||||
response_serializer=spdkrpc_dot_spdk__pb2.ReplicaRestoreStatusResponse.SerializeToString,
|
||||
),
|
||||
'ReplicaSnapshotCloneDstStart': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ReplicaSnapshotCloneDstStart,
|
||||
request_deserializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStartRequest.FromString,
|
||||
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'ReplicaSnapshotCloneDstStatusCheck': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ReplicaSnapshotCloneDstStatusCheck,
|
||||
request_deserializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStatusCheckRequest.FromString,
|
||||
response_serializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStatusCheckResponse.SerializeToString,
|
||||
),
|
||||
'ReplicaSnapshotCloneSrcStart': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ReplicaSnapshotCloneSrcStart,
|
||||
request_deserializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStartRequest.FromString,
|
||||
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'ReplicaSnapshotCloneSrcStatusCheck': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ReplicaSnapshotCloneSrcStatusCheck,
|
||||
request_deserializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStatusCheckRequest.FromString,
|
||||
response_serializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStatusCheckResponse.SerializeToString,
|
||||
),
|
||||
'ReplicaSnapshotCloneSrcFinish': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ReplicaSnapshotCloneSrcFinish,
|
||||
request_deserializer=spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcFinishRequest.FromString,
|
||||
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'EngineCreate': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.EngineCreate,
|
||||
request_deserializer=spdkrpc_dot_spdk__pb2.EngineCreateRequest.FromString,
|
||||
|
|
@ -1013,6 +1104,11 @@ def add_SPDKServiceServicer_to_server(servicer, server):
|
|||
request_deserializer=spdkrpc_dot_spdk__pb2.SnapshotHashLockStateRequest.FromString,
|
||||
response_serializer=spdkrpc_dot_spdk__pb2.SnapshotHashLockStateResponse.SerializeToString,
|
||||
),
|
||||
'EngineSnapshotClone': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.EngineSnapshotClone,
|
||||
request_deserializer=spdkrpc_dot_spdk__pb2.EngineSnapshotCloneRequest.FromString,
|
||||
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'EngineList': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.EngineList,
|
||||
request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
|
|
@ -1646,6 +1742,91 @@ class SPDKService(object):
|
|||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def ReplicaSnapshotCloneDstStart(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/spdkrpc.SPDKService/ReplicaSnapshotCloneDstStart',
|
||||
spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStartRequest.SerializeToString,
|
||||
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def ReplicaSnapshotCloneDstStatusCheck(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/spdkrpc.SPDKService/ReplicaSnapshotCloneDstStatusCheck',
|
||||
spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStatusCheckRequest.SerializeToString,
|
||||
spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneDstStatusCheckResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def ReplicaSnapshotCloneSrcStart(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcStart',
|
||||
spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStartRequest.SerializeToString,
|
||||
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def ReplicaSnapshotCloneSrcStatusCheck(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcStatusCheck',
|
||||
spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStatusCheckRequest.SerializeToString,
|
||||
spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcStatusCheckResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def ReplicaSnapshotCloneSrcFinish(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcFinish',
|
||||
spdkrpc_dot_spdk__pb2.ReplicaSnapshotCloneSrcFinishRequest.SerializeToString,
|
||||
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def EngineCreate(request,
|
||||
target,
|
||||
|
|
@ -1901,6 +2082,23 @@ class SPDKService(object):
|
|||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def EngineSnapshotClone(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/spdkrpc.SPDKService/EngineSnapshotClone',
|
||||
spdkrpc_dot_spdk__pb2.EngineSnapshotCloneRequest.SerializeToString,
|
||||
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def EngineList(request,
|
||||
target,
|
||||
|
|
|
|||
12
go.mod
12
go.mod
|
|
@ -1,6 +1,8 @@
|
|||
module github.com/longhorn/types
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.24.4
|
||||
|
||||
require (
|
||||
google.golang.org/grpc v1.74.2
|
||||
|
|
@ -8,8 +10,8 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/text v0.19.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
|
||||
)
|
||||
|
|
|
|||
46
go.sum
46
go.sum
|
|
@ -1,16 +1,34 @@
|
|||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0=
|
||||
google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
|
||||
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
|
||||
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
|
||||
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
|
||||
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
|
||||
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
|
||||
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
|
||||
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a h1:v2PbRU4K3llS09c7zodFpNePeamkAwG3mPrAery9VeE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
|
||||
google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM=
|
||||
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
|
||||
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
|
|
|
|||
|
|
@ -113,6 +113,54 @@ func (DataEngine) EnumDescriptor() ([]byte, []int) {
|
|||
return file_imrpc_common_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
type CloneMode int32
|
||||
|
||||
const (
|
||||
// Full copy; new volume is independent of the source.
|
||||
CloneMode_CLONE_MODE_FULL_COPY CloneMode = 0 // aka "full-copy"
|
||||
// Snapshot-based; fast and space-efficient but depends on the source.
|
||||
CloneMode_CLONE_MODE_SNAPSHOT_LINKED CloneMode = 1 // aka "linked-clone"
|
||||
)
|
||||
|
||||
// Enum value maps for CloneMode.
|
||||
var (
|
||||
CloneMode_name = map[int32]string{
|
||||
0: "CLONE_MODE_FULL_COPY",
|
||||
1: "CLONE_MODE_SNAPSHOT_LINKED",
|
||||
}
|
||||
CloneMode_value = map[string]int32{
|
||||
"CLONE_MODE_FULL_COPY": 0,
|
||||
"CLONE_MODE_SNAPSHOT_LINKED": 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (x CloneMode) Enum() *CloneMode {
|
||||
p := new(CloneMode)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x CloneMode) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (CloneMode) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_imrpc_common_proto_enumTypes[2].Descriptor()
|
||||
}
|
||||
|
||||
func (CloneMode) Type() protoreflect.EnumType {
|
||||
return &file_imrpc_common_proto_enumTypes[2]
|
||||
}
|
||||
|
||||
func (x CloneMode) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CloneMode.Descriptor instead.
|
||||
func (CloneMode) EnumDescriptor() ([]byte, []int) {
|
||||
return file_imrpc_common_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
var File_imrpc_common_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_imrpc_common_proto_rawDesc = []byte{
|
||||
|
|
@ -123,10 +171,15 @@ var file_imrpc_common_proto_rawDesc = []byte{
|
|||
0x01, 0x2a, 0x34, 0x0a, 0x0a, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x12,
|
||||
0x12, 0x0a, 0x0e, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x45, 0x4e, 0x47, 0x49, 0x4e, 0x45, 0x5f, 0x56,
|
||||
0x31, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x45, 0x4e, 0x47, 0x49,
|
||||
0x4e, 0x45, 0x5f, 0x56, 0x32, 0x10, 0x01, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x6f, 0x6e, 0x67, 0x68, 0x6f, 0x72, 0x6e, 0x2f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74,
|
||||
0x65, 0x64, 0x2f, 0x69, 0x6d, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x4e, 0x45, 0x5f, 0x56, 0x32, 0x10, 0x01, 0x2a, 0x45, 0x0a, 0x09, 0x43, 0x6c, 0x6f, 0x6e, 0x65,
|
||||
0x4d, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4c, 0x4f, 0x4e, 0x45, 0x5f, 0x4d, 0x4f,
|
||||
0x44, 0x45, 0x5f, 0x46, 0x55, 0x4c, 0x4c, 0x5f, 0x43, 0x4f, 0x50, 0x59, 0x10, 0x00, 0x12, 0x1e,
|
||||
0x0a, 0x1a, 0x43, 0x4c, 0x4f, 0x4e, 0x45, 0x5f, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x4e, 0x41,
|
||||
0x50, 0x53, 0x48, 0x4f, 0x54, 0x5f, 0x4c, 0x49, 0x4e, 0x4b, 0x45, 0x44, 0x10, 0x01, 0x42, 0x2f,
|
||||
0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x6f, 0x6e,
|
||||
0x67, 0x68, 0x6f, 0x72, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x6b, 0x67, 0x2f,
|
||||
0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2f, 0x69, 0x6d, 0x72, 0x70, 0x63, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -141,10 +194,11 @@ func file_imrpc_common_proto_rawDescGZIP() []byte {
|
|||
return file_imrpc_common_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_imrpc_common_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_imrpc_common_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
|
||||
var file_imrpc_common_proto_goTypes = []interface{}{
|
||||
(BackendStoreDriver)(0), // 0: imrpc.BackendStoreDriver
|
||||
(DataEngine)(0), // 1: imrpc.DataEngine
|
||||
(CloneMode)(0), // 2: imrpc.CloneMode
|
||||
}
|
||||
var file_imrpc_common_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
|
|
@ -164,7 +218,7 @@ func file_imrpc_common_proto_init() {
|
|||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_imrpc_common_proto_rawDesc,
|
||||
NumEnums: 2,
|
||||
NumEnums: 3,
|
||||
NumMessages: 0,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -49,6 +49,11 @@ const (
|
|||
SPDKService_ReplicaBackupStatus_FullMethodName = "/spdkrpc.SPDKService/ReplicaBackupStatus"
|
||||
SPDKService_ReplicaBackupRestore_FullMethodName = "/spdkrpc.SPDKService/ReplicaBackupRestore"
|
||||
SPDKService_ReplicaRestoreStatus_FullMethodName = "/spdkrpc.SPDKService/ReplicaRestoreStatus"
|
||||
SPDKService_ReplicaSnapshotCloneDstStart_FullMethodName = "/spdkrpc.SPDKService/ReplicaSnapshotCloneDstStart"
|
||||
SPDKService_ReplicaSnapshotCloneDstStatusCheck_FullMethodName = "/spdkrpc.SPDKService/ReplicaSnapshotCloneDstStatusCheck"
|
||||
SPDKService_ReplicaSnapshotCloneSrcStart_FullMethodName = "/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcStart"
|
||||
SPDKService_ReplicaSnapshotCloneSrcStatusCheck_FullMethodName = "/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcStatusCheck"
|
||||
SPDKService_ReplicaSnapshotCloneSrcFinish_FullMethodName = "/spdkrpc.SPDKService/ReplicaSnapshotCloneSrcFinish"
|
||||
SPDKService_EngineCreate_FullMethodName = "/spdkrpc.SPDKService/EngineCreate"
|
||||
SPDKService_EngineDelete_FullMethodName = "/spdkrpc.SPDKService/EngineDelete"
|
||||
SPDKService_EngineGet_FullMethodName = "/spdkrpc.SPDKService/EngineGet"
|
||||
|
|
@ -64,6 +69,7 @@ const (
|
|||
SPDKService_EngineSnapshotHashStatus_FullMethodName = "/spdkrpc.SPDKService/EngineSnapshotHashStatus"
|
||||
SPDKService_EngineSnapshotHashCancel_FullMethodName = "/spdkrpc.SPDKService/EngineSnapshotHashCancel"
|
||||
SPDKService_EngineSnapshotHashLockState_FullMethodName = "/spdkrpc.SPDKService/EngineSnapshotHashLockState"
|
||||
SPDKService_EngineSnapshotClone_FullMethodName = "/spdkrpc.SPDKService/EngineSnapshotClone"
|
||||
SPDKService_EngineList_FullMethodName = "/spdkrpc.SPDKService/EngineList"
|
||||
SPDKService_EngineWatch_FullMethodName = "/spdkrpc.SPDKService/EngineWatch"
|
||||
SPDKService_EngineReplicaList_FullMethodName = "/spdkrpc.SPDKService/EngineReplicaList"
|
||||
|
|
@ -125,6 +131,11 @@ type SPDKServiceClient interface {
|
|||
ReplicaBackupStatus(ctx context.Context, in *BackupStatusRequest, opts ...grpc.CallOption) (*BackupStatusResponse, error)
|
||||
ReplicaBackupRestore(ctx context.Context, in *ReplicaBackupRestoreRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
ReplicaRestoreStatus(ctx context.Context, in *ReplicaRestoreStatusRequest, opts ...grpc.CallOption) (*ReplicaRestoreStatusResponse, error)
|
||||
ReplicaSnapshotCloneDstStart(ctx context.Context, in *ReplicaSnapshotCloneDstStartRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
ReplicaSnapshotCloneDstStatusCheck(ctx context.Context, in *ReplicaSnapshotCloneDstStatusCheckRequest, opts ...grpc.CallOption) (*ReplicaSnapshotCloneDstStatusCheckResponse, error)
|
||||
ReplicaSnapshotCloneSrcStart(ctx context.Context, in *ReplicaSnapshotCloneSrcStartRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
ReplicaSnapshotCloneSrcStatusCheck(ctx context.Context, in *ReplicaSnapshotCloneSrcStatusCheckRequest, opts ...grpc.CallOption) (*ReplicaSnapshotCloneSrcStatusCheckResponse, error)
|
||||
ReplicaSnapshotCloneSrcFinish(ctx context.Context, in *ReplicaSnapshotCloneSrcFinishRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
EngineCreate(ctx context.Context, in *EngineCreateRequest, opts ...grpc.CallOption) (*Engine, error)
|
||||
EngineDelete(ctx context.Context, in *EngineDeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
EngineGet(ctx context.Context, in *EngineGetRequest, opts ...grpc.CallOption) (*Engine, error)
|
||||
|
|
@ -140,6 +151,7 @@ type SPDKServiceClient interface {
|
|||
EngineSnapshotHashStatus(ctx context.Context, in *SnapshotHashStatusRequest, opts ...grpc.CallOption) (*EngineSnapshotHashStatusResponse, error)
|
||||
EngineSnapshotHashCancel(ctx context.Context, in *SnapshotHashCancelRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
EngineSnapshotHashLockState(ctx context.Context, in *SnapshotHashLockStateRequest, opts ...grpc.CallOption) (*SnapshotHashLockStateResponse, error)
|
||||
EngineSnapshotClone(ctx context.Context, in *EngineSnapshotCloneRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
EngineList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*EngineListResponse, error)
|
||||
EngineWatch(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (SPDKService_EngineWatchClient, error)
|
||||
EngineReplicaList(ctx context.Context, in *EngineReplicaListRequest, opts ...grpc.CallOption) (*EngineReplicaListResponse, error)
|
||||
|
|
@ -460,6 +472,51 @@ func (c *sPDKServiceClient) ReplicaRestoreStatus(ctx context.Context, in *Replic
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) ReplicaSnapshotCloneDstStart(ctx context.Context, in *ReplicaSnapshotCloneDstStartRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SPDKService_ReplicaSnapshotCloneDstStart_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) ReplicaSnapshotCloneDstStatusCheck(ctx context.Context, in *ReplicaSnapshotCloneDstStatusCheckRequest, opts ...grpc.CallOption) (*ReplicaSnapshotCloneDstStatusCheckResponse, error) {
|
||||
out := new(ReplicaSnapshotCloneDstStatusCheckResponse)
|
||||
err := c.cc.Invoke(ctx, SPDKService_ReplicaSnapshotCloneDstStatusCheck_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) ReplicaSnapshotCloneSrcStart(ctx context.Context, in *ReplicaSnapshotCloneSrcStartRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SPDKService_ReplicaSnapshotCloneSrcStart_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) ReplicaSnapshotCloneSrcStatusCheck(ctx context.Context, in *ReplicaSnapshotCloneSrcStatusCheckRequest, opts ...grpc.CallOption) (*ReplicaSnapshotCloneSrcStatusCheckResponse, error) {
|
||||
out := new(ReplicaSnapshotCloneSrcStatusCheckResponse)
|
||||
err := c.cc.Invoke(ctx, SPDKService_ReplicaSnapshotCloneSrcStatusCheck_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) ReplicaSnapshotCloneSrcFinish(ctx context.Context, in *ReplicaSnapshotCloneSrcFinishRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SPDKService_ReplicaSnapshotCloneSrcFinish_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) EngineCreate(ctx context.Context, in *EngineCreateRequest, opts ...grpc.CallOption) (*Engine, error) {
|
||||
out := new(Engine)
|
||||
err := c.cc.Invoke(ctx, SPDKService_EngineCreate_FullMethodName, in, out, opts...)
|
||||
|
|
@ -595,6 +652,15 @@ func (c *sPDKServiceClient) EngineSnapshotHashLockState(ctx context.Context, in
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) EngineSnapshotClone(ctx context.Context, in *EngineSnapshotCloneRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SPDKService_EngineSnapshotClone_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sPDKServiceClient) EngineList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*EngineListResponse, error) {
|
||||
out := new(EngineListResponse)
|
||||
err := c.cc.Invoke(ctx, SPDKService_EngineList_FullMethodName, in, out, opts...)
|
||||
|
|
@ -908,6 +974,11 @@ type SPDKServiceServer interface {
|
|||
ReplicaBackupStatus(context.Context, *BackupStatusRequest) (*BackupStatusResponse, error)
|
||||
ReplicaBackupRestore(context.Context, *ReplicaBackupRestoreRequest) (*emptypb.Empty, error)
|
||||
ReplicaRestoreStatus(context.Context, *ReplicaRestoreStatusRequest) (*ReplicaRestoreStatusResponse, error)
|
||||
ReplicaSnapshotCloneDstStart(context.Context, *ReplicaSnapshotCloneDstStartRequest) (*emptypb.Empty, error)
|
||||
ReplicaSnapshotCloneDstStatusCheck(context.Context, *ReplicaSnapshotCloneDstStatusCheckRequest) (*ReplicaSnapshotCloneDstStatusCheckResponse, error)
|
||||
ReplicaSnapshotCloneSrcStart(context.Context, *ReplicaSnapshotCloneSrcStartRequest) (*emptypb.Empty, error)
|
||||
ReplicaSnapshotCloneSrcStatusCheck(context.Context, *ReplicaSnapshotCloneSrcStatusCheckRequest) (*ReplicaSnapshotCloneSrcStatusCheckResponse, error)
|
||||
ReplicaSnapshotCloneSrcFinish(context.Context, *ReplicaSnapshotCloneSrcFinishRequest) (*emptypb.Empty, error)
|
||||
EngineCreate(context.Context, *EngineCreateRequest) (*Engine, error)
|
||||
EngineDelete(context.Context, *EngineDeleteRequest) (*emptypb.Empty, error)
|
||||
EngineGet(context.Context, *EngineGetRequest) (*Engine, error)
|
||||
|
|
@ -923,6 +994,7 @@ type SPDKServiceServer interface {
|
|||
EngineSnapshotHashStatus(context.Context, *SnapshotHashStatusRequest) (*EngineSnapshotHashStatusResponse, error)
|
||||
EngineSnapshotHashCancel(context.Context, *SnapshotHashCancelRequest) (*emptypb.Empty, error)
|
||||
EngineSnapshotHashLockState(context.Context, *SnapshotHashLockStateRequest) (*SnapshotHashLockStateResponse, error)
|
||||
EngineSnapshotClone(context.Context, *EngineSnapshotCloneRequest) (*emptypb.Empty, error)
|
||||
EngineList(context.Context, *emptypb.Empty) (*EngineListResponse, error)
|
||||
EngineWatch(*emptypb.Empty, SPDKService_EngineWatchServer) error
|
||||
EngineReplicaList(context.Context, *EngineReplicaListRequest) (*EngineReplicaListResponse, error)
|
||||
|
|
@ -1043,6 +1115,21 @@ func (UnimplementedSPDKServiceServer) ReplicaBackupRestore(context.Context, *Rep
|
|||
func (UnimplementedSPDKServiceServer) ReplicaRestoreStatus(context.Context, *ReplicaRestoreStatusRequest) (*ReplicaRestoreStatusResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReplicaRestoreStatus not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) ReplicaSnapshotCloneDstStart(context.Context, *ReplicaSnapshotCloneDstStartRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReplicaSnapshotCloneDstStart not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) ReplicaSnapshotCloneDstStatusCheck(context.Context, *ReplicaSnapshotCloneDstStatusCheckRequest) (*ReplicaSnapshotCloneDstStatusCheckResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReplicaSnapshotCloneDstStatusCheck not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) ReplicaSnapshotCloneSrcStart(context.Context, *ReplicaSnapshotCloneSrcStartRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReplicaSnapshotCloneSrcStart not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) ReplicaSnapshotCloneSrcStatusCheck(context.Context, *ReplicaSnapshotCloneSrcStatusCheckRequest) (*ReplicaSnapshotCloneSrcStatusCheckResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReplicaSnapshotCloneSrcStatusCheck not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) ReplicaSnapshotCloneSrcFinish(context.Context, *ReplicaSnapshotCloneSrcFinishRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReplicaSnapshotCloneSrcFinish not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) EngineCreate(context.Context, *EngineCreateRequest) (*Engine, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EngineCreate not implemented")
|
||||
}
|
||||
|
|
@ -1088,6 +1175,9 @@ func (UnimplementedSPDKServiceServer) EngineSnapshotHashCancel(context.Context,
|
|||
func (UnimplementedSPDKServiceServer) EngineSnapshotHashLockState(context.Context, *SnapshotHashLockStateRequest) (*SnapshotHashLockStateResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EngineSnapshotHashLockState not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) EngineSnapshotClone(context.Context, *EngineSnapshotCloneRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EngineSnapshotClone not implemented")
|
||||
}
|
||||
func (UnimplementedSPDKServiceServer) EngineList(context.Context, *emptypb.Empty) (*EngineListResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EngineList not implemented")
|
||||
}
|
||||
|
|
@ -1704,6 +1794,96 @@ func _SPDKService_ReplicaRestoreStatus_Handler(srv interface{}, ctx context.Cont
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_ReplicaSnapshotCloneDstStart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReplicaSnapshotCloneDstStartRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneDstStart(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SPDKService_ReplicaSnapshotCloneDstStart_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneDstStart(ctx, req.(*ReplicaSnapshotCloneDstStartRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_ReplicaSnapshotCloneDstStatusCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReplicaSnapshotCloneDstStatusCheckRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneDstStatusCheck(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SPDKService_ReplicaSnapshotCloneDstStatusCheck_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneDstStatusCheck(ctx, req.(*ReplicaSnapshotCloneDstStatusCheckRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_ReplicaSnapshotCloneSrcStart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReplicaSnapshotCloneSrcStartRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneSrcStart(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SPDKService_ReplicaSnapshotCloneSrcStart_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneSrcStart(ctx, req.(*ReplicaSnapshotCloneSrcStartRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_ReplicaSnapshotCloneSrcStatusCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReplicaSnapshotCloneSrcStatusCheckRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneSrcStatusCheck(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SPDKService_ReplicaSnapshotCloneSrcStatusCheck_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneSrcStatusCheck(ctx, req.(*ReplicaSnapshotCloneSrcStatusCheckRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_ReplicaSnapshotCloneSrcFinish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReplicaSnapshotCloneSrcFinishRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneSrcFinish(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SPDKService_ReplicaSnapshotCloneSrcFinish_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SPDKServiceServer).ReplicaSnapshotCloneSrcFinish(ctx, req.(*ReplicaSnapshotCloneSrcFinishRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_EngineCreate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EngineCreateRequest)
|
||||
if err := dec(in); err != nil {
|
||||
|
|
@ -1974,6 +2154,24 @@ func _SPDKService_EngineSnapshotHashLockState_Handler(srv interface{}, ctx conte
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_EngineSnapshotClone_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EngineSnapshotCloneRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SPDKServiceServer).EngineSnapshotClone(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SPDKService_EngineSnapshotClone_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SPDKServiceServer).EngineSnapshotClone(ctx, req.(*EngineSnapshotCloneRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SPDKService_EngineList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(emptypb.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
|
|
@ -2567,6 +2765,26 @@ var SPDKService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "ReplicaRestoreStatus",
|
||||
Handler: _SPDKService_ReplicaRestoreStatus_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReplicaSnapshotCloneDstStart",
|
||||
Handler: _SPDKService_ReplicaSnapshotCloneDstStart_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReplicaSnapshotCloneDstStatusCheck",
|
||||
Handler: _SPDKService_ReplicaSnapshotCloneDstStatusCheck_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReplicaSnapshotCloneSrcStart",
|
||||
Handler: _SPDKService_ReplicaSnapshotCloneSrcStart_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReplicaSnapshotCloneSrcStatusCheck",
|
||||
Handler: _SPDKService_ReplicaSnapshotCloneSrcStatusCheck_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReplicaSnapshotCloneSrcFinish",
|
||||
Handler: _SPDKService_ReplicaSnapshotCloneSrcFinish_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "EngineCreate",
|
||||
Handler: _SPDKService_EngineCreate_Handler,
|
||||
|
|
@ -2627,6 +2845,10 @@ var SPDKService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "EngineSnapshotHashLockState",
|
||||
Handler: _SPDKService_EngineSnapshotHashLockState_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "EngineSnapshotClone",
|
||||
Handler: _SPDKService_EngineSnapshotClone_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "EngineList",
|
||||
Handler: _SPDKService_EngineList_Handler,
|
||||
|
|
|
|||
|
|
@ -14,3 +14,10 @@ enum DataEngine {
|
|||
DATA_ENGINE_V1 = 0;
|
||||
DATA_ENGINE_V2 = 1;
|
||||
}
|
||||
|
||||
enum CloneMode {
|
||||
// Full copy; new volume is independent of the source.
|
||||
CLONE_MODE_FULL_COPY = 0; // aka "full-copy"
|
||||
// Snapshot-based; fast and space-efficient but depends on the source.
|
||||
CLONE_MODE_SNAPSHOT_LINKED = 1; // aka "linked-clone"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,6 +154,11 @@ message EngineSnapshotCloneRequest {
|
|||
string from_engine_name = 6;
|
||||
string from_volume_name = 7;
|
||||
int64 grpc_timeout_seconds = 9;
|
||||
string src_replica_name = 10;
|
||||
string src_replica_address = 11;
|
||||
string dst_replica_name = 12;
|
||||
string dst_replica_address = 13;
|
||||
CloneMode clone_mode = 14;
|
||||
}
|
||||
|
||||
message EngineSnapshotCloneStatusProxyResponse {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package spdkrpc;
|
|||
option go_package = "github.com/longhorn/types/pkg/generated/spdkrpc";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "imrpc/common.proto";
|
||||
|
||||
service SPDKService {
|
||||
rpc ReplicaCreate(ReplicaCreateRequest) returns (Replica);
|
||||
|
|
@ -32,10 +33,15 @@ service SPDKService {
|
|||
rpc ReplicaRebuildingDstShallowCopyCheck(ReplicaRebuildingDstShallowCopyCheckRequest) returns (ReplicaRebuildingDstShallowCopyCheckResponse) {};
|
||||
rpc ReplicaRebuildingDstSnapshotCreate(SnapshotRequest) returns (google.protobuf.Empty);
|
||||
rpc ReplicaRebuildingDstSetQosLimit(ReplicaRebuildingDstSetQosLimitRequest) returns (google.protobuf.Empty);
|
||||
rpc ReplicaBackupCreate(BackupCreateRequest) returns (BackupCreateResponse) {}
|
||||
rpc ReplicaBackupStatus(BackupStatusRequest) returns (BackupStatusResponse) {}
|
||||
rpc ReplicaBackupRestore(ReplicaBackupRestoreRequest) returns (google.protobuf.Empty) {}
|
||||
rpc ReplicaRestoreStatus(ReplicaRestoreStatusRequest) returns (ReplicaRestoreStatusResponse) {}
|
||||
rpc ReplicaBackupCreate(BackupCreateRequest) returns (BackupCreateResponse) {};
|
||||
rpc ReplicaBackupStatus(BackupStatusRequest) returns (BackupStatusResponse) {};
|
||||
rpc ReplicaBackupRestore(ReplicaBackupRestoreRequest) returns (google.protobuf.Empty) {};
|
||||
rpc ReplicaRestoreStatus(ReplicaRestoreStatusRequest) returns (ReplicaRestoreStatusResponse) {};
|
||||
rpc ReplicaSnapshotCloneDstStart(ReplicaSnapshotCloneDstStartRequest) returns (google.protobuf.Empty){};
|
||||
rpc ReplicaSnapshotCloneDstStatusCheck(ReplicaSnapshotCloneDstStatusCheckRequest) returns (ReplicaSnapshotCloneDstStatusCheckResponse){};
|
||||
rpc ReplicaSnapshotCloneSrcStart(ReplicaSnapshotCloneSrcStartRequest) returns (google.protobuf.Empty){};
|
||||
rpc ReplicaSnapshotCloneSrcStatusCheck(ReplicaSnapshotCloneSrcStatusCheckRequest) returns (ReplicaSnapshotCloneSrcStatusCheckResponse){};
|
||||
rpc ReplicaSnapshotCloneSrcFinish(ReplicaSnapshotCloneSrcFinishRequest) returns (google.protobuf.Empty){};
|
||||
|
||||
rpc EngineCreate(EngineCreateRequest) returns (Engine);
|
||||
rpc EngineDelete(EngineDeleteRequest) returns (google.protobuf.Empty);
|
||||
|
|
@ -52,16 +58,17 @@ service SPDKService {
|
|||
rpc EngineSnapshotHashStatus(SnapshotHashStatusRequest) returns (EngineSnapshotHashStatusResponse) {};
|
||||
rpc EngineSnapshotHashCancel(SnapshotHashCancelRequest) returns (google.protobuf.Empty) {};
|
||||
rpc EngineSnapshotHashLockState(SnapshotHashLockStateRequest) returns (SnapshotHashLockStateResponse) {};
|
||||
rpc EngineSnapshotClone(EngineSnapshotCloneRequest) returns (google.protobuf.Empty) {};
|
||||
rpc EngineList(google.protobuf.Empty) returns (EngineListResponse);
|
||||
rpc EngineWatch(google.protobuf.Empty) returns (stream google.protobuf.Empty) {}
|
||||
rpc EngineReplicaList(EngineReplicaListRequest) returns (EngineReplicaListResponse) {}
|
||||
rpc EngineReplicaAdd(EngineReplicaAddRequest) returns (google.protobuf.Empty) {}
|
||||
rpc EngineReplicaDelete(EngineReplicaDeleteRequest) returns (google.protobuf.Empty) {}
|
||||
rpc EngineBackupCreate(BackupCreateRequest) returns (BackupCreateResponse) {}
|
||||
rpc EngineBackupStatus(BackupStatusRequest) returns (BackupStatusResponse) {}
|
||||
rpc EngineBackupRestore(EngineBackupRestoreRequest) returns (EngineBackupRestoreResponse) {}
|
||||
rpc EngineBackupRestoreFinish(EngineBackupRestoreFinishRequest) returns (google.protobuf.Empty) {} // Deprecated: retained for compatibility with v1.7.x and earlier versions.
|
||||
rpc EngineRestoreStatus(RestoreStatusRequest) returns (RestoreStatusResponse) {}
|
||||
rpc EngineWatch(google.protobuf.Empty) returns (stream google.protobuf.Empty) {};
|
||||
rpc EngineReplicaList(EngineReplicaListRequest) returns (EngineReplicaListResponse) {};
|
||||
rpc EngineReplicaAdd(EngineReplicaAddRequest) returns (google.protobuf.Empty) {};
|
||||
rpc EngineReplicaDelete(EngineReplicaDeleteRequest) returns (google.protobuf.Empty) {};
|
||||
rpc EngineBackupCreate(BackupCreateRequest) returns (BackupCreateResponse) {};
|
||||
rpc EngineBackupStatus(BackupStatusRequest) returns (BackupStatusResponse) {};
|
||||
rpc EngineBackupRestore(EngineBackupRestoreRequest) returns (EngineBackupRestoreResponse) {};
|
||||
rpc EngineBackupRestoreFinish(EngineBackupRestoreFinishRequest) returns (google.protobuf.Empty) {}; // Deprecated: retained for compatibility with v1.7.x and earlier versions.
|
||||
rpc EngineRestoreStatus(RestoreStatusRequest) returns (RestoreStatusResponse) {};
|
||||
|
||||
rpc BackingImageCreate(BackingImageCreateRequest) returns (BackingImage);
|
||||
rpc BackingImageDelete(BackingImageDeleteRequest) returns (google.protobuf.Empty);
|
||||
|
|
@ -230,6 +237,61 @@ message ReplicaRebuildingDstSetQosLimitRequest {
|
|||
int64 qos_limit_mbps = 2;
|
||||
}
|
||||
|
||||
message ReplicaSnapshotCloneDstStartRequest {
|
||||
string name = 1;
|
||||
string snapshot_name = 2;
|
||||
string src_replica_name = 3;
|
||||
string src_replica_address = 4;
|
||||
CloneMode clone_mode = 5;
|
||||
}
|
||||
|
||||
enum CloneMode {
|
||||
// Full copy; new volume is independent of the source.
|
||||
CLONE_MODE_FULL_COPY = 0; // aka "full-copy"
|
||||
// Snapshot-based; fast and space-efficient but depends on the source.
|
||||
CLONE_MODE_SNAPSHOT_LINKED = 1; // aka "linked-clone"
|
||||
}
|
||||
|
||||
message ReplicaSnapshotCloneDstStatusCheckRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message ReplicaSnapshotCloneDstStatusCheckResponse {
|
||||
bool is_cloning = 1;
|
||||
string src_replica_name = 2;
|
||||
string src_replica_address = 3;
|
||||
string snapshot_name = 4;
|
||||
string state = 5;
|
||||
uint32 progress = 6;
|
||||
string error = 7;
|
||||
}
|
||||
|
||||
message ReplicaSnapshotCloneSrcStartRequest {
|
||||
string name = 1;
|
||||
string snapshot_name = 2;
|
||||
string dst_replica_name = 3;
|
||||
string dst_cloning_lvol_address = 4;
|
||||
CloneMode clone_mode = 5;
|
||||
}
|
||||
|
||||
message ReplicaSnapshotCloneSrcStatusCheckRequest {
|
||||
string name = 1;
|
||||
string snapshot_name = 2;
|
||||
string dst_replica_name = 3;
|
||||
}
|
||||
|
||||
message ReplicaSnapshotCloneSrcStatusCheckResponse {
|
||||
string state = 1;
|
||||
uint64 processed_clusters = 2;
|
||||
uint64 total_clusters = 3;
|
||||
string error_msg = 4;
|
||||
}
|
||||
|
||||
message ReplicaSnapshotCloneSrcFinishRequest {
|
||||
string name = 1;
|
||||
string dst_replica_name = 2;
|
||||
}
|
||||
|
||||
message Engine {
|
||||
string name = 1;
|
||||
string volume_name = 2;
|
||||
|
|
@ -388,6 +450,16 @@ message SnapshotHashLockStateResponse {
|
|||
bool is_locked = 1;
|
||||
}
|
||||
|
||||
message EngineSnapshotCloneRequest {
|
||||
string name = 1;
|
||||
string snapshot_name = 2;
|
||||
string src_replica_name = 3;
|
||||
string src_replica_address = 4;
|
||||
string dst_replica_name = 5;
|
||||
string dst_replica_address = 6;
|
||||
CloneMode clone_mode = 7;
|
||||
}
|
||||
|
||||
message VersionOutput {
|
||||
string version = 1;
|
||||
string gitCommit = 2;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ package http2
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
|
@ -158,7 +158,7 @@ func (c *dialCall) dial(ctx context.Context, addr string) {
|
|||
// This code decides which ones live or die.
|
||||
// The return value used is whether c was used.
|
||||
// c is never closed.
|
||||
func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c *tls.Conn) (used bool, err error) {
|
||||
func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c net.Conn) (used bool, err error) {
|
||||
p.mu.Lock()
|
||||
for _, cc := range p.conns[key] {
|
||||
if cc.CanTakeNewRequest() {
|
||||
|
|
@ -194,8 +194,8 @@ type addConnCall struct {
|
|||
err error
|
||||
}
|
||||
|
||||
func (c *addConnCall) run(t *Transport, key string, tc *tls.Conn) {
|
||||
cc, err := t.NewClientConn(tc)
|
||||
func (c *addConnCall) run(t *Transport, key string, nc net.Conn) {
|
||||
cc, err := t.NewClientConn(nc)
|
||||
|
||||
p := c.p
|
||||
p.mu.Lock()
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func configFromServer(h1 *http.Server, h2 *Server) http2Config {
|
|||
return conf
|
||||
}
|
||||
|
||||
// configFromServer merges configuration settings from h2 and h2.t1.HTTP2
|
||||
// configFromTransport merges configuration settings from h2 and h2.t1.HTTP2
|
||||
// (the net/http Transport).
|
||||
func configFromTransport(h2 *Transport) http2Config {
|
||||
conf := http2Config{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ func fillNetHTTPServerConfig(conf *http2Config, srv *http.Server) {
|
|||
fillNetHTTPConfig(conf, srv.HTTP2)
|
||||
}
|
||||
|
||||
// fillNetHTTPServerConfig sets fields in conf from tr.HTTP2.
|
||||
// fillNetHTTPTransportConfig sets fields in conf from tr.HTTP2.
|
||||
func fillNetHTTPTransportConfig(conf *http2Config, tr *http.Transport) {
|
||||
fillNetHTTPConfig(conf, tr.HTTP2)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,6 +225,11 @@ var fhBytes = sync.Pool{
|
|||
},
|
||||
}
|
||||
|
||||
func invalidHTTP1LookingFrameHeader() FrameHeader {
|
||||
fh, _ := readFrameHeader(make([]byte, frameHeaderLen), strings.NewReader("HTTP/1.1 "))
|
||||
return fh
|
||||
}
|
||||
|
||||
// ReadFrameHeader reads 9 bytes from r and returns a FrameHeader.
|
||||
// Most users should use Framer.ReadFrame instead.
|
||||
func ReadFrameHeader(r io.Reader) (FrameHeader, error) {
|
||||
|
|
@ -503,10 +508,16 @@ func (fr *Framer) ReadFrame() (Frame, error) {
|
|||
return nil, err
|
||||
}
|
||||
if fh.Length > fr.maxReadSize {
|
||||
if fh == invalidHTTP1LookingFrameHeader() {
|
||||
return nil, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", err)
|
||||
}
|
||||
return nil, ErrFrameTooLarge
|
||||
}
|
||||
payload := fr.getReadBuf(fh.Length)
|
||||
if _, err := io.ReadFull(fr.r, payload); err != nil {
|
||||
if fh == invalidHTTP1LookingFrameHeader() {
|
||||
return nil, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
f, err := typeFrameParser(fh.Type)(fr.frameCache, fh, fr.countError, payload)
|
||||
|
|
@ -1490,7 +1501,7 @@ func (mh *MetaHeadersFrame) checkPseudos() error {
|
|||
pf := mh.PseudoFields()
|
||||
for i, hf := range pf {
|
||||
switch hf.Name {
|
||||
case ":method", ":path", ":scheme", ":authority":
|
||||
case ":method", ":path", ":scheme", ":authority", ":protocol":
|
||||
isRequest = true
|
||||
case ":status":
|
||||
isResponse = true
|
||||
|
|
@ -1498,7 +1509,7 @@ func (mh *MetaHeadersFrame) checkPseudos() error {
|
|||
return pseudoHeaderError(hf.Name)
|
||||
}
|
||||
// Check for duplicates.
|
||||
// This would be a bad algorithm, but N is 4.
|
||||
// This would be a bad algorithm, but N is 5.
|
||||
// And this doesn't allocate.
|
||||
for _, hf2 := range pf[:i] {
|
||||
if hf.Name == hf2.Name {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ var (
|
|||
logFrameWrites bool
|
||||
logFrameReads bool
|
||||
inTests bool
|
||||
|
||||
// Enabling extended CONNECT by causes browsers to attempt to use
|
||||
// WebSockets-over-HTTP/2. This results in problems when the server's websocket
|
||||
// package doesn't support extended CONNECT.
|
||||
//
|
||||
// Disable extended CONNECT by default for now.
|
||||
//
|
||||
// Issue #71128.
|
||||
disableExtendedConnectProtocol = true
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -50,6 +59,9 @@ func init() {
|
|||
logFrameWrites = true
|
||||
logFrameReads = true
|
||||
}
|
||||
if strings.Contains(e, "http2xconnect=1") {
|
||||
disableExtendedConnectProtocol = false
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -141,6 +153,10 @@ func (s Setting) Valid() error {
|
|||
if s.Val < 16384 || s.Val > 1<<24-1 {
|
||||
return ConnectionError(ErrCodeProtocol)
|
||||
}
|
||||
case SettingEnableConnectProtocol:
|
||||
if s.Val != 1 && s.Val != 0 {
|
||||
return ConnectionError(ErrCodeProtocol)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -150,21 +166,23 @@ func (s Setting) Valid() error {
|
|||
type SettingID uint16
|
||||
|
||||
const (
|
||||
SettingHeaderTableSize SettingID = 0x1
|
||||
SettingEnablePush SettingID = 0x2
|
||||
SettingMaxConcurrentStreams SettingID = 0x3
|
||||
SettingInitialWindowSize SettingID = 0x4
|
||||
SettingMaxFrameSize SettingID = 0x5
|
||||
SettingMaxHeaderListSize SettingID = 0x6
|
||||
SettingHeaderTableSize SettingID = 0x1
|
||||
SettingEnablePush SettingID = 0x2
|
||||
SettingMaxConcurrentStreams SettingID = 0x3
|
||||
SettingInitialWindowSize SettingID = 0x4
|
||||
SettingMaxFrameSize SettingID = 0x5
|
||||
SettingMaxHeaderListSize SettingID = 0x6
|
||||
SettingEnableConnectProtocol SettingID = 0x8
|
||||
)
|
||||
|
||||
var settingName = map[SettingID]string{
|
||||
SettingHeaderTableSize: "HEADER_TABLE_SIZE",
|
||||
SettingEnablePush: "ENABLE_PUSH",
|
||||
SettingMaxConcurrentStreams: "MAX_CONCURRENT_STREAMS",
|
||||
SettingInitialWindowSize: "INITIAL_WINDOW_SIZE",
|
||||
SettingMaxFrameSize: "MAX_FRAME_SIZE",
|
||||
SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE",
|
||||
SettingHeaderTableSize: "HEADER_TABLE_SIZE",
|
||||
SettingEnablePush: "ENABLE_PUSH",
|
||||
SettingMaxConcurrentStreams: "MAX_CONCURRENT_STREAMS",
|
||||
SettingInitialWindowSize: "INITIAL_WINDOW_SIZE",
|
||||
SettingMaxFrameSize: "MAX_FRAME_SIZE",
|
||||
SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE",
|
||||
SettingEnableConnectProtocol: "ENABLE_CONNECT_PROTOCOL",
|
||||
}
|
||||
|
||||
func (s SettingID) String() string {
|
||||
|
|
@ -397,23 +415,6 @@ func (s *sorter) SortStrings(ss []string) {
|
|||
s.v = save
|
||||
}
|
||||
|
||||
// validPseudoPath reports whether v is a valid :path pseudo-header
|
||||
// value. It must be either:
|
||||
//
|
||||
// - a non-empty string starting with '/'
|
||||
// - the string '*', for OPTIONS requests.
|
||||
//
|
||||
// For now this is only used a quick check for deciding when to clean
|
||||
// up Opaque URLs before sending requests from the Transport.
|
||||
// See golang.org/issue/16847
|
||||
//
|
||||
// We used to enforce that the path also didn't start with "//", but
|
||||
// Google's GFE accepts such paths and Chrome sends them, so ignore
|
||||
// that part of the spec. See golang.org/issue/19103.
|
||||
func validPseudoPath(v string) bool {
|
||||
return (len(v) > 0 && v[0] == '/') || v == "*"
|
||||
}
|
||||
|
||||
// incomparable is a zero-width, non-comparable type. Adding it to a struct
|
||||
// makes that struct also non-comparable, and generally doesn't add
|
||||
// any size (as long as it's first).
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import (
|
|||
|
||||
"golang.org/x/net/http/httpguts"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
"golang.org/x/net/internal/httpcommon"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -306,7 +307,7 @@ func ConfigureServer(s *http.Server, conf *Server) error {
|
|||
if s.TLSNextProto == nil {
|
||||
s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){}
|
||||
}
|
||||
protoHandler := func(hs *http.Server, c *tls.Conn, h http.Handler) {
|
||||
protoHandler := func(hs *http.Server, c net.Conn, h http.Handler, sawClientPreface bool) {
|
||||
if testHookOnConn != nil {
|
||||
testHookOnConn()
|
||||
}
|
||||
|
|
@ -323,12 +324,31 @@ func ConfigureServer(s *http.Server, conf *Server) error {
|
|||
ctx = bc.BaseContext()
|
||||
}
|
||||
conf.ServeConn(c, &ServeConnOpts{
|
||||
Context: ctx,
|
||||
Handler: h,
|
||||
BaseConfig: hs,
|
||||
Context: ctx,
|
||||
Handler: h,
|
||||
BaseConfig: hs,
|
||||
SawClientPreface: sawClientPreface,
|
||||
})
|
||||
}
|
||||
s.TLSNextProto[NextProtoTLS] = protoHandler
|
||||
s.TLSNextProto[NextProtoTLS] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
|
||||
protoHandler(hs, c, h, false)
|
||||
}
|
||||
// The "unencrypted_http2" TLSNextProto key is used to pass off non-TLS HTTP/2 conns.
|
||||
//
|
||||
// A connection passed in this method has already had the HTTP/2 preface read from it.
|
||||
s.TLSNextProto[nextProtoUnencryptedHTTP2] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
|
||||
nc, err := unencryptedNetConnFromTLSConn(c)
|
||||
if err != nil {
|
||||
if lg := hs.ErrorLog; lg != nil {
|
||||
lg.Print(err)
|
||||
} else {
|
||||
log.Print(err)
|
||||
}
|
||||
go c.Close()
|
||||
return
|
||||
}
|
||||
protoHandler(hs, nc, h, true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -793,8 +813,7 @@ const maxCachedCanonicalHeadersKeysSize = 2048
|
|||
|
||||
func (sc *serverConn) canonicalHeader(v string) string {
|
||||
sc.serveG.check()
|
||||
buildCommonHeaderMapsOnce()
|
||||
cv, ok := commonCanonHeader[v]
|
||||
cv, ok := httpcommon.CachedCanonicalHeader(v)
|
||||
if ok {
|
||||
return cv
|
||||
}
|
||||
|
|
@ -913,14 +932,18 @@ func (sc *serverConn) serve(conf http2Config) {
|
|||
sc.vlogf("http2: server connection from %v on %p", sc.conn.RemoteAddr(), sc.hs)
|
||||
}
|
||||
|
||||
settings := writeSettings{
|
||||
{SettingMaxFrameSize, conf.MaxReadFrameSize},
|
||||
{SettingMaxConcurrentStreams, sc.advMaxStreams},
|
||||
{SettingMaxHeaderListSize, sc.maxHeaderListSize()},
|
||||
{SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize},
|
||||
{SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)},
|
||||
}
|
||||
if !disableExtendedConnectProtocol {
|
||||
settings = append(settings, Setting{SettingEnableConnectProtocol, 1})
|
||||
}
|
||||
sc.writeFrame(FrameWriteRequest{
|
||||
write: writeSettings{
|
||||
{SettingMaxFrameSize, conf.MaxReadFrameSize},
|
||||
{SettingMaxConcurrentStreams, sc.advMaxStreams},
|
||||
{SettingMaxHeaderListSize, sc.maxHeaderListSize()},
|
||||
{SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize},
|
||||
{SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)},
|
||||
},
|
||||
write: settings,
|
||||
})
|
||||
sc.unackedSettings++
|
||||
|
||||
|
|
@ -1045,7 +1068,10 @@ func (sc *serverConn) serve(conf http2Config) {
|
|||
|
||||
func (sc *serverConn) handlePingTimer(lastFrameReadTime time.Time) {
|
||||
if sc.pingSent {
|
||||
sc.vlogf("timeout waiting for PING response")
|
||||
sc.logf("timeout waiting for PING response")
|
||||
if f := sc.countErrorFunc; f != nil {
|
||||
f("conn_close_lost_ping")
|
||||
}
|
||||
sc.conn.Close()
|
||||
return
|
||||
}
|
||||
|
|
@ -1782,6 +1808,9 @@ func (sc *serverConn) processSetting(s Setting) error {
|
|||
sc.maxFrameSize = int32(s.Val) // the maximum valid s.Val is < 2^31
|
||||
case SettingMaxHeaderListSize:
|
||||
sc.peerMaxHeaderListSize = s.Val
|
||||
case SettingEnableConnectProtocol:
|
||||
// Receipt of this parameter by a server does not
|
||||
// have any impact
|
||||
default:
|
||||
// Unknown setting: "An endpoint that receives a SETTINGS
|
||||
// frame with any unknown or unsupported identifier MUST
|
||||
|
|
@ -2207,19 +2236,25 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream
|
|||
func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*responseWriter, *http.Request, error) {
|
||||
sc.serveG.check()
|
||||
|
||||
rp := requestParam{
|
||||
method: f.PseudoValue("method"),
|
||||
scheme: f.PseudoValue("scheme"),
|
||||
authority: f.PseudoValue("authority"),
|
||||
path: f.PseudoValue("path"),
|
||||
rp := httpcommon.ServerRequestParam{
|
||||
Method: f.PseudoValue("method"),
|
||||
Scheme: f.PseudoValue("scheme"),
|
||||
Authority: f.PseudoValue("authority"),
|
||||
Path: f.PseudoValue("path"),
|
||||
Protocol: f.PseudoValue("protocol"),
|
||||
}
|
||||
|
||||
isConnect := rp.method == "CONNECT"
|
||||
// extended connect is disabled, so we should not see :protocol
|
||||
if disableExtendedConnectProtocol && rp.Protocol != "" {
|
||||
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
|
||||
}
|
||||
|
||||
isConnect := rp.Method == "CONNECT"
|
||||
if isConnect {
|
||||
if rp.path != "" || rp.scheme != "" || rp.authority == "" {
|
||||
if rp.Protocol == "" && (rp.Path != "" || rp.Scheme != "" || rp.Authority == "") {
|
||||
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
|
||||
}
|
||||
} else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") {
|
||||
} else if rp.Method == "" || rp.Path == "" || (rp.Scheme != "https" && rp.Scheme != "http") {
|
||||
// See 8.1.2.6 Malformed Requests and Responses:
|
||||
//
|
||||
// Malformed requests or responses that are detected
|
||||
|
|
@ -2233,12 +2268,16 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
|
|||
return nil, nil, sc.countError("bad_path_method", streamError(f.StreamID, ErrCodeProtocol))
|
||||
}
|
||||
|
||||
rp.header = make(http.Header)
|
||||
header := make(http.Header)
|
||||
rp.Header = header
|
||||
for _, hf := range f.RegularFields() {
|
||||
rp.header.Add(sc.canonicalHeader(hf.Name), hf.Value)
|
||||
header.Add(sc.canonicalHeader(hf.Name), hf.Value)
|
||||
}
|
||||
if rp.authority == "" {
|
||||
rp.authority = rp.header.Get("Host")
|
||||
if rp.Authority == "" {
|
||||
rp.Authority = header.Get("Host")
|
||||
}
|
||||
if rp.Protocol != "" {
|
||||
header.Set(":protocol", rp.Protocol)
|
||||
}
|
||||
|
||||
rw, req, err := sc.newWriterAndRequestNoBody(st, rp)
|
||||
|
|
@ -2247,7 +2286,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
|
|||
}
|
||||
bodyOpen := !f.StreamEnded()
|
||||
if bodyOpen {
|
||||
if vv, ok := rp.header["Content-Length"]; ok {
|
||||
if vv, ok := rp.Header["Content-Length"]; ok {
|
||||
if cl, err := strconv.ParseUint(vv[0], 10, 63); err == nil {
|
||||
req.ContentLength = int64(cl)
|
||||
} else {
|
||||
|
|
@ -2263,83 +2302,38 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
|
|||
return rw, req, nil
|
||||
}
|
||||
|
||||
type requestParam struct {
|
||||
method string
|
||||
scheme, authority, path string
|
||||
header http.Header
|
||||
}
|
||||
|
||||
func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*responseWriter, *http.Request, error) {
|
||||
func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp httpcommon.ServerRequestParam) (*responseWriter, *http.Request, error) {
|
||||
sc.serveG.check()
|
||||
|
||||
var tlsState *tls.ConnectionState // nil if not scheme https
|
||||
if rp.scheme == "https" {
|
||||
if rp.Scheme == "https" {
|
||||
tlsState = sc.tlsState
|
||||
}
|
||||
|
||||
needsContinue := httpguts.HeaderValuesContainsToken(rp.header["Expect"], "100-continue")
|
||||
if needsContinue {
|
||||
rp.header.Del("Expect")
|
||||
}
|
||||
// Merge Cookie headers into one "; "-delimited value.
|
||||
if cookies := rp.header["Cookie"]; len(cookies) > 1 {
|
||||
rp.header.Set("Cookie", strings.Join(cookies, "; "))
|
||||
}
|
||||
|
||||
// Setup Trailers
|
||||
var trailer http.Header
|
||||
for _, v := range rp.header["Trailer"] {
|
||||
for _, key := range strings.Split(v, ",") {
|
||||
key = http.CanonicalHeaderKey(textproto.TrimString(key))
|
||||
switch key {
|
||||
case "Transfer-Encoding", "Trailer", "Content-Length":
|
||||
// Bogus. (copy of http1 rules)
|
||||
// Ignore.
|
||||
default:
|
||||
if trailer == nil {
|
||||
trailer = make(http.Header)
|
||||
}
|
||||
trailer[key] = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
delete(rp.header, "Trailer")
|
||||
|
||||
var url_ *url.URL
|
||||
var requestURI string
|
||||
if rp.method == "CONNECT" {
|
||||
url_ = &url.URL{Host: rp.authority}
|
||||
requestURI = rp.authority // mimic HTTP/1 server behavior
|
||||
} else {
|
||||
var err error
|
||||
url_, err = url.ParseRequestURI(rp.path)
|
||||
if err != nil {
|
||||
return nil, nil, sc.countError("bad_path", streamError(st.id, ErrCodeProtocol))
|
||||
}
|
||||
requestURI = rp.path
|
||||
res := httpcommon.NewServerRequest(rp)
|
||||
if res.InvalidReason != "" {
|
||||
return nil, nil, sc.countError(res.InvalidReason, streamError(st.id, ErrCodeProtocol))
|
||||
}
|
||||
|
||||
body := &requestBody{
|
||||
conn: sc,
|
||||
stream: st,
|
||||
needsContinue: needsContinue,
|
||||
needsContinue: res.NeedsContinue,
|
||||
}
|
||||
req := &http.Request{
|
||||
Method: rp.method,
|
||||
URL: url_,
|
||||
req := (&http.Request{
|
||||
Method: rp.Method,
|
||||
URL: res.URL,
|
||||
RemoteAddr: sc.remoteAddrStr,
|
||||
Header: rp.header,
|
||||
RequestURI: requestURI,
|
||||
Header: rp.Header,
|
||||
RequestURI: res.RequestURI,
|
||||
Proto: "HTTP/2.0",
|
||||
ProtoMajor: 2,
|
||||
ProtoMinor: 0,
|
||||
TLS: tlsState,
|
||||
Host: rp.authority,
|
||||
Host: rp.Authority,
|
||||
Body: body,
|
||||
Trailer: trailer,
|
||||
}
|
||||
req = req.WithContext(st.ctx)
|
||||
|
||||
Trailer: res.Trailer,
|
||||
}).WithContext(st.ctx)
|
||||
rw := sc.newResponseWriter(st, req)
|
||||
return rw, req, nil
|
||||
}
|
||||
|
|
@ -2880,6 +2874,11 @@ func (w *responseWriter) SetWriteDeadline(deadline time.Time) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (w *responseWriter) EnableFullDuplex() error {
|
||||
// We always support full duplex responses, so this is a no-op.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *responseWriter) Flush() {
|
||||
w.FlushError()
|
||||
}
|
||||
|
|
@ -3229,12 +3228,12 @@ func (sc *serverConn) startPush(msg *startPushRequest) {
|
|||
// we start in "half closed (remote)" for simplicity.
|
||||
// See further comments at the definition of stateHalfClosedRemote.
|
||||
promised := sc.newStream(promisedID, msg.parent.id, stateHalfClosedRemote)
|
||||
rw, req, err := sc.newWriterAndRequestNoBody(promised, requestParam{
|
||||
method: msg.method,
|
||||
scheme: msg.url.Scheme,
|
||||
authority: msg.url.Host,
|
||||
path: msg.url.RequestURI(),
|
||||
header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE
|
||||
rw, req, err := sc.newWriterAndRequestNoBody(promised, httpcommon.ServerRequestParam{
|
||||
Method: msg.method,
|
||||
Scheme: msg.url.Scheme,
|
||||
Authority: msg.url.Host,
|
||||
Path: msg.url.RequestURI(),
|
||||
Header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE
|
||||
})
|
||||
if err != nil {
|
||||
// Should not happen, since we've already validated msg.url.
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package http2
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
const nextProtoUnencryptedHTTP2 = "unencrypted_http2"
|
||||
|
||||
// unencryptedNetConnFromTLSConn retrieves a net.Conn wrapped in a *tls.Conn.
|
||||
//
|
||||
// TLSNextProto functions accept a *tls.Conn.
|
||||
//
|
||||
// When passing an unencrypted HTTP/2 connection to a TLSNextProto function,
|
||||
// we pass a *tls.Conn with an underlying net.Conn containing the unencrypted connection.
|
||||
// To be extra careful about mistakes (accidentally dropping TLS encryption in a place
|
||||
// where we want it), the tls.Conn contains a net.Conn with an UnencryptedNetConn method
|
||||
// that returns the actual connection we want to use.
|
||||
func unencryptedNetConnFromTLSConn(tc *tls.Conn) (net.Conn, error) {
|
||||
conner, ok := tc.NetConn().(interface {
|
||||
UnencryptedNetConn() net.Conn
|
||||
})
|
||||
if !ok {
|
||||
return nil, errors.New("http2: TLS conn unexpectedly found in unencrypted handoff")
|
||||
}
|
||||
return conner.UnencryptedNetConn(), nil
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
"golang.org/x/net/http/httpguts"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
"golang.org/x/net/internal/httpcommon"
|
||||
)
|
||||
|
||||
// writeFramer is implemented by any type that is used to write frames.
|
||||
|
|
@ -351,7 +352,7 @@ func encodeHeaders(enc *hpack.Encoder, h http.Header, keys []string) {
|
|||
}
|
||||
for _, k := range keys {
|
||||
vv := h[k]
|
||||
k, ascii := lowerHeader(k)
|
||||
k, ascii := httpcommon.LowerHeader(k)
|
||||
if !ascii {
|
||||
// Skip writing invalid headers. Per RFC 7540, Section 8.1.2, header
|
||||
// field names have to be ASCII characters (just as in HTTP/1.x).
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package httpcommon
|
||||
|
||||
import "strings"
|
||||
|
||||
// The HTTP protocols are defined in terms of ASCII, not Unicode. This file
|
||||
// contains helper functions which may use Unicode-aware functions which would
|
||||
// otherwise be unsafe and could introduce vulnerabilities if used improperly.
|
||||
|
||||
// asciiEqualFold is strings.EqualFold, ASCII only. It reports whether s and t
|
||||
// are equal, ASCII-case-insensitively.
|
||||
func asciiEqualFold(s, t string) bool {
|
||||
if len(s) != len(t) {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < len(s); i++ {
|
||||
if lower(s[i]) != lower(t[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// lower returns the ASCII lowercase version of b.
|
||||
func lower(b byte) byte {
|
||||
if 'A' <= b && b <= 'Z' {
|
||||
return b + ('a' - 'A')
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// isASCIIPrint returns whether s is ASCII and printable according to
|
||||
// https://tools.ietf.org/html/rfc20#section-4.2.
|
||||
func isASCIIPrint(s string) bool {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] < ' ' || s[i] > '~' {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// asciiToLower returns the lowercase version of s if s is ASCII and printable,
|
||||
// and whether or not it was.
|
||||
func asciiToLower(s string) (lower string, ok bool) {
|
||||
if !isASCIIPrint(s) {
|
||||
return "", false
|
||||
}
|
||||
return strings.ToLower(s), true
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package http2
|
||||
package httpcommon
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/textproto"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
|
@ -82,13 +82,15 @@ func buildCommonHeaderMaps() {
|
|||
commonLowerHeader = make(map[string]string, len(common))
|
||||
commonCanonHeader = make(map[string]string, len(common))
|
||||
for _, v := range common {
|
||||
chk := http.CanonicalHeaderKey(v)
|
||||
chk := textproto.CanonicalMIMEHeaderKey(v)
|
||||
commonLowerHeader[chk] = v
|
||||
commonCanonHeader[v] = chk
|
||||
}
|
||||
}
|
||||
|
||||
func lowerHeader(v string) (lower string, ascii bool) {
|
||||
// LowerHeader returns the lowercase form of a header name,
|
||||
// used on the wire for HTTP/2 and HTTP/3 requests.
|
||||
func LowerHeader(v string) (lower string, ascii bool) {
|
||||
buildCommonHeaderMapsOnce()
|
||||
if s, ok := commonLowerHeader[v]; ok {
|
||||
return s, true
|
||||
|
|
@ -96,10 +98,18 @@ func lowerHeader(v string) (lower string, ascii bool) {
|
|||
return asciiToLower(v)
|
||||
}
|
||||
|
||||
func canonicalHeader(v string) string {
|
||||
// CanonicalHeader canonicalizes a header name. (For example, "host" becomes "Host".)
|
||||
func CanonicalHeader(v string) string {
|
||||
buildCommonHeaderMapsOnce()
|
||||
if s, ok := commonCanonHeader[v]; ok {
|
||||
return s
|
||||
}
|
||||
return http.CanonicalHeaderKey(v)
|
||||
return textproto.CanonicalMIMEHeaderKey(v)
|
||||
}
|
||||
|
||||
// CachedCanonicalHeader returns the canonical form of a well-known header name.
|
||||
func CachedCanonicalHeader(v string) (string, bool) {
|
||||
buildCommonHeaderMapsOnce()
|
||||
s, ok := commonCanonHeader[v]
|
||||
return s, ok
|
||||
}
|
||||
|
|
@ -0,0 +1,467 @@
|
|||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package httpcommon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http/httptrace"
|
||||
"net/textproto"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/http/httpguts"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrRequestHeaderListSize = errors.New("request header list larger than peer's advertised limit")
|
||||
)
|
||||
|
||||
// Request is a subset of http.Request.
|
||||
// It'd be simpler to pass an *http.Request, of course, but we can't depend on net/http
|
||||
// without creating a dependency cycle.
|
||||
type Request struct {
|
||||
URL *url.URL
|
||||
Method string
|
||||
Host string
|
||||
Header map[string][]string
|
||||
Trailer map[string][]string
|
||||
ActualContentLength int64 // 0 means 0, -1 means unknown
|
||||
}
|
||||
|
||||
// EncodeHeadersParam is parameters to EncodeHeaders.
|
||||
type EncodeHeadersParam struct {
|
||||
Request Request
|
||||
|
||||
// AddGzipHeader indicates that an "accept-encoding: gzip" header should be
|
||||
// added to the request.
|
||||
AddGzipHeader bool
|
||||
|
||||
// PeerMaxHeaderListSize, when non-zero, is the peer's MAX_HEADER_LIST_SIZE setting.
|
||||
PeerMaxHeaderListSize uint64
|
||||
|
||||
// DefaultUserAgent is the User-Agent header to send when the request
|
||||
// neither contains a User-Agent nor disables it.
|
||||
DefaultUserAgent string
|
||||
}
|
||||
|
||||
// EncodeHeadersParam is the result of EncodeHeaders.
|
||||
type EncodeHeadersResult struct {
|
||||
HasBody bool
|
||||
HasTrailers bool
|
||||
}
|
||||
|
||||
// EncodeHeaders constructs request headers common to HTTP/2 and HTTP/3.
|
||||
// It validates a request and calls headerf with each pseudo-header and header
|
||||
// for the request.
|
||||
// The headerf function is called with the validated, canonicalized header name.
|
||||
func EncodeHeaders(ctx context.Context, param EncodeHeadersParam, headerf func(name, value string)) (res EncodeHeadersResult, _ error) {
|
||||
req := param.Request
|
||||
|
||||
// Check for invalid connection-level headers.
|
||||
if err := checkConnHeaders(req.Header); err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
if req.URL == nil {
|
||||
return res, errors.New("Request.URL is nil")
|
||||
}
|
||||
|
||||
host := req.Host
|
||||
if host == "" {
|
||||
host = req.URL.Host
|
||||
}
|
||||
host, err := httpguts.PunycodeHostPort(host)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if !httpguts.ValidHostHeader(host) {
|
||||
return res, errors.New("invalid Host header")
|
||||
}
|
||||
|
||||
// isNormalConnect is true if this is a non-extended CONNECT request.
|
||||
isNormalConnect := false
|
||||
var protocol string
|
||||
if vv := req.Header[":protocol"]; len(vv) > 0 {
|
||||
protocol = vv[0]
|
||||
}
|
||||
if req.Method == "CONNECT" && protocol == "" {
|
||||
isNormalConnect = true
|
||||
} else if protocol != "" && req.Method != "CONNECT" {
|
||||
return res, errors.New("invalid :protocol header in non-CONNECT request")
|
||||
}
|
||||
|
||||
// Validate the path, except for non-extended CONNECT requests which have no path.
|
||||
var path string
|
||||
if !isNormalConnect {
|
||||
path = req.URL.RequestURI()
|
||||
if !validPseudoPath(path) {
|
||||
orig := path
|
||||
path = strings.TrimPrefix(path, req.URL.Scheme+"://"+host)
|
||||
if !validPseudoPath(path) {
|
||||
if req.URL.Opaque != "" {
|
||||
return res, fmt.Errorf("invalid request :path %q from URL.Opaque = %q", orig, req.URL.Opaque)
|
||||
} else {
|
||||
return res, fmt.Errorf("invalid request :path %q", orig)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for any invalid headers+trailers and return an error before we
|
||||
// potentially pollute our hpack state. (We want to be able to
|
||||
// continue to reuse the hpack encoder for future requests)
|
||||
if err := validateHeaders(req.Header); err != "" {
|
||||
return res, fmt.Errorf("invalid HTTP header %s", err)
|
||||
}
|
||||
if err := validateHeaders(req.Trailer); err != "" {
|
||||
return res, fmt.Errorf("invalid HTTP trailer %s", err)
|
||||
}
|
||||
|
||||
trailers, err := commaSeparatedTrailers(req.Trailer)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
enumerateHeaders := func(f func(name, value string)) {
|
||||
// 8.1.2.3 Request Pseudo-Header Fields
|
||||
// The :path pseudo-header field includes the path and query parts of the
|
||||
// target URI (the path-absolute production and optionally a '?' character
|
||||
// followed by the query production, see Sections 3.3 and 3.4 of
|
||||
// [RFC3986]).
|
||||
f(":authority", host)
|
||||
m := req.Method
|
||||
if m == "" {
|
||||
m = "GET"
|
||||
}
|
||||
f(":method", m)
|
||||
if !isNormalConnect {
|
||||
f(":path", path)
|
||||
f(":scheme", req.URL.Scheme)
|
||||
}
|
||||
if protocol != "" {
|
||||
f(":protocol", protocol)
|
||||
}
|
||||
if trailers != "" {
|
||||
f("trailer", trailers)
|
||||
}
|
||||
|
||||
var didUA bool
|
||||
for k, vv := range req.Header {
|
||||
if asciiEqualFold(k, "host") || asciiEqualFold(k, "content-length") {
|
||||
// Host is :authority, already sent.
|
||||
// Content-Length is automatic, set below.
|
||||
continue
|
||||
} else if asciiEqualFold(k, "connection") ||
|
||||
asciiEqualFold(k, "proxy-connection") ||
|
||||
asciiEqualFold(k, "transfer-encoding") ||
|
||||
asciiEqualFold(k, "upgrade") ||
|
||||
asciiEqualFold(k, "keep-alive") {
|
||||
// Per 8.1.2.2 Connection-Specific Header
|
||||
// Fields, don't send connection-specific
|
||||
// fields. We have already checked if any
|
||||
// are error-worthy so just ignore the rest.
|
||||
continue
|
||||
} else if asciiEqualFold(k, "user-agent") {
|
||||
// Match Go's http1 behavior: at most one
|
||||
// User-Agent. If set to nil or empty string,
|
||||
// then omit it. Otherwise if not mentioned,
|
||||
// include the default (below).
|
||||
didUA = true
|
||||
if len(vv) < 1 {
|
||||
continue
|
||||
}
|
||||
vv = vv[:1]
|
||||
if vv[0] == "" {
|
||||
continue
|
||||
}
|
||||
} else if asciiEqualFold(k, "cookie") {
|
||||
// Per 8.1.2.5 To allow for better compression efficiency, the
|
||||
// Cookie header field MAY be split into separate header fields,
|
||||
// each with one or more cookie-pairs.
|
||||
for _, v := range vv {
|
||||
for {
|
||||
p := strings.IndexByte(v, ';')
|
||||
if p < 0 {
|
||||
break
|
||||
}
|
||||
f("cookie", v[:p])
|
||||
p++
|
||||
// strip space after semicolon if any.
|
||||
for p+1 <= len(v) && v[p] == ' ' {
|
||||
p++
|
||||
}
|
||||
v = v[p:]
|
||||
}
|
||||
if len(v) > 0 {
|
||||
f("cookie", v)
|
||||
}
|
||||
}
|
||||
continue
|
||||
} else if k == ":protocol" {
|
||||
// :protocol pseudo-header was already sent above.
|
||||
continue
|
||||
}
|
||||
|
||||
for _, v := range vv {
|
||||
f(k, v)
|
||||
}
|
||||
}
|
||||
if shouldSendReqContentLength(req.Method, req.ActualContentLength) {
|
||||
f("content-length", strconv.FormatInt(req.ActualContentLength, 10))
|
||||
}
|
||||
if param.AddGzipHeader {
|
||||
f("accept-encoding", "gzip")
|
||||
}
|
||||
if !didUA {
|
||||
f("user-agent", param.DefaultUserAgent)
|
||||
}
|
||||
}
|
||||
|
||||
// Do a first pass over the headers counting bytes to ensure
|
||||
// we don't exceed cc.peerMaxHeaderListSize. This is done as a
|
||||
// separate pass before encoding the headers to prevent
|
||||
// modifying the hpack state.
|
||||
if param.PeerMaxHeaderListSize > 0 {
|
||||
hlSize := uint64(0)
|
||||
enumerateHeaders(func(name, value string) {
|
||||
hf := hpack.HeaderField{Name: name, Value: value}
|
||||
hlSize += uint64(hf.Size())
|
||||
})
|
||||
|
||||
if hlSize > param.PeerMaxHeaderListSize {
|
||||
return res, ErrRequestHeaderListSize
|
||||
}
|
||||
}
|
||||
|
||||
trace := httptrace.ContextClientTrace(ctx)
|
||||
|
||||
// Header list size is ok. Write the headers.
|
||||
enumerateHeaders(func(name, value string) {
|
||||
name, ascii := LowerHeader(name)
|
||||
if !ascii {
|
||||
// Skip writing invalid headers. Per RFC 7540, Section 8.1.2, header
|
||||
// field names have to be ASCII characters (just as in HTTP/1.x).
|
||||
return
|
||||
}
|
||||
|
||||
headerf(name, value)
|
||||
|
||||
if trace != nil && trace.WroteHeaderField != nil {
|
||||
trace.WroteHeaderField(name, []string{value})
|
||||
}
|
||||
})
|
||||
|
||||
res.HasBody = req.ActualContentLength != 0
|
||||
res.HasTrailers = trailers != ""
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// IsRequestGzip reports whether we should add an Accept-Encoding: gzip header
|
||||
// for a request.
|
||||
func IsRequestGzip(method string, header map[string][]string, disableCompression bool) bool {
|
||||
// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
|
||||
if !disableCompression &&
|
||||
len(header["Accept-Encoding"]) == 0 &&
|
||||
len(header["Range"]) == 0 &&
|
||||
method != "HEAD" {
|
||||
// Request gzip only, not deflate. Deflate is ambiguous and
|
||||
// not as universally supported anyway.
|
||||
// See: https://zlib.net/zlib_faq.html#faq39
|
||||
//
|
||||
// Note that we don't request this for HEAD requests,
|
||||
// due to a bug in nginx:
|
||||
// http://trac.nginx.org/nginx/ticket/358
|
||||
// https://golang.org/issue/5522
|
||||
//
|
||||
// We don't request gzip if the request is for a range, since
|
||||
// auto-decoding a portion of a gzipped document will just fail
|
||||
// anyway. See https://golang.org/issue/8923
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// checkConnHeaders checks whether req has any invalid connection-level headers.
|
||||
//
|
||||
// https://www.rfc-editor.org/rfc/rfc9114.html#section-4.2-3
|
||||
// https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.2-1
|
||||
//
|
||||
// Certain headers are special-cased as okay but not transmitted later.
|
||||
// For example, we allow "Transfer-Encoding: chunked", but drop the header when encoding.
|
||||
func checkConnHeaders(h map[string][]string) error {
|
||||
if vv := h["Upgrade"]; len(vv) > 0 && (vv[0] != "" && vv[0] != "chunked") {
|
||||
return fmt.Errorf("invalid Upgrade request header: %q", vv)
|
||||
}
|
||||
if vv := h["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
|
||||
return fmt.Errorf("invalid Transfer-Encoding request header: %q", vv)
|
||||
}
|
||||
if vv := h["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && !asciiEqualFold(vv[0], "close") && !asciiEqualFold(vv[0], "keep-alive")) {
|
||||
return fmt.Errorf("invalid Connection request header: %q", vv)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func commaSeparatedTrailers(trailer map[string][]string) (string, error) {
|
||||
keys := make([]string, 0, len(trailer))
|
||||
for k := range trailer {
|
||||
k = CanonicalHeader(k)
|
||||
switch k {
|
||||
case "Transfer-Encoding", "Trailer", "Content-Length":
|
||||
return "", fmt.Errorf("invalid Trailer key %q", k)
|
||||
}
|
||||
keys = append(keys, k)
|
||||
}
|
||||
if len(keys) > 0 {
|
||||
sort.Strings(keys)
|
||||
return strings.Join(keys, ","), nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// validPseudoPath reports whether v is a valid :path pseudo-header
|
||||
// value. It must be either:
|
||||
//
|
||||
// - a non-empty string starting with '/'
|
||||
// - the string '*', for OPTIONS requests.
|
||||
//
|
||||
// For now this is only used a quick check for deciding when to clean
|
||||
// up Opaque URLs before sending requests from the Transport.
|
||||
// See golang.org/issue/16847
|
||||
//
|
||||
// We used to enforce that the path also didn't start with "//", but
|
||||
// Google's GFE accepts such paths and Chrome sends them, so ignore
|
||||
// that part of the spec. See golang.org/issue/19103.
|
||||
func validPseudoPath(v string) bool {
|
||||
return (len(v) > 0 && v[0] == '/') || v == "*"
|
||||
}
|
||||
|
||||
func validateHeaders(hdrs map[string][]string) string {
|
||||
for k, vv := range hdrs {
|
||||
if !httpguts.ValidHeaderFieldName(k) && k != ":protocol" {
|
||||
return fmt.Sprintf("name %q", k)
|
||||
}
|
||||
for _, v := range vv {
|
||||
if !httpguts.ValidHeaderFieldValue(v) {
|
||||
// Don't include the value in the error,
|
||||
// because it may be sensitive.
|
||||
return fmt.Sprintf("value for header %q", k)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// shouldSendReqContentLength reports whether we should send
|
||||
// a "content-length" request header. This logic is basically a copy of the net/http
|
||||
// transferWriter.shouldSendContentLength.
|
||||
// The contentLength is the corrected contentLength (so 0 means actually 0, not unknown).
|
||||
// -1 means unknown.
|
||||
func shouldSendReqContentLength(method string, contentLength int64) bool {
|
||||
if contentLength > 0 {
|
||||
return true
|
||||
}
|
||||
if contentLength < 0 {
|
||||
return false
|
||||
}
|
||||
// For zero bodies, whether we send a content-length depends on the method.
|
||||
// It also kinda doesn't matter for http2 either way, with END_STREAM.
|
||||
switch method {
|
||||
case "POST", "PUT", "PATCH":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// ServerRequestParam is parameters to NewServerRequest.
|
||||
type ServerRequestParam struct {
|
||||
Method string
|
||||
Scheme, Authority, Path string
|
||||
Protocol string
|
||||
Header map[string][]string
|
||||
}
|
||||
|
||||
// ServerRequestResult is the result of NewServerRequest.
|
||||
type ServerRequestResult struct {
|
||||
// Various http.Request fields.
|
||||
URL *url.URL
|
||||
RequestURI string
|
||||
Trailer map[string][]string
|
||||
|
||||
NeedsContinue bool // client provided an "Expect: 100-continue" header
|
||||
|
||||
// If the request should be rejected, this is a short string suitable for passing
|
||||
// to the http2 package's CountError function.
|
||||
// It might be a bit odd to return errors this way rather than returing an error,
|
||||
// but this ensures we don't forget to include a CountError reason.
|
||||
InvalidReason string
|
||||
}
|
||||
|
||||
func NewServerRequest(rp ServerRequestParam) ServerRequestResult {
|
||||
needsContinue := httpguts.HeaderValuesContainsToken(rp.Header["Expect"], "100-continue")
|
||||
if needsContinue {
|
||||
delete(rp.Header, "Expect")
|
||||
}
|
||||
// Merge Cookie headers into one "; "-delimited value.
|
||||
if cookies := rp.Header["Cookie"]; len(cookies) > 1 {
|
||||
rp.Header["Cookie"] = []string{strings.Join(cookies, "; ")}
|
||||
}
|
||||
|
||||
// Setup Trailers
|
||||
var trailer map[string][]string
|
||||
for _, v := range rp.Header["Trailer"] {
|
||||
for _, key := range strings.Split(v, ",") {
|
||||
key = textproto.CanonicalMIMEHeaderKey(textproto.TrimString(key))
|
||||
switch key {
|
||||
case "Transfer-Encoding", "Trailer", "Content-Length":
|
||||
// Bogus. (copy of http1 rules)
|
||||
// Ignore.
|
||||
default:
|
||||
if trailer == nil {
|
||||
trailer = make(map[string][]string)
|
||||
}
|
||||
trailer[key] = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
delete(rp.Header, "Trailer")
|
||||
|
||||
// "':authority' MUST NOT include the deprecated userinfo subcomponent
|
||||
// for "http" or "https" schemed URIs."
|
||||
// https://www.rfc-editor.org/rfc/rfc9113.html#section-8.3.1-2.3.8
|
||||
if strings.IndexByte(rp.Authority, '@') != -1 && (rp.Scheme == "http" || rp.Scheme == "https") {
|
||||
return ServerRequestResult{
|
||||
InvalidReason: "userinfo_in_authority",
|
||||
}
|
||||
}
|
||||
|
||||
var url_ *url.URL
|
||||
var requestURI string
|
||||
if rp.Method == "CONNECT" && rp.Protocol == "" {
|
||||
url_ = &url.URL{Host: rp.Authority}
|
||||
requestURI = rp.Authority // mimic HTTP/1 server behavior
|
||||
} else {
|
||||
var err error
|
||||
url_, err = url.ParseRequestURI(rp.Path)
|
||||
if err != nil {
|
||||
return ServerRequestResult{
|
||||
InvalidReason: "bad_path",
|
||||
}
|
||||
}
|
||||
requestURI = rp.Path
|
||||
}
|
||||
|
||||
return ServerRequestResult{
|
||||
URL: url_,
|
||||
NeedsContinue: needsContinue,
|
||||
RequestURI: requestURI,
|
||||
Trailer: trailer,
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
|
||||
|
||||
package unix
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//go:linkname runtime_getAuxv runtime.getAuxv
|
||||
func runtime_getAuxv() []uintptr
|
||||
|
||||
// Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.
|
||||
// The returned slice is always a fresh copy, owned by the caller.
|
||||
// It returns an error on non-ELF platforms, or if the auxiliary vector cannot be accessed,
|
||||
// which happens in some locked-down environments and build modes.
|
||||
func Auxv() ([][2]uintptr, error) {
|
||||
vec := runtime_getAuxv()
|
||||
vecLen := len(vec)
|
||||
|
||||
if vecLen == 0 {
|
||||
return nil, syscall.ENOENT
|
||||
}
|
||||
|
||||
if vecLen%2 != 0 {
|
||||
return nil, syscall.EINVAL
|
||||
}
|
||||
|
||||
result := make([]uintptr, vecLen)
|
||||
copy(result, vec)
|
||||
return unsafe.Slice((*[2]uintptr)(unsafe.Pointer(&result[0])), vecLen/2), nil
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
|
||||
|
||||
package unix
|
||||
|
||||
import "syscall"
|
||||
|
||||
func Auxv() ([][2]uintptr, error) {
|
||||
return nil, syscall.ENOTSUP
|
||||
}
|
||||
|
|
@ -58,6 +58,102 @@ func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
|
|||
return &value, err
|
||||
}
|
||||
|
||||
// IoctlGetEthtoolTsInfo fetches ethtool timestamping and PHC
|
||||
// association for the network device specified by ifname.
|
||||
func IoctlGetEthtoolTsInfo(fd int, ifname string) (*EthtoolTsInfo, error) {
|
||||
ifr, err := NewIfreq(ifname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
value := EthtoolTsInfo{Cmd: ETHTOOL_GET_TS_INFO}
|
||||
ifrd := ifr.withData(unsafe.Pointer(&value))
|
||||
|
||||
err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
// IoctlGetHwTstamp retrieves the hardware timestamping configuration
|
||||
// for the network device specified by ifname.
|
||||
func IoctlGetHwTstamp(fd int, ifname string) (*HwTstampConfig, error) {
|
||||
ifr, err := NewIfreq(ifname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
value := HwTstampConfig{}
|
||||
ifrd := ifr.withData(unsafe.Pointer(&value))
|
||||
|
||||
err = ioctlIfreqData(fd, SIOCGHWTSTAMP, &ifrd)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
// IoctlSetHwTstamp updates the hardware timestamping configuration for
|
||||
// the network device specified by ifname.
|
||||
func IoctlSetHwTstamp(fd int, ifname string, cfg *HwTstampConfig) error {
|
||||
ifr, err := NewIfreq(ifname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ifrd := ifr.withData(unsafe.Pointer(cfg))
|
||||
return ioctlIfreqData(fd, SIOCSHWTSTAMP, &ifrd)
|
||||
}
|
||||
|
||||
// FdToClockID derives the clock ID from the file descriptor number
|
||||
// - see clock_gettime(3), FD_TO_CLOCKID macros. The resulting ID is
|
||||
// suitable for system calls like ClockGettime.
|
||||
func FdToClockID(fd int) int32 { return int32((int(^fd) << 3) | 3) }
|
||||
|
||||
// IoctlPtpClockGetcaps returns the description of a given PTP device.
|
||||
func IoctlPtpClockGetcaps(fd int) (*PtpClockCaps, error) {
|
||||
var value PtpClockCaps
|
||||
err := ioctlPtr(fd, PTP_CLOCK_GETCAPS2, unsafe.Pointer(&value))
|
||||
return &value, err
|
||||
}
|
||||
|
||||
// IoctlPtpSysOffsetPrecise returns a description of the clock
|
||||
// offset compared to the system clock.
|
||||
func IoctlPtpSysOffsetPrecise(fd int) (*PtpSysOffsetPrecise, error) {
|
||||
var value PtpSysOffsetPrecise
|
||||
err := ioctlPtr(fd, PTP_SYS_OFFSET_PRECISE2, unsafe.Pointer(&value))
|
||||
return &value, err
|
||||
}
|
||||
|
||||
// IoctlPtpSysOffsetExtended returns an extended description of the
|
||||
// clock offset compared to the system clock. The samples parameter
|
||||
// specifies the desired number of measurements.
|
||||
func IoctlPtpSysOffsetExtended(fd int, samples uint) (*PtpSysOffsetExtended, error) {
|
||||
value := PtpSysOffsetExtended{Samples: uint32(samples)}
|
||||
err := ioctlPtr(fd, PTP_SYS_OFFSET_EXTENDED2, unsafe.Pointer(&value))
|
||||
return &value, err
|
||||
}
|
||||
|
||||
// IoctlPtpPinGetfunc returns the configuration of the specified
|
||||
// I/O pin on given PTP device.
|
||||
func IoctlPtpPinGetfunc(fd int, index uint) (*PtpPinDesc, error) {
|
||||
value := PtpPinDesc{Index: uint32(index)}
|
||||
err := ioctlPtr(fd, PTP_PIN_GETFUNC2, unsafe.Pointer(&value))
|
||||
return &value, err
|
||||
}
|
||||
|
||||
// IoctlPtpPinSetfunc updates configuration of the specified PTP
|
||||
// I/O pin.
|
||||
func IoctlPtpPinSetfunc(fd int, pd *PtpPinDesc) error {
|
||||
return ioctlPtr(fd, PTP_PIN_SETFUNC2, unsafe.Pointer(pd))
|
||||
}
|
||||
|
||||
// IoctlPtpPeroutRequest configures the periodic output mode of the
|
||||
// PTP I/O pins.
|
||||
func IoctlPtpPeroutRequest(fd int, r *PtpPeroutRequest) error {
|
||||
return ioctlPtr(fd, PTP_PEROUT_REQUEST2, unsafe.Pointer(r))
|
||||
}
|
||||
|
||||
// IoctlPtpExttsRequest configures the external timestamping mode
|
||||
// of the PTP I/O pins.
|
||||
func IoctlPtpExttsRequest(fd int, r *PtpExttsRequest) error {
|
||||
return ioctlPtr(fd, PTP_EXTTS_REQUEST2, unsafe.Pointer(r))
|
||||
}
|
||||
|
||||
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
||||
// Linux watchdog API. For more information, see:
|
||||
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||
|
|
|
|||
|
|
@ -158,6 +158,16 @@ includes_Linux='
|
|||
#endif
|
||||
#define _GNU_SOURCE
|
||||
|
||||
// See the description in unix/linux/types.go
|
||||
#if defined(__ARM_EABI__) || \
|
||||
(defined(__mips__) && (_MIPS_SIM == _ABIO32)) || \
|
||||
(defined(__powerpc__) && (!defined(__powerpc64__)))
|
||||
# ifdef _TIME_BITS
|
||||
# undef _TIME_BITS
|
||||
# endif
|
||||
# define _TIME_BITS 32
|
||||
#endif
|
||||
|
||||
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
|
||||
// these structures. We just include them copied from <bits/termios.h>.
|
||||
#if defined(__powerpc__)
|
||||
|
|
@ -256,6 +266,7 @@ struct ltchars {
|
|||
#include <linux/nsfs.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <linux/pps.h>
|
||||
#include <linux/ptp_clock.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/reboot.h>
|
||||
|
|
@ -527,6 +538,7 @@ ccflags="$@"
|
|||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
|
||||
$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
|
||||
$2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
|
||||
$2 ~ /^PTP_/ ||
|
||||
$2 ~ /^RAW_PAYLOAD_/ ||
|
||||
$2 ~ /^[US]F_/ ||
|
||||
$2 ~ /^TP_STATUS_/ ||
|
||||
|
|
|
|||
|
|
@ -602,7 +602,150 @@ func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocI
|
|||
return
|
||||
}
|
||||
|
||||
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
|
||||
// sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
|
||||
const minIovec = 8
|
||||
|
||||
func Readv(fd int, iovs [][]byte) (n int, err error) {
|
||||
if !darwinKernelVersionMin(11, 0, 0) {
|
||||
return 0, ENOSYS
|
||||
}
|
||||
|
||||
iovecs := make([]Iovec, 0, minIovec)
|
||||
iovecs = appendBytes(iovecs, iovs)
|
||||
n, err = readv(fd, iovecs)
|
||||
readvRacedetect(iovecs, n, err)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||
if !darwinKernelVersionMin(11, 0, 0) {
|
||||
return 0, ENOSYS
|
||||
}
|
||||
iovecs := make([]Iovec, 0, minIovec)
|
||||
iovecs = appendBytes(iovecs, iovs)
|
||||
n, err = preadv(fd, iovecs, offset)
|
||||
readvRacedetect(iovecs, n, err)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func Writev(fd int, iovs [][]byte) (n int, err error) {
|
||||
if !darwinKernelVersionMin(11, 0, 0) {
|
||||
return 0, ENOSYS
|
||||
}
|
||||
|
||||
iovecs := make([]Iovec, 0, minIovec)
|
||||
iovecs = appendBytes(iovecs, iovs)
|
||||
if raceenabled {
|
||||
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||
}
|
||||
n, err = writev(fd, iovecs)
|
||||
writevRacedetect(iovecs, n)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||
if !darwinKernelVersionMin(11, 0, 0) {
|
||||
return 0, ENOSYS
|
||||
}
|
||||
|
||||
iovecs := make([]Iovec, 0, minIovec)
|
||||
iovecs = appendBytes(iovecs, iovs)
|
||||
if raceenabled {
|
||||
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||
}
|
||||
n, err = pwritev(fd, iovecs, offset)
|
||||
writevRacedetect(iovecs, n)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func appendBytes(vecs []Iovec, bs [][]byte) []Iovec {
|
||||
for _, b := range bs {
|
||||
var v Iovec
|
||||
v.SetLen(len(b))
|
||||
if len(b) > 0 {
|
||||
v.Base = &b[0]
|
||||
} else {
|
||||
v.Base = (*byte)(unsafe.Pointer(&_zero))
|
||||
}
|
||||
vecs = append(vecs, v)
|
||||
}
|
||||
return vecs
|
||||
}
|
||||
|
||||
func writevRacedetect(iovecs []Iovec, n int) {
|
||||
if !raceenabled {
|
||||
return
|
||||
}
|
||||
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||
m := int(iovecs[i].Len)
|
||||
if m > n {
|
||||
m = n
|
||||
}
|
||||
n -= m
|
||||
if m > 0 {
|
||||
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func readvRacedetect(iovecs []Iovec, n int, err error) {
|
||||
if !raceenabled {
|
||||
return
|
||||
}
|
||||
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||
m := int(iovecs[i].Len)
|
||||
if m > n {
|
||||
m = n
|
||||
}
|
||||
n -= m
|
||||
if m > 0 {
|
||||
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
raceAcquire(unsafe.Pointer(&ioSync))
|
||||
}
|
||||
}
|
||||
|
||||
func darwinMajorMinPatch() (maj, min, patch int, err error) {
|
||||
var un Utsname
|
||||
err = Uname(&un)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var mmp [3]int
|
||||
c := 0
|
||||
Loop:
|
||||
for _, b := range un.Release[:] {
|
||||
switch {
|
||||
case b >= '0' && b <= '9':
|
||||
mmp[c] = 10*mmp[c] + int(b-'0')
|
||||
case b == '.':
|
||||
c++
|
||||
if c > 2 {
|
||||
return 0, 0, 0, ENOTSUP
|
||||
}
|
||||
case b == 0:
|
||||
break Loop
|
||||
default:
|
||||
return 0, 0, 0, ENOTSUP
|
||||
}
|
||||
}
|
||||
if c != 2 {
|
||||
return 0, 0, 0, ENOTSUP
|
||||
}
|
||||
return mmp[0], mmp[1], mmp[2], nil
|
||||
}
|
||||
|
||||
func darwinKernelVersionMin(maj, min, patch int) bool {
|
||||
actualMaj, actualMin, actualPatch, err := darwinMajorMinPatch()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return actualMaj > maj || actualMaj == maj && (actualMin > min || actualMin == min && actualPatch >= patch)
|
||||
}
|
||||
|
||||
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
||||
|
||||
//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
|
||||
|
|
@ -705,3 +848,7 @@ func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocI
|
|||
//sys write(fd int, p []byte) (n int, err error)
|
||||
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||
//sys readv(fd int, iovecs []Iovec) (n int, err error)
|
||||
//sys preadv(fd int, iovecs []Iovec, offset int64) (n int, err error)
|
||||
//sys writev(fd int, iovecs []Iovec) (n int, err error)
|
||||
//sys pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error)
|
||||
|
|
|
|||
|
|
@ -246,6 +246,18 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||
return sendfile(outfd, infd, offset, count)
|
||||
}
|
||||
|
||||
func Dup3(oldfd, newfd, flags int) error {
|
||||
if oldfd == newfd || flags&^O_CLOEXEC != 0 {
|
||||
return EINVAL
|
||||
}
|
||||
how := F_DUP2FD
|
||||
if flags&O_CLOEXEC != 0 {
|
||||
how = F_DUP2FD_CLOEXEC
|
||||
}
|
||||
_, err := fcntl(oldfd, how, newfd)
|
||||
return err
|
||||
}
|
||||
|
||||
/*
|
||||
* Exposed directly
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ package unix
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"slices"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
|
@ -417,7 +418,7 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||
return nil, 0, EINVAL
|
||||
}
|
||||
sa.raw.Family = AF_UNIX
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
sa.raw.Path[i] = int8(name[i])
|
||||
}
|
||||
// length is family (uint16), name, NUL.
|
||||
|
|
@ -507,7 +508,7 @@ func (sa *SockaddrL2) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||
psm := (*[2]byte)(unsafe.Pointer(&sa.raw.Psm))
|
||||
psm[0] = byte(sa.PSM)
|
||||
psm[1] = byte(sa.PSM >> 8)
|
||||
for i := 0; i < len(sa.Addr); i++ {
|
||||
for i := range len(sa.Addr) {
|
||||
sa.raw.Bdaddr[i] = sa.Addr[len(sa.Addr)-1-i]
|
||||
}
|
||||
cid := (*[2]byte)(unsafe.Pointer(&sa.raw.Cid))
|
||||
|
|
@ -589,11 +590,11 @@ func (sa *SockaddrCAN) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||
sa.raw.Family = AF_CAN
|
||||
sa.raw.Ifindex = int32(sa.Ifindex)
|
||||
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID))
|
||||
for i := 0; i < 4; i++ {
|
||||
for i := range 4 {
|
||||
sa.raw.Addr[i] = rx[i]
|
||||
}
|
||||
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID))
|
||||
for i := 0; i < 4; i++ {
|
||||
for i := range 4 {
|
||||
sa.raw.Addr[i+4] = tx[i]
|
||||
}
|
||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrCAN, nil
|
||||
|
|
@ -618,11 +619,11 @@ func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||
sa.raw.Family = AF_CAN
|
||||
sa.raw.Ifindex = int32(sa.Ifindex)
|
||||
n := (*[8]byte)(unsafe.Pointer(&sa.Name))
|
||||
for i := 0; i < 8; i++ {
|
||||
for i := range 8 {
|
||||
sa.raw.Addr[i] = n[i]
|
||||
}
|
||||
p := (*[4]byte)(unsafe.Pointer(&sa.PGN))
|
||||
for i := 0; i < 4; i++ {
|
||||
for i := range 4 {
|
||||
sa.raw.Addr[i+8] = p[i]
|
||||
}
|
||||
sa.raw.Addr[12] = sa.Addr
|
||||
|
|
@ -911,7 +912,7 @@ func (sa *SockaddrIUCV) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||
// These are EBCDIC encoded by the kernel, but we still need to pad them
|
||||
// with blanks. Initializing with blanks allows the caller to feed in either
|
||||
// a padded or an unpadded string.
|
||||
for i := 0; i < 8; i++ {
|
||||
for i := range 8 {
|
||||
sa.raw.Nodeid[i] = ' '
|
||||
sa.raw.User_id[i] = ' '
|
||||
sa.raw.Name[i] = ' '
|
||||
|
|
@ -1148,7 +1149,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||
var user [8]byte
|
||||
var name [8]byte
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
for i := range 8 {
|
||||
user[i] = byte(pp.User_id[i])
|
||||
name[i] = byte(pp.Name[i])
|
||||
}
|
||||
|
|
@ -1173,11 +1174,11 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||
Ifindex: int(pp.Ifindex),
|
||||
}
|
||||
name := (*[8]byte)(unsafe.Pointer(&sa.Name))
|
||||
for i := 0; i < 8; i++ {
|
||||
for i := range 8 {
|
||||
name[i] = pp.Addr[i]
|
||||
}
|
||||
pgn := (*[4]byte)(unsafe.Pointer(&sa.PGN))
|
||||
for i := 0; i < 4; i++ {
|
||||
for i := range 4 {
|
||||
pgn[i] = pp.Addr[i+8]
|
||||
}
|
||||
addr := (*[1]byte)(unsafe.Pointer(&sa.Addr))
|
||||
|
|
@ -1188,11 +1189,11 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||
Ifindex: int(pp.Ifindex),
|
||||
}
|
||||
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID))
|
||||
for i := 0; i < 4; i++ {
|
||||
for i := range 4 {
|
||||
rx[i] = pp.Addr[i]
|
||||
}
|
||||
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID))
|
||||
for i := 0; i < 4; i++ {
|
||||
for i := range 4 {
|
||||
tx[i] = pp.Addr[i+4]
|
||||
}
|
||||
return sa, nil
|
||||
|
|
@ -1860,6 +1861,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||
//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
|
||||
//sys ClockGetres(clockid int32, res *Timespec) (err error)
|
||||
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
||||
//sys ClockSettime(clockid int32, time *Timespec) (err error)
|
||||
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
|
||||
//sys Close(fd int) (err error)
|
||||
//sys CloseRange(first uint, last uint, flags uint) (err error)
|
||||
|
|
@ -2215,10 +2217,7 @@ func readvRacedetect(iovecs []Iovec, n int, err error) {
|
|||
return
|
||||
}
|
||||
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||
m := int(iovecs[i].Len)
|
||||
if m > n {
|
||||
m = n
|
||||
}
|
||||
m := min(int(iovecs[i].Len), n)
|
||||
n -= m
|
||||
if m > 0 {
|
||||
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||
|
|
@ -2269,10 +2268,7 @@ func writevRacedetect(iovecs []Iovec, n int) {
|
|||
return
|
||||
}
|
||||
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||
m := int(iovecs[i].Len)
|
||||
if m > n {
|
||||
m = n
|
||||
}
|
||||
m := min(int(iovecs[i].Len), n)
|
||||
n -= m
|
||||
if m > 0 {
|
||||
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||
|
|
@ -2319,12 +2315,7 @@ func isGroupMember(gid int) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
for _, g := range groups {
|
||||
if g == gid {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(groups, gid)
|
||||
}
|
||||
|
||||
func isCapDacOverrideSet() bool {
|
||||
|
|
|
|||
|
|
@ -1102,3 +1102,90 @@ func (s *Strioctl) SetInt(i int) {
|
|||
func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) {
|
||||
return ioctlPtrRet(fd, req, unsafe.Pointer(s))
|
||||
}
|
||||
|
||||
// Ucred Helpers
|
||||
// See ucred(3c) and getpeerucred(3c)
|
||||
|
||||
//sys getpeerucred(fd uintptr, ucred *uintptr) (err error)
|
||||
//sys ucredFree(ucred uintptr) = ucred_free
|
||||
//sys ucredGet(pid int) (ucred uintptr, err error) = ucred_get
|
||||
//sys ucredGeteuid(ucred uintptr) (uid int) = ucred_geteuid
|
||||
//sys ucredGetegid(ucred uintptr) (gid int) = ucred_getegid
|
||||
//sys ucredGetruid(ucred uintptr) (uid int) = ucred_getruid
|
||||
//sys ucredGetrgid(ucred uintptr) (gid int) = ucred_getrgid
|
||||
//sys ucredGetsuid(ucred uintptr) (uid int) = ucred_getsuid
|
||||
//sys ucredGetsgid(ucred uintptr) (gid int) = ucred_getsgid
|
||||
//sys ucredGetpid(ucred uintptr) (pid int) = ucred_getpid
|
||||
|
||||
// Ucred is an opaque struct that holds user credentials.
|
||||
type Ucred struct {
|
||||
ucred uintptr
|
||||
}
|
||||
|
||||
// We need to ensure that ucredFree is called on the underlying ucred
|
||||
// when the Ucred is garbage collected.
|
||||
func ucredFinalizer(u *Ucred) {
|
||||
ucredFree(u.ucred)
|
||||
}
|
||||
|
||||
func GetPeerUcred(fd uintptr) (*Ucred, error) {
|
||||
var ucred uintptr
|
||||
err := getpeerucred(fd, &ucred)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &Ucred{
|
||||
ucred: ucred,
|
||||
}
|
||||
// set the finalizer on the result so that the ucred will be freed
|
||||
runtime.SetFinalizer(result, ucredFinalizer)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func UcredGet(pid int) (*Ucred, error) {
|
||||
ucred, err := ucredGet(pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &Ucred{
|
||||
ucred: ucred,
|
||||
}
|
||||
// set the finalizer on the result so that the ucred will be freed
|
||||
runtime.SetFinalizer(result, ucredFinalizer)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (u *Ucred) Geteuid() int {
|
||||
defer runtime.KeepAlive(u)
|
||||
return ucredGeteuid(u.ucred)
|
||||
}
|
||||
|
||||
func (u *Ucred) Getruid() int {
|
||||
defer runtime.KeepAlive(u)
|
||||
return ucredGetruid(u.ucred)
|
||||
}
|
||||
|
||||
func (u *Ucred) Getsuid() int {
|
||||
defer runtime.KeepAlive(u)
|
||||
return ucredGetsuid(u.ucred)
|
||||
}
|
||||
|
||||
func (u *Ucred) Getegid() int {
|
||||
defer runtime.KeepAlive(u)
|
||||
return ucredGetegid(u.ucred)
|
||||
}
|
||||
|
||||
func (u *Ucred) Getrgid() int {
|
||||
defer runtime.KeepAlive(u)
|
||||
return ucredGetrgid(u.ucred)
|
||||
}
|
||||
|
||||
func (u *Ucred) Getsgid() int {
|
||||
defer runtime.KeepAlive(u)
|
||||
return ucredGetsgid(u.ucred)
|
||||
}
|
||||
|
||||
func (u *Ucred) Getpid() int {
|
||||
defer runtime.KeepAlive(u)
|
||||
return ucredGetpid(u.ucred)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -768,6 +768,15 @@ func Munmap(b []byte) (err error) {
|
|||
return mapper.Munmap(b)
|
||||
}
|
||||
|
||||
func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) {
|
||||
xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset)
|
||||
return unsafe.Pointer(xaddr), err
|
||||
}
|
||||
|
||||
func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) {
|
||||
return mapper.munmap(uintptr(addr), length)
|
||||
}
|
||||
|
||||
//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
|
||||
//sysnb Getgid() (gid int)
|
||||
//sysnb Getpid() (pid int)
|
||||
|
|
@ -816,10 +825,10 @@ func Lstat(path string, stat *Stat_t) (err error) {
|
|||
// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
|
||||
func isSpecialPath(path []byte) (v bool) {
|
||||
var special = [4][8]byte{
|
||||
[8]byte{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
|
||||
[8]byte{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
|
||||
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
|
||||
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
|
||||
{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
|
||||
{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
|
||||
{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
|
||||
{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
|
||||
|
||||
var i, j int
|
||||
for i = 0; i < len(special); i++ {
|
||||
|
|
@ -3115,3 +3124,90 @@ func legacy_Mkfifoat(dirfd int, path string, mode uint32) (err error) {
|
|||
//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
|
||||
//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
|
||||
//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT
|
||||
|
||||
func fcntlAsIs(fd uintptr, cmd int, arg uintptr) (val int, err error) {
|
||||
runtime.EnterSyscall()
|
||||
r0, e2, e1 := CallLeFuncWithErr(GetZosLibVec()+SYS_FCNTL<<4, uintptr(fd), uintptr(cmd), arg)
|
||||
runtime.ExitSyscall()
|
||||
val = int(r0)
|
||||
if int64(r0) == -1 {
|
||||
err = errnoErr2(e1, e2)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Fcntl(fd uintptr, cmd int, op interface{}) (ret int, err error) {
|
||||
switch op.(type) {
|
||||
case *Flock_t:
|
||||
err = FcntlFlock(fd, cmd, op.(*Flock_t))
|
||||
if err != nil {
|
||||
ret = -1
|
||||
}
|
||||
return
|
||||
case int:
|
||||
return FcntlInt(fd, cmd, op.(int))
|
||||
case *F_cnvrt:
|
||||
return fcntlAsIs(fd, cmd, uintptr(unsafe.Pointer(op.(*F_cnvrt))))
|
||||
case unsafe.Pointer:
|
||||
return fcntlAsIs(fd, cmd, uintptr(op.(unsafe.Pointer)))
|
||||
default:
|
||||
return -1, EINVAL
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
if raceenabled {
|
||||
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||
}
|
||||
return sendfile(outfd, infd, offset, count)
|
||||
}
|
||||
|
||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
// TODO: use LE call instead if the call is implemented
|
||||
originalOffset, err := Seek(infd, 0, SEEK_CUR)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
//start reading data from in_fd
|
||||
if offset != nil {
|
||||
_, err := Seek(infd, *offset, SEEK_SET)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
}
|
||||
|
||||
buf := make([]byte, count)
|
||||
readBuf := make([]byte, 0)
|
||||
var n int = 0
|
||||
for i := 0; i < count; i += n {
|
||||
n, err := Read(infd, buf)
|
||||
if n == 0 {
|
||||
if err != nil {
|
||||
return -1, err
|
||||
} else { // EOF
|
||||
break
|
||||
}
|
||||
}
|
||||
readBuf = append(readBuf, buf...)
|
||||
buf = buf[0:0]
|
||||
}
|
||||
|
||||
n2, err := Write(outfd, readBuf)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
//When sendfile() returns, this variable will be set to the
|
||||
// offset of the byte following the last byte that was read.
|
||||
if offset != nil {
|
||||
*offset = *offset + int64(n)
|
||||
// If offset is not NULL, then sendfile() does not modify the file
|
||||
// offset of in_fd
|
||||
_, err := Seek(infd, originalOffset, SEEK_SET)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
}
|
||||
return n2, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,6 +321,9 @@ const (
|
|||
AUDIT_INTEGRITY_STATUS = 0x70a
|
||||
AUDIT_IPC = 0x517
|
||||
AUDIT_IPC_SET_PERM = 0x51f
|
||||
AUDIT_IPE_ACCESS = 0x58c
|
||||
AUDIT_IPE_CONFIG_CHANGE = 0x58d
|
||||
AUDIT_IPE_POLICY_LOAD = 0x58e
|
||||
AUDIT_KERNEL = 0x7d0
|
||||
AUDIT_KERNEL_OTHER = 0x524
|
||||
AUDIT_KERN_MODULE = 0x532
|
||||
|
|
@ -489,6 +492,7 @@ const (
|
|||
BPF_F_ID = 0x20
|
||||
BPF_F_NETFILTER_IP_DEFRAG = 0x1
|
||||
BPF_F_QUERY_EFFECTIVE = 0x1
|
||||
BPF_F_REDIRECT_FLAGS = 0x19
|
||||
BPF_F_REPLACE = 0x4
|
||||
BPF_F_SLEEPABLE = 0x10
|
||||
BPF_F_STRICT_ALIGNMENT = 0x1
|
||||
|
|
@ -1166,6 +1170,7 @@ const (
|
|||
EXTA = 0xe
|
||||
EXTB = 0xf
|
||||
F2FS_SUPER_MAGIC = 0xf2f52010
|
||||
FALLOC_FL_ALLOCATE_RANGE = 0x0
|
||||
FALLOC_FL_COLLAPSE_RANGE = 0x8
|
||||
FALLOC_FL_INSERT_RANGE = 0x20
|
||||
FALLOC_FL_KEEP_SIZE = 0x1
|
||||
|
|
@ -1240,6 +1245,7 @@ const (
|
|||
FAN_REPORT_DFID_NAME = 0xc00
|
||||
FAN_REPORT_DFID_NAME_TARGET = 0x1e00
|
||||
FAN_REPORT_DIR_FID = 0x400
|
||||
FAN_REPORT_FD_ERROR = 0x2000
|
||||
FAN_REPORT_FID = 0x200
|
||||
FAN_REPORT_NAME = 0x800
|
||||
FAN_REPORT_PIDFD = 0x80
|
||||
|
|
@ -1325,8 +1331,10 @@ const (
|
|||
FUSE_SUPER_MAGIC = 0x65735546
|
||||
FUTEXFS_SUPER_MAGIC = 0xbad1dea
|
||||
F_ADD_SEALS = 0x409
|
||||
F_CREATED_QUERY = 0x404
|
||||
F_DUPFD = 0x0
|
||||
F_DUPFD_CLOEXEC = 0x406
|
||||
F_DUPFD_QUERY = 0x403
|
||||
F_EXLCK = 0x4
|
||||
F_GETFD = 0x1
|
||||
F_GETFL = 0x3
|
||||
|
|
@ -1546,6 +1554,7 @@ const (
|
|||
IPPROTO_ROUTING = 0x2b
|
||||
IPPROTO_RSVP = 0x2e
|
||||
IPPROTO_SCTP = 0x84
|
||||
IPPROTO_SMC = 0x100
|
||||
IPPROTO_TCP = 0x6
|
||||
IPPROTO_TP = 0x1d
|
||||
IPPROTO_UDP = 0x11
|
||||
|
|
@ -1618,6 +1627,8 @@ const (
|
|||
IPV6_UNICAST_IF = 0x4c
|
||||
IPV6_USER_FLOW = 0xe
|
||||
IPV6_V6ONLY = 0x1a
|
||||
IPV6_VERSION = 0x60
|
||||
IPV6_VERSION_MASK = 0xf0
|
||||
IPV6_XFRM_POLICY = 0x23
|
||||
IP_ADD_MEMBERSHIP = 0x23
|
||||
IP_ADD_SOURCE_MEMBERSHIP = 0x27
|
||||
|
|
@ -1799,6 +1810,8 @@ const (
|
|||
LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
|
||||
LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
|
||||
LANDLOCK_CREATE_RULESET_VERSION = 0x1
|
||||
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
|
||||
LANDLOCK_SCOPE_SIGNAL = 0x2
|
||||
LINUX_REBOOT_CMD_CAD_OFF = 0x0
|
||||
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
|
||||
LINUX_REBOOT_CMD_HALT = 0xcdef0123
|
||||
|
|
@ -1860,6 +1873,7 @@ const (
|
|||
MADV_UNMERGEABLE = 0xd
|
||||
MADV_WILLNEED = 0x3
|
||||
MADV_WIPEONFORK = 0x12
|
||||
MAP_DROPPABLE = 0x8
|
||||
MAP_FILE = 0x0
|
||||
MAP_FIXED = 0x10
|
||||
MAP_FIXED_NOREPLACE = 0x100000
|
||||
|
|
@ -1924,6 +1938,7 @@ const (
|
|||
MNT_FORCE = 0x1
|
||||
MNT_ID_REQ_SIZE_VER0 = 0x18
|
||||
MNT_ID_REQ_SIZE_VER1 = 0x20
|
||||
MNT_NS_INFO_SIZE_VER0 = 0x10
|
||||
MODULE_INIT_COMPRESSED_FILE = 0x4
|
||||
MODULE_INIT_IGNORE_MODVERSIONS = 0x1
|
||||
MODULE_INIT_IGNORE_VERMAGIC = 0x2
|
||||
|
|
@ -1959,6 +1974,7 @@ const (
|
|||
MSG_PEEK = 0x2
|
||||
MSG_PROXY = 0x10
|
||||
MSG_RST = 0x1000
|
||||
MSG_SOCK_DEVMEM = 0x2000000
|
||||
MSG_SYN = 0x400
|
||||
MSG_TRUNC = 0x20
|
||||
MSG_TRYHARD = 0x4
|
||||
|
|
@ -2075,6 +2091,7 @@ const (
|
|||
NFC_ATR_REQ_MAXSIZE = 0x40
|
||||
NFC_ATR_RES_GB_MAXSIZE = 0x2f
|
||||
NFC_ATR_RES_MAXSIZE = 0x40
|
||||
NFC_ATS_MAXSIZE = 0x14
|
||||
NFC_COMM_ACTIVE = 0x0
|
||||
NFC_COMM_PASSIVE = 0x1
|
||||
NFC_DEVICE_NAME_MAXSIZE = 0x8
|
||||
|
|
@ -2155,6 +2172,7 @@ const (
|
|||
NFNL_SUBSYS_QUEUE = 0x3
|
||||
NFNL_SUBSYS_ULOG = 0x4
|
||||
NFS_SUPER_MAGIC = 0x6969
|
||||
NFT_BITWISE_BOOL = 0x0
|
||||
NFT_CHAIN_FLAGS = 0x7
|
||||
NFT_CHAIN_MAXNAMELEN = 0x100
|
||||
NFT_CT_MAX = 0x17
|
||||
|
|
@ -2483,6 +2501,7 @@ const (
|
|||
PR_GET_PDEATHSIG = 0x2
|
||||
PR_GET_SECCOMP = 0x15
|
||||
PR_GET_SECUREBITS = 0x1b
|
||||
PR_GET_SHADOW_STACK_STATUS = 0x4a
|
||||
PR_GET_SPECULATION_CTRL = 0x34
|
||||
PR_GET_TAGGED_ADDR_CTRL = 0x38
|
||||
PR_GET_THP_DISABLE = 0x2a
|
||||
|
|
@ -2491,6 +2510,7 @@ const (
|
|||
PR_GET_TIMING = 0xd
|
||||
PR_GET_TSC = 0x19
|
||||
PR_GET_UNALIGN = 0x5
|
||||
PR_LOCK_SHADOW_STACK_STATUS = 0x4c
|
||||
PR_MCE_KILL = 0x21
|
||||
PR_MCE_KILL_CLEAR = 0x0
|
||||
PR_MCE_KILL_DEFAULT = 0x2
|
||||
|
|
@ -2517,6 +2537,8 @@ const (
|
|||
PR_PAC_GET_ENABLED_KEYS = 0x3d
|
||||
PR_PAC_RESET_KEYS = 0x36
|
||||
PR_PAC_SET_ENABLED_KEYS = 0x3c
|
||||
PR_PMLEN_MASK = 0x7f000000
|
||||
PR_PMLEN_SHIFT = 0x18
|
||||
PR_PPC_DEXCR_CTRL_CLEAR = 0x4
|
||||
PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10
|
||||
PR_PPC_DEXCR_CTRL_EDITABLE = 0x1
|
||||
|
|
@ -2584,6 +2606,7 @@ const (
|
|||
PR_SET_PTRACER = 0x59616d61
|
||||
PR_SET_SECCOMP = 0x16
|
||||
PR_SET_SECUREBITS = 0x1c
|
||||
PR_SET_SHADOW_STACK_STATUS = 0x4b
|
||||
PR_SET_SPECULATION_CTRL = 0x35
|
||||
PR_SET_SYSCALL_USER_DISPATCH = 0x3b
|
||||
PR_SET_TAGGED_ADDR_CTRL = 0x37
|
||||
|
|
@ -2594,6 +2617,9 @@ const (
|
|||
PR_SET_UNALIGN = 0x6
|
||||
PR_SET_VMA = 0x53564d41
|
||||
PR_SET_VMA_ANON_NAME = 0x0
|
||||
PR_SHADOW_STACK_ENABLE = 0x1
|
||||
PR_SHADOW_STACK_PUSH = 0x4
|
||||
PR_SHADOW_STACK_WRITE = 0x2
|
||||
PR_SME_GET_VL = 0x40
|
||||
PR_SME_SET_VL = 0x3f
|
||||
PR_SME_SET_VL_ONEXEC = 0x40000
|
||||
|
|
@ -2625,6 +2651,28 @@ const (
|
|||
PR_UNALIGN_NOPRINT = 0x1
|
||||
PR_UNALIGN_SIGBUS = 0x2
|
||||
PSTOREFS_MAGIC = 0x6165676c
|
||||
PTP_CLK_MAGIC = '='
|
||||
PTP_ENABLE_FEATURE = 0x1
|
||||
PTP_EXTTS_EDGES = 0x6
|
||||
PTP_EXTTS_EVENT_VALID = 0x1
|
||||
PTP_EXTTS_V1_VALID_FLAGS = 0x7
|
||||
PTP_EXTTS_VALID_FLAGS = 0x1f
|
||||
PTP_EXT_OFFSET = 0x10
|
||||
PTP_FALLING_EDGE = 0x4
|
||||
PTP_MAX_SAMPLES = 0x19
|
||||
PTP_PEROUT_DUTY_CYCLE = 0x2
|
||||
PTP_PEROUT_ONE_SHOT = 0x1
|
||||
PTP_PEROUT_PHASE = 0x4
|
||||
PTP_PEROUT_V1_VALID_FLAGS = 0x0
|
||||
PTP_PEROUT_VALID_FLAGS = 0x7
|
||||
PTP_PIN_GETFUNC = 0xc0603d06
|
||||
PTP_PIN_GETFUNC2 = 0xc0603d0f
|
||||
PTP_RISING_EDGE = 0x2
|
||||
PTP_STRICT_FLAGS = 0x8
|
||||
PTP_SYS_OFFSET_EXTENDED = 0xc4c03d09
|
||||
PTP_SYS_OFFSET_EXTENDED2 = 0xc4c03d12
|
||||
PTP_SYS_OFFSET_PRECISE = 0xc0403d08
|
||||
PTP_SYS_OFFSET_PRECISE2 = 0xc0403d11
|
||||
PTRACE_ATTACH = 0x10
|
||||
PTRACE_CONT = 0x7
|
||||
PTRACE_DETACH = 0x11
|
||||
|
|
@ -2881,7 +2929,6 @@ const (
|
|||
RTM_NEWNEXTHOP = 0x68
|
||||
RTM_NEWNEXTHOPBUCKET = 0x74
|
||||
RTM_NEWNSID = 0x58
|
||||
RTM_NEWNVLAN = 0x70
|
||||
RTM_NEWPREFIX = 0x34
|
||||
RTM_NEWQDISC = 0x24
|
||||
RTM_NEWROUTE = 0x18
|
||||
|
|
@ -2890,6 +2937,7 @@ const (
|
|||
RTM_NEWTCLASS = 0x28
|
||||
RTM_NEWTFILTER = 0x2c
|
||||
RTM_NEWTUNNEL = 0x78
|
||||
RTM_NEWVLAN = 0x70
|
||||
RTM_NR_FAMILIES = 0x1b
|
||||
RTM_NR_MSGTYPES = 0x6c
|
||||
RTM_SETDCB = 0x4f
|
||||
|
|
@ -2948,6 +2996,7 @@ const (
|
|||
RWF_WRITE_LIFE_NOT_SET = 0x0
|
||||
SCHED_BATCH = 0x3
|
||||
SCHED_DEADLINE = 0x6
|
||||
SCHED_EXT = 0x7
|
||||
SCHED_FIFO = 0x1
|
||||
SCHED_FLAG_ALL = 0x7f
|
||||
SCHED_FLAG_DL_OVERRUN = 0x4
|
||||
|
|
|
|||
|
|
@ -109,12 +109,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x80084803
|
||||
HIDIOCGRDESC = 0x90044802
|
||||
HIDIOCGRDESCSIZE = 0x80044801
|
||||
HIDIOCREVOKE = 0x4004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -237,6 +240,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x7434
|
||||
PPPIOCXFERUNIT = 0x744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||
PTP_ENABLE_PPS = 0x40043d04
|
||||
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||
PTP_EXTTS_REQUEST = 0x40103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||
PTP_PEROUT_REQUEST = 0x40383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||
PTP_PIN_SETFUNC = 0x40603d07
|
||||
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||
PTP_SYS_OFFSET = 0x43403d05
|
||||
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GETFPXREGS = 0x12
|
||||
PTRACE_GET_THREAD_AREA = 0x19
|
||||
|
|
@ -283,10 +300,13 @@ const (
|
|||
RTC_WIE_ON = 0x700f
|
||||
RTC_WKALM_RD = 0x80287010
|
||||
RTC_WKALM_SET = 0x4028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
|
|
@ -321,6 +341,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -109,12 +109,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x80084803
|
||||
HIDIOCGRDESC = 0x90044802
|
||||
HIDIOCGRDESCSIZE = 0x80044801
|
||||
HIDIOCREVOKE = 0x4004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -237,6 +240,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x7434
|
||||
PPPIOCXFERUNIT = 0x744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||
PTP_ENABLE_PPS = 0x40043d04
|
||||
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||
PTP_EXTTS_REQUEST = 0x40103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||
PTP_PEROUT_REQUEST = 0x40383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||
PTP_PIN_SETFUNC = 0x40603d07
|
||||
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||
PTP_SYS_OFFSET = 0x43403d05
|
||||
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||
PTRACE_ARCH_PRCTL = 0x1e
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GETFPXREGS = 0x12
|
||||
|
|
@ -284,10 +301,13 @@ const (
|
|||
RTC_WIE_ON = 0x700f
|
||||
RTC_WKALM_RD = 0x80287010
|
||||
RTC_WKALM_SET = 0x4028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
|
|
@ -322,6 +342,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x80084803
|
||||
HIDIOCGRDESC = 0x90044802
|
||||
HIDIOCGRDESCSIZE = 0x80044801
|
||||
HIDIOCREVOKE = 0x4004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -234,6 +237,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x7434
|
||||
PPPIOCXFERUNIT = 0x744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||
PTP_ENABLE_PPS = 0x40043d04
|
||||
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||
PTP_EXTTS_REQUEST = 0x40103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||
PTP_PEROUT_REQUEST = 0x40383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||
PTP_PIN_SETFUNC = 0x40603d07
|
||||
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||
PTP_SYS_OFFSET = 0x43403d05
|
||||
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||
PTRACE_GETCRUNCHREGS = 0x19
|
||||
PTRACE_GETFDPIC = 0x1f
|
||||
PTRACE_GETFDPIC_EXEC = 0x0
|
||||
|
|
@ -289,10 +306,13 @@ const (
|
|||
RTC_WIE_ON = 0x700f
|
||||
RTC_WKALM_RD = 0x80287010
|
||||
RTC_WKALM_SET = 0x4028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
|
|
@ -327,6 +347,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -109,15 +109,19 @@ const (
|
|||
F_SETOWN = 0x8
|
||||
F_UNLCK = 0x2
|
||||
F_WRLCK = 0x1
|
||||
GCS_MAGIC = 0x47435300
|
||||
HIDIOCGRAWINFO = 0x80084803
|
||||
HIDIOCGRDESC = 0x90044802
|
||||
HIDIOCGRDESCSIZE = 0x80044801
|
||||
HIDIOCREVOKE = 0x4004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -205,6 +209,7 @@ const (
|
|||
PERF_EVENT_IOC_SET_BPF = 0x40042408
|
||||
PERF_EVENT_IOC_SET_FILTER = 0x40082406
|
||||
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
|
||||
POE_MAGIC = 0x504f4530
|
||||
PPPIOCATTACH = 0x4004743d
|
||||
PPPIOCATTCHAN = 0x40047438
|
||||
PPPIOCBRIDGECHAN = 0x40047435
|
||||
|
|
@ -240,6 +245,20 @@ const (
|
|||
PROT_BTI = 0x10
|
||||
PROT_MTE = 0x20
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||
PTP_ENABLE_PPS = 0x40043d04
|
||||
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||
PTP_EXTTS_REQUEST = 0x40103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||
PTP_PEROUT_REQUEST = 0x40383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||
PTP_PIN_SETFUNC = 0x40603d07
|
||||
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||
PTP_SYS_OFFSET = 0x43403d05
|
||||
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||
PTRACE_PEEKMTETAGS = 0x21
|
||||
PTRACE_POKEMTETAGS = 0x22
|
||||
PTRACE_SYSEMU = 0x1f
|
||||
|
|
@ -280,10 +299,13 @@ const (
|
|||
RTC_WIE_ON = 0x700f
|
||||
RTC_WKALM_RD = 0x80287010
|
||||
RTC_WKALM_SET = 0x4028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
|
|
@ -318,6 +340,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -109,12 +109,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x80084803
|
||||
HIDIOCGRDESC = 0x90044802
|
||||
HIDIOCGRDESCSIZE = 0x80044801
|
||||
HIDIOCREVOKE = 0x4004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -238,6 +241,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x7434
|
||||
PPPIOCXFERUNIT = 0x744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||
PTP_ENABLE_PPS = 0x40043d04
|
||||
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||
PTP_EXTTS_REQUEST = 0x40103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||
PTP_PEROUT_REQUEST = 0x40383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||
PTP_PIN_SETFUNC = 0x40603d07
|
||||
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||
PTP_SYS_OFFSET = 0x43403d05
|
||||
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||
PTRACE_SYSEMU = 0x1f
|
||||
PTRACE_SYSEMU_SINGLESTEP = 0x20
|
||||
RLIMIT_AS = 0x9
|
||||
|
|
@ -276,10 +293,13 @@ const (
|
|||
RTC_WIE_ON = 0x700f
|
||||
RTC_WKALM_RD = 0x80287010
|
||||
RTC_WKALM_SET = 0x4028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
|
|
@ -314,6 +334,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x100
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x80
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xfffffff
|
||||
IPV6_FLOWLABEL_MASK = 0xfffff
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -234,6 +237,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x20007434
|
||||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GET_THREAD_AREA = 0x19
|
||||
PTRACE_GET_THREAD_AREA_3264 = 0xc4
|
||||
|
|
@ -282,10 +299,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -320,6 +340,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x1029
|
||||
SO_DONTROUTE = 0x10
|
||||
SO_ERROR = 0x1007
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x100
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x80
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xfffffff
|
||||
IPV6_FLOWLABEL_MASK = 0xfffff
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -234,6 +237,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x20007434
|
||||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GET_THREAD_AREA = 0x19
|
||||
PTRACE_GET_THREAD_AREA_3264 = 0xc4
|
||||
|
|
@ -282,10 +299,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -320,6 +340,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x1029
|
||||
SO_DONTROUTE = 0x10
|
||||
SO_ERROR = 0x1007
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x100
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x80
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -234,6 +237,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x20007434
|
||||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GET_THREAD_AREA = 0x19
|
||||
PTRACE_GET_THREAD_AREA_3264 = 0xc4
|
||||
|
|
@ -282,10 +299,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -320,6 +340,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x1029
|
||||
SO_DONTROUTE = 0x10
|
||||
SO_ERROR = 0x1007
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x100
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x80
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -234,6 +237,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x20007434
|
||||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GET_THREAD_AREA = 0x19
|
||||
PTRACE_GET_THREAD_AREA_3264 = 0xc4
|
||||
|
|
@ -282,10 +299,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -320,6 +340,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x1029
|
||||
SO_DONTROUTE = 0x10
|
||||
SO_ERROR = 0x1007
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x4000
|
||||
ICANON = 0x100
|
||||
IEXTEN = 0x400
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xfffffff
|
||||
IPV6_FLOWLABEL_MASK = 0xfffff
|
||||
ISIG = 0x80
|
||||
IUCLC = 0x1000
|
||||
IXOFF = 0x400
|
||||
|
|
@ -237,6 +240,20 @@ const (
|
|||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PROT_SAO = 0x10
|
||||
PR_SET_PTRACER_ANY = 0xffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETEVRREGS = 0x14
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GETREGS64 = 0x16
|
||||
|
|
@ -337,10 +354,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -375,6 +395,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x4000
|
||||
ICANON = 0x100
|
||||
IEXTEN = 0x400
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xfffffff
|
||||
IPV6_FLOWLABEL_MASK = 0xfffff
|
||||
ISIG = 0x80
|
||||
IUCLC = 0x1000
|
||||
IXOFF = 0x400
|
||||
|
|
@ -237,6 +240,20 @@ const (
|
|||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PROT_SAO = 0x10
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETEVRREGS = 0x14
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GETREGS64 = 0x16
|
||||
|
|
@ -341,10 +358,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -379,6 +399,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x4000
|
||||
ICANON = 0x100
|
||||
IEXTEN = 0x400
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x80
|
||||
IUCLC = 0x1000
|
||||
IXOFF = 0x400
|
||||
|
|
@ -237,6 +240,20 @@ const (
|
|||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PROT_SAO = 0x10
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETEVRREGS = 0x14
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GETREGS64 = 0x16
|
||||
|
|
@ -341,10 +358,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -379,6 +399,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x80084803
|
||||
HIDIOCGRDESC = 0x90044802
|
||||
HIDIOCGRDESCSIZE = 0x80044801
|
||||
HIDIOCREVOKE = 0x4004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -234,6 +237,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x7434
|
||||
PPPIOCXFERUNIT = 0x744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||
PTP_ENABLE_PPS = 0x40043d04
|
||||
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||
PTP_EXTTS_REQUEST = 0x40103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||
PTP_PEROUT_REQUEST = 0x40383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||
PTP_PIN_SETFUNC = 0x40603d07
|
||||
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||
PTP_SYS_OFFSET = 0x43403d05
|
||||
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||
PTRACE_GETFDPIC = 0x21
|
||||
PTRACE_GETFDPIC_EXEC = 0x0
|
||||
PTRACE_GETFDPIC_INTERP = 0x1
|
||||
|
|
@ -273,10 +290,13 @@ const (
|
|||
RTC_WIE_ON = 0x700f
|
||||
RTC_WKALM_RD = 0x80287010
|
||||
RTC_WKALM_SET = 0x4028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
|
|
@ -311,6 +331,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -108,12 +108,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x80084803
|
||||
HIDIOCGRDESC = 0x90044802
|
||||
HIDIOCGRDESCSIZE = 0x80044801
|
||||
HIDIOCREVOKE = 0x4004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x80000
|
||||
IN_NONBLOCK = 0x800
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||
IPV6_FLOWINFO_MASK = 0xfffffff
|
||||
IPV6_FLOWLABEL_MASK = 0xfffff
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -234,6 +237,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x7434
|
||||
PPPIOCXFERUNIT = 0x744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||
PTP_ENABLE_PPS = 0x40043d04
|
||||
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||
PTP_EXTTS_REQUEST = 0x40103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||
PTP_PEROUT_REQUEST = 0x40383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||
PTP_PIN_SETFUNC = 0x40603d07
|
||||
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||
PTP_SYS_OFFSET = 0x43403d05
|
||||
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||
PTRACE_DISABLE_TE = 0x5010
|
||||
PTRACE_ENABLE_TE = 0x5009
|
||||
PTRACE_GET_LAST_BREAK = 0x5006
|
||||
|
|
@ -345,10 +362,13 @@ const (
|
|||
RTC_WIE_ON = 0x700f
|
||||
RTC_WKALM_RD = 0x80287010
|
||||
RTC_WKALM_SET = 0x4028700f
|
||||
SCM_DEVMEM_DMABUF = 0x4f
|
||||
SCM_DEVMEM_LINEAR = 0x4e
|
||||
SCM_TIMESTAMPING = 0x25
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||
SCM_TIMESTAMPNS = 0x23
|
||||
SCM_TS_OPT_ID = 0x51
|
||||
SCM_TXTIME = 0x3d
|
||||
SCM_WIFI_STATUS = 0x29
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||
|
|
@ -383,6 +403,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x35
|
||||
SO_COOKIE = 0x39
|
||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||
SO_DEVMEM_DMABUF = 0x4f
|
||||
SO_DEVMEM_DONTNEED = 0x50
|
||||
SO_DEVMEM_LINEAR = 0x4e
|
||||
SO_DOMAIN = 0x27
|
||||
SO_DONTROUTE = 0x5
|
||||
SO_ERROR = 0x4
|
||||
|
|
|
|||
|
|
@ -112,12 +112,15 @@ const (
|
|||
HIDIOCGRAWINFO = 0x40084803
|
||||
HIDIOCGRDESC = 0x50044802
|
||||
HIDIOCGRDESCSIZE = 0x40044801
|
||||
HIDIOCREVOKE = 0x8004480d
|
||||
HUPCL = 0x400
|
||||
ICANON = 0x2
|
||||
IEXTEN = 0x8000
|
||||
IN_CLOEXEC = 0x400000
|
||||
IN_NONBLOCK = 0x4000
|
||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
|
||||
IPV6_FLOWINFO_MASK = 0xfffffff
|
||||
IPV6_FLOWLABEL_MASK = 0xfffff
|
||||
ISIG = 0x1
|
||||
IUCLC = 0x200
|
||||
IXOFF = 0x1000
|
||||
|
|
@ -239,6 +242,20 @@ const (
|
|||
PPPIOCUNBRIDGECHAN = 0x20007434
|
||||
PPPIOCXFERUNIT = 0x2000744e
|
||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||
PTP_CLOCK_GETCAPS = 0x40503d01
|
||||
PTP_CLOCK_GETCAPS2 = 0x40503d0a
|
||||
PTP_ENABLE_PPS = 0x80043d04
|
||||
PTP_ENABLE_PPS2 = 0x80043d0d
|
||||
PTP_EXTTS_REQUEST = 0x80103d02
|
||||
PTP_EXTTS_REQUEST2 = 0x80103d0b
|
||||
PTP_MASK_CLEAR_ALL = 0x20003d13
|
||||
PTP_MASK_EN_SINGLE = 0x80043d14
|
||||
PTP_PEROUT_REQUEST = 0x80383d03
|
||||
PTP_PEROUT_REQUEST2 = 0x80383d0c
|
||||
PTP_PIN_SETFUNC = 0x80603d07
|
||||
PTP_PIN_SETFUNC2 = 0x80603d10
|
||||
PTP_SYS_OFFSET = 0x83403d05
|
||||
PTP_SYS_OFFSET2 = 0x83403d0e
|
||||
PTRACE_GETFPAREGS = 0x14
|
||||
PTRACE_GETFPREGS = 0xe
|
||||
PTRACE_GETFPREGS64 = 0x19
|
||||
|
|
@ -336,10 +353,13 @@ const (
|
|||
RTC_WIE_ON = 0x2000700f
|
||||
RTC_WKALM_RD = 0x40287010
|
||||
RTC_WKALM_SET = 0x8028700f
|
||||
SCM_DEVMEM_DMABUF = 0x58
|
||||
SCM_DEVMEM_LINEAR = 0x57
|
||||
SCM_TIMESTAMPING = 0x23
|
||||
SCM_TIMESTAMPING_OPT_STATS = 0x38
|
||||
SCM_TIMESTAMPING_PKTINFO = 0x3c
|
||||
SCM_TIMESTAMPNS = 0x21
|
||||
SCM_TS_OPT_ID = 0x5a
|
||||
SCM_TXTIME = 0x3f
|
||||
SCM_WIFI_STATUS = 0x25
|
||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
|
||||
|
|
@ -422,6 +442,9 @@ const (
|
|||
SO_CNX_ADVICE = 0x37
|
||||
SO_COOKIE = 0x3b
|
||||
SO_DETACH_REUSEPORT_BPF = 0x47
|
||||
SO_DEVMEM_DMABUF = 0x58
|
||||
SO_DEVMEM_DONTNEED = 0x59
|
||||
SO_DEVMEM_LINEAR = 0x57
|
||||
SO_DOMAIN = 0x1029
|
||||
SO_DONTROUTE = 0x10
|
||||
SO_ERROR = 0x1007
|
||||
|
|
|
|||
|
|
@ -2512,6 +2512,90 @@ var libc_munmap_trampoline_addr uintptr
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func readv(fd int, iovecs []Iovec) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_readv_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_readv readv "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_preadv_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_preadv preadv "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func writev(fd int, iovecs []Iovec) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_writev_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_writev writev "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_pwritev_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_pwritev pwritev "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Fstat(fd int, stat *Stat_t) (err error) {
|
||||
_, _, e1 := syscall_syscall(libc_fstat64_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
|
||||
if e1 != 0 {
|
||||
|
|
|
|||
|
|
@ -738,6 +738,26 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
|
|||
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB)
|
||||
|
||||
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_readv(SB)
|
||||
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_readv_trampoline_addr(SB)/8, $libc_readv_trampoline<>(SB)
|
||||
|
||||
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_preadv(SB)
|
||||
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_preadv_trampoline_addr(SB)/8, $libc_preadv_trampoline<>(SB)
|
||||
|
||||
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_writev(SB)
|
||||
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_writev_trampoline_addr(SB)/8, $libc_writev_trampoline<>(SB)
|
||||
|
||||
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_pwritev(SB)
|
||||
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_pwritev_trampoline_addr(SB)/8, $libc_pwritev_trampoline<>(SB)
|
||||
|
||||
TEXT libc_fstat64_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_fstat64(SB)
|
||||
GLOBL ·libc_fstat64_trampoline_addr(SB), RODATA, $8
|
||||
|
|
|
|||
|
|
@ -2512,6 +2512,90 @@ var libc_munmap_trampoline_addr uintptr
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func readv(fd int, iovecs []Iovec) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall(libc_readv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_readv_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_readv readv "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func preadv(fd int, iovecs []Iovec, offset int64) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall6(libc_preadv_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_preadv_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_preadv preadv "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func writev(fd int, iovecs []Iovec) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall(libc_writev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_writev_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_writev writev "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(iovecs) > 0 {
|
||||
_p0 = unsafe.Pointer(&iovecs[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := syscall_syscall6(libc_pwritev_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(iovecs)), uintptr(offset), 0, 0)
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var libc_pwritev_trampoline_addr uintptr
|
||||
|
||||
//go:cgo_import_dynamic libc_pwritev pwritev "/usr/lib/libSystem.B.dylib"
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Fstat(fd int, stat *Stat_t) (err error) {
|
||||
_, _, e1 := syscall_syscall(libc_fstat_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
|
||||
if e1 != 0 {
|
||||
|
|
|
|||
|
|
@ -738,6 +738,26 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
|
|||
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB)
|
||||
|
||||
TEXT libc_readv_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_readv(SB)
|
||||
GLOBL ·libc_readv_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_readv_trampoline_addr(SB)/8, $libc_readv_trampoline<>(SB)
|
||||
|
||||
TEXT libc_preadv_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_preadv(SB)
|
||||
GLOBL ·libc_preadv_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_preadv_trampoline_addr(SB)/8, $libc_preadv_trampoline<>(SB)
|
||||
|
||||
TEXT libc_writev_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_writev(SB)
|
||||
GLOBL ·libc_writev_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_writev_trampoline_addr(SB)/8, $libc_writev_trampoline<>(SB)
|
||||
|
||||
TEXT libc_pwritev_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_pwritev(SB)
|
||||
GLOBL ·libc_pwritev_trampoline_addr(SB), RODATA, $8
|
||||
DATA ·libc_pwritev_trampoline_addr(SB)/8, $libc_pwritev_trampoline<>(SB)
|
||||
|
||||
TEXT libc_fstat_trampoline<>(SB),NOSPLIT,$0-0
|
||||
JMP libc_fstat(SB)
|
||||
GLOBL ·libc_fstat_trampoline_addr(SB), RODATA, $8
|
||||
|
|
|
|||
|
|
@ -592,6 +592,16 @@ func ClockGettime(clockid int32, time *Timespec) (err error) {
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ClockSettime(clockid int32, time *Timespec) (err error) {
|
||||
_, _, e1 := Syscall(SYS_CLOCK_SETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) {
|
||||
_, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0)
|
||||
if e1 != 0 {
|
||||
|
|
|
|||
|
|
@ -141,6 +141,16 @@ import (
|
|||
//go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so"
|
||||
//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so"
|
||||
//go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so"
|
||||
//go:cgo_import_dynamic libc_getpeerucred getpeerucred "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_get ucred_get "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_geteuid ucred_geteuid "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_getegid ucred_getegid "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_getruid ucred_getruid "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_getrgid ucred_getrgid "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_getsuid ucred_getsuid "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_getsgid ucred_getsgid "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_getpid ucred_getpid "libc.so"
|
||||
//go:cgo_import_dynamic libc_ucred_free ucred_free "libc.so"
|
||||
//go:cgo_import_dynamic libc_port_create port_create "libc.so"
|
||||
//go:cgo_import_dynamic libc_port_associate port_associate "libc.so"
|
||||
//go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so"
|
||||
|
|
@ -280,6 +290,16 @@ import (
|
|||
//go:linkname procgetpeername libc_getpeername
|
||||
//go:linkname procsetsockopt libc_setsockopt
|
||||
//go:linkname procrecvfrom libc_recvfrom
|
||||
//go:linkname procgetpeerucred libc_getpeerucred
|
||||
//go:linkname procucred_get libc_ucred_get
|
||||
//go:linkname procucred_geteuid libc_ucred_geteuid
|
||||
//go:linkname procucred_getegid libc_ucred_getegid
|
||||
//go:linkname procucred_getruid libc_ucred_getruid
|
||||
//go:linkname procucred_getrgid libc_ucred_getrgid
|
||||
//go:linkname procucred_getsuid libc_ucred_getsuid
|
||||
//go:linkname procucred_getsgid libc_ucred_getsgid
|
||||
//go:linkname procucred_getpid libc_ucred_getpid
|
||||
//go:linkname procucred_free libc_ucred_free
|
||||
//go:linkname procport_create libc_port_create
|
||||
//go:linkname procport_associate libc_port_associate
|
||||
//go:linkname procport_dissociate libc_port_dissociate
|
||||
|
|
@ -420,6 +440,16 @@ var (
|
|||
procgetpeername,
|
||||
procsetsockopt,
|
||||
procrecvfrom,
|
||||
procgetpeerucred,
|
||||
procucred_get,
|
||||
procucred_geteuid,
|
||||
procucred_getegid,
|
||||
procucred_getruid,
|
||||
procucred_getrgid,
|
||||
procucred_getsuid,
|
||||
procucred_getsgid,
|
||||
procucred_getpid,
|
||||
procucred_free,
|
||||
procport_create,
|
||||
procport_associate,
|
||||
procport_dissociate,
|
||||
|
|
@ -2029,6 +2059,90 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func getpeerucred(fd uintptr, ucred *uintptr) (err error) {
|
||||
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetpeerucred)), 2, uintptr(fd), uintptr(unsafe.Pointer(ucred)), 0, 0, 0, 0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGet(pid int) (ucred uintptr, err error) {
|
||||
r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procucred_get)), 1, uintptr(pid), 0, 0, 0, 0, 0)
|
||||
ucred = uintptr(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGeteuid(ucred uintptr) (uid int) {
|
||||
r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_geteuid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
uid = int(r0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGetegid(ucred uintptr) (gid int) {
|
||||
r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getegid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
gid = int(r0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGetruid(ucred uintptr) (uid int) {
|
||||
r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getruid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
uid = int(r0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGetrgid(ucred uintptr) (gid int) {
|
||||
r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getrgid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
gid = int(r0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGetsuid(ucred uintptr) (uid int) {
|
||||
r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getsuid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
uid = int(r0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGetsgid(ucred uintptr) (gid int) {
|
||||
r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getsgid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
gid = int(r0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredGetpid(ucred uintptr) (pid int) {
|
||||
r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getpid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
pid = int(r0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func ucredFree(ucred uintptr) {
|
||||
sysvicall6(uintptr(unsafe.Pointer(&procucred_free)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func port_create() (n int, err error) {
|
||||
r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procport_create)), 0, 0, 0, 0, 0, 0, 0)
|
||||
n = int(r0)
|
||||
|
|
|
|||
|
|
@ -458,4 +458,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -381,4 +381,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -422,4 +422,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -325,4 +325,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -321,4 +321,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -442,4 +442,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 4460
|
||||
SYS_LSM_LIST_MODULES = 4461
|
||||
SYS_MSEAL = 4462
|
||||
SYS_SETXATTRAT = 4463
|
||||
SYS_GETXATTRAT = 4464
|
||||
SYS_LISTXATTRAT = 4465
|
||||
SYS_REMOVEXATTRAT = 4466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -372,4 +372,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 5460
|
||||
SYS_LSM_LIST_MODULES = 5461
|
||||
SYS_MSEAL = 5462
|
||||
SYS_SETXATTRAT = 5463
|
||||
SYS_GETXATTRAT = 5464
|
||||
SYS_LISTXATTRAT = 5465
|
||||
SYS_REMOVEXATTRAT = 5466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -372,4 +372,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 5460
|
||||
SYS_LSM_LIST_MODULES = 5461
|
||||
SYS_MSEAL = 5462
|
||||
SYS_SETXATTRAT = 5463
|
||||
SYS_GETXATTRAT = 5464
|
||||
SYS_LISTXATTRAT = 5465
|
||||
SYS_REMOVEXATTRAT = 5466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -442,4 +442,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 4460
|
||||
SYS_LSM_LIST_MODULES = 4461
|
||||
SYS_MSEAL = 4462
|
||||
SYS_SETXATTRAT = 4463
|
||||
SYS_GETXATTRAT = 4464
|
||||
SYS_LISTXATTRAT = 4465
|
||||
SYS_REMOVEXATTRAT = 4466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -449,4 +449,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -421,4 +421,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -421,4 +421,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -326,4 +326,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -387,4 +387,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -400,4 +400,8 @@ const (
|
|||
SYS_LSM_SET_SELF_ATTR = 460
|
||||
SYS_LSM_LIST_MODULES = 461
|
||||
SYS_MSEAL = 462
|
||||
SYS_SETXATTRAT = 463
|
||||
SYS_GETXATTRAT = 464
|
||||
SYS_LISTXATTRAT = 465
|
||||
SYS_REMOVEXATTRAT = 466
|
||||
)
|
||||
|
|
|
|||
|
|
@ -462,11 +462,14 @@ type FdSet struct {
|
|||
|
||||
const (
|
||||
SizeofIfMsghdr = 0x70
|
||||
SizeofIfMsghdr2 = 0xa0
|
||||
SizeofIfData = 0x60
|
||||
SizeofIfData64 = 0x80
|
||||
SizeofIfaMsghdr = 0x14
|
||||
SizeofIfmaMsghdr = 0x10
|
||||
SizeofIfmaMsghdr2 = 0x14
|
||||
SizeofRtMsghdr = 0x5c
|
||||
SizeofRtMsghdr2 = 0x5c
|
||||
SizeofRtMetrics = 0x38
|
||||
)
|
||||
|
||||
|
|
@ -480,6 +483,20 @@ type IfMsghdr struct {
|
|||
Data IfData
|
||||
}
|
||||
|
||||
type IfMsghdr2 struct {
|
||||
Msglen uint16
|
||||
Version uint8
|
||||
Type uint8
|
||||
Addrs int32
|
||||
Flags int32
|
||||
Index uint16
|
||||
Snd_len int32
|
||||
Snd_maxlen int32
|
||||
Snd_drops int32
|
||||
Timer int32
|
||||
Data IfData64
|
||||
}
|
||||
|
||||
type IfData struct {
|
||||
Type uint8
|
||||
Typelen uint8
|
||||
|
|
@ -512,6 +529,34 @@ type IfData struct {
|
|||
Reserved2 uint32
|
||||
}
|
||||
|
||||
type IfData64 struct {
|
||||
Type uint8
|
||||
Typelen uint8
|
||||
Physical uint8
|
||||
Addrlen uint8
|
||||
Hdrlen uint8
|
||||
Recvquota uint8
|
||||
Xmitquota uint8
|
||||
Unused1 uint8
|
||||
Mtu uint32
|
||||
Metric uint32
|
||||
Baudrate uint64
|
||||
Ipackets uint64
|
||||
Ierrors uint64
|
||||
Opackets uint64
|
||||
Oerrors uint64
|
||||
Collisions uint64
|
||||
Ibytes uint64
|
||||
Obytes uint64
|
||||
Imcasts uint64
|
||||
Omcasts uint64
|
||||
Iqdrops uint64
|
||||
Noproto uint64
|
||||
Recvtiming uint32
|
||||
Xmittiming uint32
|
||||
Lastchange Timeval32
|
||||
}
|
||||
|
||||
type IfaMsghdr struct {
|
||||
Msglen uint16
|
||||
Version uint8
|
||||
|
|
@ -557,6 +602,21 @@ type RtMsghdr struct {
|
|||
Rmx RtMetrics
|
||||
}
|
||||
|
||||
type RtMsghdr2 struct {
|
||||
Msglen uint16
|
||||
Version uint8
|
||||
Type uint8
|
||||
Index uint16
|
||||
Flags int32
|
||||
Addrs int32
|
||||
Refcnt int32
|
||||
Parentflags int32
|
||||
Reserved int32
|
||||
Use int32
|
||||
Inits uint32
|
||||
Rmx RtMetrics
|
||||
}
|
||||
|
||||
type RtMetrics struct {
|
||||
Locks uint32
|
||||
Mtu uint32
|
||||
|
|
|
|||
|
|
@ -462,11 +462,14 @@ type FdSet struct {
|
|||
|
||||
const (
|
||||
SizeofIfMsghdr = 0x70
|
||||
SizeofIfMsghdr2 = 0xa0
|
||||
SizeofIfData = 0x60
|
||||
SizeofIfData64 = 0x80
|
||||
SizeofIfaMsghdr = 0x14
|
||||
SizeofIfmaMsghdr = 0x10
|
||||
SizeofIfmaMsghdr2 = 0x14
|
||||
SizeofRtMsghdr = 0x5c
|
||||
SizeofRtMsghdr2 = 0x5c
|
||||
SizeofRtMetrics = 0x38
|
||||
)
|
||||
|
||||
|
|
@ -480,6 +483,20 @@ type IfMsghdr struct {
|
|||
Data IfData
|
||||
}
|
||||
|
||||
type IfMsghdr2 struct {
|
||||
Msglen uint16
|
||||
Version uint8
|
||||
Type uint8
|
||||
Addrs int32
|
||||
Flags int32
|
||||
Index uint16
|
||||
Snd_len int32
|
||||
Snd_maxlen int32
|
||||
Snd_drops int32
|
||||
Timer int32
|
||||
Data IfData64
|
||||
}
|
||||
|
||||
type IfData struct {
|
||||
Type uint8
|
||||
Typelen uint8
|
||||
|
|
@ -512,6 +529,34 @@ type IfData struct {
|
|||
Reserved2 uint32
|
||||
}
|
||||
|
||||
type IfData64 struct {
|
||||
Type uint8
|
||||
Typelen uint8
|
||||
Physical uint8
|
||||
Addrlen uint8
|
||||
Hdrlen uint8
|
||||
Recvquota uint8
|
||||
Xmitquota uint8
|
||||
Unused1 uint8
|
||||
Mtu uint32
|
||||
Metric uint32
|
||||
Baudrate uint64
|
||||
Ipackets uint64
|
||||
Ierrors uint64
|
||||
Opackets uint64
|
||||
Oerrors uint64
|
||||
Collisions uint64
|
||||
Ibytes uint64
|
||||
Obytes uint64
|
||||
Imcasts uint64
|
||||
Omcasts uint64
|
||||
Iqdrops uint64
|
||||
Noproto uint64
|
||||
Recvtiming uint32
|
||||
Xmittiming uint32
|
||||
Lastchange Timeval32
|
||||
}
|
||||
|
||||
type IfaMsghdr struct {
|
||||
Msglen uint16
|
||||
Version uint8
|
||||
|
|
@ -557,6 +602,21 @@ type RtMsghdr struct {
|
|||
Rmx RtMetrics
|
||||
}
|
||||
|
||||
type RtMsghdr2 struct {
|
||||
Msglen uint16
|
||||
Version uint8
|
||||
Type uint8
|
||||
Index uint16
|
||||
Flags int32
|
||||
Addrs int32
|
||||
Refcnt int32
|
||||
Parentflags int32
|
||||
Reserved int32
|
||||
Use int32
|
||||
Inits uint32
|
||||
Rmx RtMetrics
|
||||
}
|
||||
|
||||
type RtMetrics struct {
|
||||
Locks uint32
|
||||
Mtu uint32
|
||||
|
|
|
|||
|
|
@ -1752,12 +1752,6 @@ const (
|
|||
IFLA_IPVLAN_UNSPEC = 0x0
|
||||
IFLA_IPVLAN_MODE = 0x1
|
||||
IFLA_IPVLAN_FLAGS = 0x2
|
||||
NETKIT_NEXT = -0x1
|
||||
NETKIT_PASS = 0x0
|
||||
NETKIT_DROP = 0x2
|
||||
NETKIT_REDIRECT = 0x7
|
||||
NETKIT_L2 = 0x0
|
||||
NETKIT_L3 = 0x1
|
||||
IFLA_NETKIT_UNSPEC = 0x0
|
||||
IFLA_NETKIT_PEER_INFO = 0x1
|
||||
IFLA_NETKIT_PRIMARY = 0x2
|
||||
|
|
@ -1796,6 +1790,7 @@ const (
|
|||
IFLA_VXLAN_DF = 0x1d
|
||||
IFLA_VXLAN_VNIFILTER = 0x1e
|
||||
IFLA_VXLAN_LOCALBYPASS = 0x1f
|
||||
IFLA_VXLAN_LABEL_POLICY = 0x20
|
||||
IFLA_GENEVE_UNSPEC = 0x0
|
||||
IFLA_GENEVE_ID = 0x1
|
||||
IFLA_GENEVE_REMOTE = 0x2
|
||||
|
|
@ -1825,6 +1820,8 @@ const (
|
|||
IFLA_GTP_ROLE = 0x4
|
||||
IFLA_GTP_CREATE_SOCKETS = 0x5
|
||||
IFLA_GTP_RESTART_COUNT = 0x6
|
||||
IFLA_GTP_LOCAL = 0x7
|
||||
IFLA_GTP_LOCAL6 = 0x8
|
||||
IFLA_BOND_UNSPEC = 0x0
|
||||
IFLA_BOND_MODE = 0x1
|
||||
IFLA_BOND_ACTIVE_SLAVE = 0x2
|
||||
|
|
@ -1857,6 +1854,7 @@ const (
|
|||
IFLA_BOND_AD_LACP_ACTIVE = 0x1d
|
||||
IFLA_BOND_MISSED_MAX = 0x1e
|
||||
IFLA_BOND_NS_IP6_TARGET = 0x1f
|
||||
IFLA_BOND_COUPLED_CONTROL = 0x20
|
||||
IFLA_BOND_AD_INFO_UNSPEC = 0x0
|
||||
IFLA_BOND_AD_INFO_AGGREGATOR = 0x1
|
||||
IFLA_BOND_AD_INFO_NUM_PORTS = 0x2
|
||||
|
|
@ -1925,6 +1923,7 @@ const (
|
|||
IFLA_HSR_SEQ_NR = 0x5
|
||||
IFLA_HSR_VERSION = 0x6
|
||||
IFLA_HSR_PROTOCOL = 0x7
|
||||
IFLA_HSR_INTERLINK = 0x8
|
||||
IFLA_STATS_UNSPEC = 0x0
|
||||
IFLA_STATS_LINK_64 = 0x1
|
||||
IFLA_STATS_LINK_XSTATS = 0x2
|
||||
|
|
@ -1977,6 +1976,15 @@ const (
|
|||
IFLA_DSA_MASTER = 0x1
|
||||
)
|
||||
|
||||
const (
|
||||
NETKIT_NEXT = -0x1
|
||||
NETKIT_PASS = 0x0
|
||||
NETKIT_DROP = 0x2
|
||||
NETKIT_REDIRECT = 0x7
|
||||
NETKIT_L2 = 0x0
|
||||
NETKIT_L3 = 0x1
|
||||
)
|
||||
|
||||
const (
|
||||
NF_INET_PRE_ROUTING = 0x0
|
||||
NF_INET_LOCAL_IN = 0x1
|
||||
|
|
@ -2586,8 +2594,8 @@ const (
|
|||
SOF_TIMESTAMPING_BIND_PHC = 0x8000
|
||||
SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000
|
||||
|
||||
SOF_TIMESTAMPING_LAST = 0x10000
|
||||
SOF_TIMESTAMPING_MASK = 0x1ffff
|
||||
SOF_TIMESTAMPING_LAST = 0x20000
|
||||
SOF_TIMESTAMPING_MASK = 0x3ffff
|
||||
|
||||
SCM_TSTAMP_SND = 0x0
|
||||
SCM_TSTAMP_SCHED = 0x1
|
||||
|
|
@ -3533,7 +3541,7 @@ type Nhmsg struct {
|
|||
type NexthopGrp struct {
|
||||
Id uint32
|
||||
Weight uint8
|
||||
Resvd1 uint8
|
||||
High uint8
|
||||
Resvd2 uint16
|
||||
}
|
||||
|
||||
|
|
@ -3794,7 +3802,7 @@ const (
|
|||
ETHTOOL_MSG_PSE_GET = 0x24
|
||||
ETHTOOL_MSG_PSE_SET = 0x25
|
||||
ETHTOOL_MSG_RSS_GET = 0x26
|
||||
ETHTOOL_MSG_USER_MAX = 0x2c
|
||||
ETHTOOL_MSG_USER_MAX = 0x2d
|
||||
ETHTOOL_MSG_KERNEL_NONE = 0x0
|
||||
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
|
||||
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
|
||||
|
|
@ -3834,7 +3842,7 @@ const (
|
|||
ETHTOOL_MSG_MODULE_NTF = 0x24
|
||||
ETHTOOL_MSG_PSE_GET_REPLY = 0x25
|
||||
ETHTOOL_MSG_RSS_GET_REPLY = 0x26
|
||||
ETHTOOL_MSG_KERNEL_MAX = 0x2c
|
||||
ETHTOOL_MSG_KERNEL_MAX = 0x2e
|
||||
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
|
||||
ETHTOOL_FLAG_OMIT_REPLY = 0x2
|
||||
ETHTOOL_FLAG_STATS = 0x4
|
||||
|
|
@ -3842,7 +3850,7 @@ const (
|
|||
ETHTOOL_A_HEADER_DEV_INDEX = 0x1
|
||||
ETHTOOL_A_HEADER_DEV_NAME = 0x2
|
||||
ETHTOOL_A_HEADER_FLAGS = 0x3
|
||||
ETHTOOL_A_HEADER_MAX = 0x3
|
||||
ETHTOOL_A_HEADER_MAX = 0x4
|
||||
ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0
|
||||
ETHTOOL_A_BITSET_BIT_INDEX = 0x1
|
||||
ETHTOOL_A_BITSET_BIT_NAME = 0x2
|
||||
|
|
@ -4023,11 +4031,11 @@ const (
|
|||
ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0
|
||||
ETHTOOL_A_CABLE_RESULT_PAIR = 0x1
|
||||
ETHTOOL_A_CABLE_RESULT_CODE = 0x2
|
||||
ETHTOOL_A_CABLE_RESULT_MAX = 0x2
|
||||
ETHTOOL_A_CABLE_RESULT_MAX = 0x3
|
||||
ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0
|
||||
ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1
|
||||
ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2
|
||||
ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x2
|
||||
ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x3
|
||||
ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0
|
||||
ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1
|
||||
ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2
|
||||
|
|
@ -4110,6 +4118,107 @@ type EthtoolDrvinfo struct {
|
|||
Regdump_len uint32
|
||||
}
|
||||
|
||||
type EthtoolTsInfo struct {
|
||||
Cmd uint32
|
||||
So_timestamping uint32
|
||||
Phc_index int32
|
||||
Tx_types uint32
|
||||
Tx_reserved [3]uint32
|
||||
Rx_filters uint32
|
||||
Rx_reserved [3]uint32
|
||||
}
|
||||
|
||||
type HwTstampConfig struct {
|
||||
Flags int32
|
||||
Tx_type int32
|
||||
Rx_filter int32
|
||||
}
|
||||
|
||||
const (
|
||||
HWTSTAMP_FILTER_NONE = 0x0
|
||||
HWTSTAMP_FILTER_ALL = 0x1
|
||||
HWTSTAMP_FILTER_SOME = 0x2
|
||||
HWTSTAMP_FILTER_PTP_V1_L4_EVENT = 0x3
|
||||
HWTSTAMP_FILTER_PTP_V2_L4_EVENT = 0x6
|
||||
HWTSTAMP_FILTER_PTP_V2_L2_EVENT = 0x9
|
||||
HWTSTAMP_FILTER_PTP_V2_EVENT = 0xc
|
||||
)
|
||||
|
||||
const (
|
||||
HWTSTAMP_TX_OFF = 0x0
|
||||
HWTSTAMP_TX_ON = 0x1
|
||||
HWTSTAMP_TX_ONESTEP_SYNC = 0x2
|
||||
)
|
||||
|
||||
type (
|
||||
PtpClockCaps struct {
|
||||
Max_adj int32
|
||||
N_alarm int32
|
||||
N_ext_ts int32
|
||||
N_per_out int32
|
||||
Pps int32
|
||||
N_pins int32
|
||||
Cross_timestamping int32
|
||||
Adjust_phase int32
|
||||
Max_phase_adj int32
|
||||
Rsv [11]int32
|
||||
}
|
||||
PtpClockTime struct {
|
||||
Sec int64
|
||||
Nsec uint32
|
||||
Reserved uint32
|
||||
}
|
||||
PtpExttsEvent struct {
|
||||
T PtpClockTime
|
||||
Index uint32
|
||||
Flags uint32
|
||||
Rsv [2]uint32
|
||||
}
|
||||
PtpExttsRequest struct {
|
||||
Index uint32
|
||||
Flags uint32
|
||||
Rsv [2]uint32
|
||||
}
|
||||
PtpPeroutRequest struct {
|
||||
StartOrPhase PtpClockTime
|
||||
Period PtpClockTime
|
||||
Index uint32
|
||||
Flags uint32
|
||||
On PtpClockTime
|
||||
}
|
||||
PtpPinDesc struct {
|
||||
Name [64]byte
|
||||
Index uint32
|
||||
Func uint32
|
||||
Chan uint32
|
||||
Rsv [5]uint32
|
||||
}
|
||||
PtpSysOffset struct {
|
||||
Samples uint32
|
||||
Rsv [3]uint32
|
||||
Ts [51]PtpClockTime
|
||||
}
|
||||
PtpSysOffsetExtended struct {
|
||||
Samples uint32
|
||||
Clockid int32
|
||||
Rsv [2]uint32
|
||||
Ts [25][3]PtpClockTime
|
||||
}
|
||||
PtpSysOffsetPrecise struct {
|
||||
Device PtpClockTime
|
||||
Realtime PtpClockTime
|
||||
Monoraw PtpClockTime
|
||||
Rsv [4]uint32
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
PTP_PF_NONE = 0x0
|
||||
PTP_PF_EXTTS = 0x1
|
||||
PTP_PF_PEROUT = 0x2
|
||||
PTP_PF_PHYSYNC = 0x3
|
||||
)
|
||||
|
||||
type (
|
||||
HIDRawReportDescriptor struct {
|
||||
Size uint32
|
||||
|
|
@ -4291,6 +4400,7 @@ const (
|
|||
type LandlockRulesetAttr struct {
|
||||
Access_fs uint64
|
||||
Access_net uint64
|
||||
Scoped uint64
|
||||
}
|
||||
|
||||
type LandlockPathBeneathAttr struct {
|
||||
|
|
@ -4637,7 +4747,7 @@ const (
|
|||
NL80211_ATTR_MAC_HINT = 0xc8
|
||||
NL80211_ATTR_MAC_MASK = 0xd7
|
||||
NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
|
||||
NL80211_ATTR_MAX = 0x14c
|
||||
NL80211_ATTR_MAX = 0x14d
|
||||
NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
|
||||
NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
|
||||
NL80211_ATTR_MAX_MATCH_SETS = 0x85
|
||||
|
|
@ -5409,7 +5519,7 @@ const (
|
|||
NL80211_MNTR_FLAG_CONTROL = 0x3
|
||||
NL80211_MNTR_FLAG_COOK_FRAMES = 0x5
|
||||
NL80211_MNTR_FLAG_FCSFAIL = 0x1
|
||||
NL80211_MNTR_FLAG_MAX = 0x6
|
||||
NL80211_MNTR_FLAG_MAX = 0x7
|
||||
NL80211_MNTR_FLAG_OTHER_BSS = 0x4
|
||||
NL80211_MNTR_FLAG_PLCPFAIL = 0x2
|
||||
NL80211_MPATH_FLAG_ACTIVE = 0x1
|
||||
|
|
@ -6064,3 +6174,5 @@ type SockDiagReq struct {
|
|||
Family uint8
|
||||
Protocol uint8
|
||||
}
|
||||
|
||||
const RTM_NEWNVLAN = 0x70
|
||||
|
|
|
|||
|
|
@ -377,6 +377,12 @@ type Flock_t struct {
|
|||
Pid int32
|
||||
}
|
||||
|
||||
type F_cnvrt struct {
|
||||
Cvtcmd int32
|
||||
Pccsid int16
|
||||
Fccsid int16
|
||||
}
|
||||
|
||||
type Termios struct {
|
||||
Cflag uint32
|
||||
Iflag uint32
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ type DLL struct {
|
|||
// LoadDLL loads DLL file into memory.
|
||||
//
|
||||
// Warning: using LoadDLL without an absolute path name is subject to
|
||||
// DLL preloading attacks. To safely load a system DLL, use LazyDLL
|
||||
// with System set to true, or use LoadLibraryEx directly.
|
||||
// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL],
|
||||
// or use [LoadLibraryEx] directly.
|
||||
func LoadDLL(name string) (dll *DLL, err error) {
|
||||
namep, err := UTF16PtrFromString(name)
|
||||
if err != nil {
|
||||
|
|
@ -271,6 +271,9 @@ func (d *LazyDLL) NewProc(name string) *LazyProc {
|
|||
}
|
||||
|
||||
// NewLazyDLL creates new LazyDLL associated with DLL file.
|
||||
//
|
||||
// Warning: using NewLazyDLL without an absolute path name is subject to
|
||||
// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL].
|
||||
func NewLazyDLL(name string) *LazyDLL {
|
||||
return &LazyDLL{Name: name}
|
||||
}
|
||||
|
|
@ -410,7 +413,3 @@ func loadLibraryEx(name string, system bool) (*DLL, error) {
|
|||
}
|
||||
return &DLL{Name: name, Handle: h}, nil
|
||||
}
|
||||
|
||||
type errString string
|
||||
|
||||
func (s errString) Error() string { return string(s) }
|
||||
|
|
|
|||
|
|
@ -1303,7 +1303,10 @@ func (selfRelativeSD *SECURITY_DESCRIPTOR) ToAbsolute() (absoluteSD *SECURITY_DE
|
|||
return nil, err
|
||||
}
|
||||
if absoluteSDSize > 0 {
|
||||
absoluteSD = (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&make([]byte, absoluteSDSize)[0]))
|
||||
absoluteSD = new(SECURITY_DESCRIPTOR)
|
||||
if unsafe.Sizeof(*absoluteSD) < uintptr(absoluteSDSize) {
|
||||
panic("sizeof(SECURITY_DESCRIPTOR) too small")
|
||||
}
|
||||
}
|
||||
var (
|
||||
dacl *ACL
|
||||
|
|
@ -1312,19 +1315,55 @@ func (selfRelativeSD *SECURITY_DESCRIPTOR) ToAbsolute() (absoluteSD *SECURITY_DE
|
|||
group *SID
|
||||
)
|
||||
if daclSize > 0 {
|
||||
dacl = (*ACL)(unsafe.Pointer(&make([]byte, daclSize)[0]))
|
||||
dacl = (*ACL)(unsafe.Pointer(unsafe.SliceData(make([]byte, daclSize))))
|
||||
}
|
||||
if saclSize > 0 {
|
||||
sacl = (*ACL)(unsafe.Pointer(&make([]byte, saclSize)[0]))
|
||||
sacl = (*ACL)(unsafe.Pointer(unsafe.SliceData(make([]byte, saclSize))))
|
||||
}
|
||||
if ownerSize > 0 {
|
||||
owner = (*SID)(unsafe.Pointer(&make([]byte, ownerSize)[0]))
|
||||
owner = (*SID)(unsafe.Pointer(unsafe.SliceData(make([]byte, ownerSize))))
|
||||
}
|
||||
if groupSize > 0 {
|
||||
group = (*SID)(unsafe.Pointer(&make([]byte, groupSize)[0]))
|
||||
group = (*SID)(unsafe.Pointer(unsafe.SliceData(make([]byte, groupSize))))
|
||||
}
|
||||
// We call into Windows via makeAbsoluteSD, which sets up
|
||||
// pointers within absoluteSD that point to other chunks of memory
|
||||
// we pass into makeAbsoluteSD, and that happens outside the view of the GC.
|
||||
// We therefore take some care here to then verify the pointers are as we expect
|
||||
// and set them explicitly in view of the GC. See https://go.dev/issue/73199.
|
||||
// TODO: consider weak pointers once Go 1.24 is appropriate. See suggestion in https://go.dev/cl/663575.
|
||||
err = makeAbsoluteSD(selfRelativeSD, absoluteSD, &absoluteSDSize,
|
||||
dacl, &daclSize, sacl, &saclSize, owner, &ownerSize, group, &groupSize)
|
||||
if err != nil {
|
||||
// Don't return absoluteSD, which might be partially initialized.
|
||||
return nil, err
|
||||
}
|
||||
// Before using any fields, verify absoluteSD is in the format we expect according to Windows.
|
||||
// See https://learn.microsoft.com/en-us/windows/win32/secauthz/absolute-and-self-relative-security-descriptors
|
||||
absControl, _, err := absoluteSD.Control()
|
||||
if err != nil {
|
||||
panic("absoluteSD: " + err.Error())
|
||||
}
|
||||
if absControl&SE_SELF_RELATIVE != 0 {
|
||||
panic("absoluteSD not in absolute format")
|
||||
}
|
||||
if absoluteSD.dacl != dacl {
|
||||
panic("dacl pointer mismatch")
|
||||
}
|
||||
if absoluteSD.sacl != sacl {
|
||||
panic("sacl pointer mismatch")
|
||||
}
|
||||
if absoluteSD.owner != owner {
|
||||
panic("owner pointer mismatch")
|
||||
}
|
||||
if absoluteSD.group != group {
|
||||
panic("group pointer mismatch")
|
||||
}
|
||||
absoluteSD.dacl = dacl
|
||||
absoluteSD.sacl = sacl
|
||||
absoluteSD.owner = owner
|
||||
absoluteSD.group = group
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -168,6 +168,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
|||
//sys CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) [failretval==InvalidHandle] = CreateNamedPipeW
|
||||
//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error)
|
||||
//sys DisconnectNamedPipe(pipe Handle) (err error)
|
||||
//sys GetNamedPipeClientProcessId(pipe Handle, clientProcessID *uint32) (err error)
|
||||
//sys GetNamedPipeServerProcessId(pipe Handle, serverProcessID *uint32) (err error)
|
||||
//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error)
|
||||
//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
|
||||
//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState
|
||||
|
|
@ -725,20 +727,12 @@ func DurationSinceBoot() time.Duration {
|
|||
}
|
||||
|
||||
func Ftruncate(fd Handle, length int64) (err error) {
|
||||
curoffset, e := Seek(fd, 0, 1)
|
||||
if e != nil {
|
||||
return e
|
||||
type _FILE_END_OF_FILE_INFO struct {
|
||||
EndOfFile int64
|
||||
}
|
||||
defer Seek(fd, curoffset, 0)
|
||||
_, e = Seek(fd, length, 0)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
e = SetEndOfFile(fd)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
var info _FILE_END_OF_FILE_INFO
|
||||
info.EndOfFile = length
|
||||
return SetFileInformationByHandle(fd, FileEndOfFileInfo, (*byte)(unsafe.Pointer(&info)), uint32(unsafe.Sizeof(info)))
|
||||
}
|
||||
|
||||
func Gettimeofday(tv *Timeval) (err error) {
|
||||
|
|
@ -876,6 +870,7 @@ const socket_error = uintptr(^uint32(0))
|
|||
//sys WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSARecvFrom
|
||||
//sys WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) [failretval==socket_error] = ws2_32.WSASendTo
|
||||
//sys WSASocket(af int32, typ int32, protocol int32, protoInfo *WSAProtocolInfo, group uint32, flags uint32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.WSASocketW
|
||||
//sys WSADuplicateSocket(s Handle, processID uint32, info *WSAProtocolInfo) (err error) [failretval!=0] = ws2_32.WSADuplicateSocketW
|
||||
//sys GetHostByName(name string) (h *Hostent, err error) [failretval==nil] = ws2_32.gethostbyname
|
||||
//sys GetServByName(name string, proto string) (s *Servent, err error) [failretval==nil] = ws2_32.getservbyname
|
||||
//sys Ntohs(netshort uint16) (u uint16) = ws2_32.ntohs
|
||||
|
|
@ -894,6 +889,11 @@ const socket_error = uintptr(^uint32(0))
|
|||
//sys GetACP() (acp uint32) = kernel32.GetACP
|
||||
//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
|
||||
//sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx
|
||||
//sys GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) = iphlpapi.GetIfEntry2Ex
|
||||
//sys GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) = iphlpapi.GetUnicastIpAddressEntry
|
||||
//sys NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyIpInterfaceChange
|
||||
//sys NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyUnicastIpAddressChange
|
||||
//sys CancelMibChangeNotify2(notificationHandle Handle) (errcode error) = iphlpapi.CancelMibChangeNotify2
|
||||
|
||||
// For testing: clients can set this flag to force
|
||||
// creation of IPv6 sockets to return EAFNOSUPPORT.
|
||||
|
|
@ -1685,19 +1685,23 @@ func (s NTStatus) Error() string {
|
|||
// do not use NTUnicodeString, and instead UTF16PtrFromString should be used for
|
||||
// the more common *uint16 string type.
|
||||
func NewNTUnicodeString(s string) (*NTUnicodeString, error) {
|
||||
var u NTUnicodeString
|
||||
s16, err := UTF16PtrFromString(s)
|
||||
s16, err := UTF16FromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
RtlInitUnicodeString(&u, s16)
|
||||
return &u, nil
|
||||
n := uint16(len(s16) * 2)
|
||||
return &NTUnicodeString{
|
||||
Length: n - 2, // subtract 2 bytes for the NULL terminator
|
||||
MaximumLength: n,
|
||||
Buffer: &s16[0],
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Slice returns a uint16 slice that aliases the data in the NTUnicodeString.
|
||||
func (s *NTUnicodeString) Slice() []uint16 {
|
||||
slice := unsafe.Slice(s.Buffer, s.MaximumLength)
|
||||
return slice[:s.Length]
|
||||
// Note: this rounds the length down, if it happens
|
||||
// to (incorrectly) be odd. Probably safer than rounding up.
|
||||
return unsafe.Slice(s.Buffer, s.MaximumLength/2)[:s.Length/2]
|
||||
}
|
||||
|
||||
func (s *NTUnicodeString) String() string {
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ const (
|
|||
WAIT_FAILED = 0xFFFFFFFF
|
||||
|
||||
// Access rights for process.
|
||||
PROCESS_ALL_ACCESS = 0xFFFF
|
||||
PROCESS_CREATE_PROCESS = 0x0080
|
||||
PROCESS_CREATE_THREAD = 0x0002
|
||||
PROCESS_DUP_HANDLE = 0x0040
|
||||
|
|
@ -1073,6 +1074,7 @@ const (
|
|||
IP_ADD_MEMBERSHIP = 0xc
|
||||
IP_DROP_MEMBERSHIP = 0xd
|
||||
IP_PKTINFO = 0x13
|
||||
IP_MTU_DISCOVER = 0x47
|
||||
|
||||
IPV6_V6ONLY = 0x1b
|
||||
IPV6_UNICAST_HOPS = 0x4
|
||||
|
|
@ -1082,6 +1084,7 @@ const (
|
|||
IPV6_JOIN_GROUP = 0xc
|
||||
IPV6_LEAVE_GROUP = 0xd
|
||||
IPV6_PKTINFO = 0x13
|
||||
IPV6_MTU_DISCOVER = 0x47
|
||||
|
||||
MSG_OOB = 0x1
|
||||
MSG_PEEK = 0x2
|
||||
|
|
@ -1131,6 +1134,15 @@ const (
|
|||
WSASYS_STATUS_LEN = 128
|
||||
)
|
||||
|
||||
// enum PMTUD_STATE from ws2ipdef.h
|
||||
const (
|
||||
IP_PMTUDISC_NOT_SET = 0
|
||||
IP_PMTUDISC_DO = 1
|
||||
IP_PMTUDISC_DONT = 2
|
||||
IP_PMTUDISC_PROBE = 3
|
||||
IP_PMTUDISC_MAX = 4
|
||||
)
|
||||
|
||||
type WSABuf struct {
|
||||
Len uint32
|
||||
Buf *byte
|
||||
|
|
@ -1145,6 +1157,22 @@ type WSAMsg struct {
|
|||
Flags uint32
|
||||
}
|
||||
|
||||
type WSACMSGHDR struct {
|
||||
Len uintptr
|
||||
Level int32
|
||||
Type int32
|
||||
}
|
||||
|
||||
type IN_PKTINFO struct {
|
||||
Addr [4]byte
|
||||
Ifindex uint32
|
||||
}
|
||||
|
||||
type IN6_PKTINFO struct {
|
||||
Addr [16]byte
|
||||
Ifindex uint32
|
||||
}
|
||||
|
||||
// Flags for WSASocket
|
||||
const (
|
||||
WSA_FLAG_OVERLAPPED = 0x01
|
||||
|
|
@ -2203,6 +2231,132 @@ const (
|
|||
IfOperStatusLowerLayerDown = 7
|
||||
)
|
||||
|
||||
const (
|
||||
IF_MAX_PHYS_ADDRESS_LENGTH = 32
|
||||
IF_MAX_STRING_SIZE = 256
|
||||
)
|
||||
|
||||
// MIB_IF_ENTRY_LEVEL enumeration from netioapi.h or
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getifentry2ex.
|
||||
const (
|
||||
MibIfEntryNormal = 0
|
||||
MibIfEntryNormalWithoutStatistics = 2
|
||||
)
|
||||
|
||||
// MIB_NOTIFICATION_TYPE enumeration from netioapi.h or
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ne-netioapi-mib_notification_type.
|
||||
const (
|
||||
MibParameterNotification = 0
|
||||
MibAddInstance = 1
|
||||
MibDeleteInstance = 2
|
||||
MibInitialNotification = 3
|
||||
)
|
||||
|
||||
// MibIfRow2 stores information about a particular interface. See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_row2.
|
||||
type MibIfRow2 struct {
|
||||
InterfaceLuid uint64
|
||||
InterfaceIndex uint32
|
||||
InterfaceGuid GUID
|
||||
Alias [IF_MAX_STRING_SIZE + 1]uint16
|
||||
Description [IF_MAX_STRING_SIZE + 1]uint16
|
||||
PhysicalAddressLength uint32
|
||||
PhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
|
||||
PermanentPhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
|
||||
Mtu uint32
|
||||
Type uint32
|
||||
TunnelType uint32
|
||||
MediaType uint32
|
||||
PhysicalMediumType uint32
|
||||
AccessType uint32
|
||||
DirectionType uint32
|
||||
InterfaceAndOperStatusFlags uint8
|
||||
OperStatus uint32
|
||||
AdminStatus uint32
|
||||
MediaConnectState uint32
|
||||
NetworkGuid GUID
|
||||
ConnectionType uint32
|
||||
TransmitLinkSpeed uint64
|
||||
ReceiveLinkSpeed uint64
|
||||
InOctets uint64
|
||||
InUcastPkts uint64
|
||||
InNUcastPkts uint64
|
||||
InDiscards uint64
|
||||
InErrors uint64
|
||||
InUnknownProtos uint64
|
||||
InUcastOctets uint64
|
||||
InMulticastOctets uint64
|
||||
InBroadcastOctets uint64
|
||||
OutOctets uint64
|
||||
OutUcastPkts uint64
|
||||
OutNUcastPkts uint64
|
||||
OutDiscards uint64
|
||||
OutErrors uint64
|
||||
OutUcastOctets uint64
|
||||
OutMulticastOctets uint64
|
||||
OutBroadcastOctets uint64
|
||||
OutQLen uint64
|
||||
}
|
||||
|
||||
// MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row.
|
||||
type MibUnicastIpAddressRow struct {
|
||||
Address RawSockaddrInet6 // SOCKADDR_INET union
|
||||
InterfaceLuid uint64
|
||||
InterfaceIndex uint32
|
||||
PrefixOrigin uint32
|
||||
SuffixOrigin uint32
|
||||
ValidLifetime uint32
|
||||
PreferredLifetime uint32
|
||||
OnLinkPrefixLength uint8
|
||||
SkipAsSource uint8
|
||||
DadState uint32
|
||||
ScopeId uint32
|
||||
CreationTimeStamp Filetime
|
||||
}
|
||||
|
||||
const ScopeLevelCount = 16
|
||||
|
||||
// MIB_IPINTERFACE_ROW stores interface management information for a particular IP address family on a network interface.
|
||||
// See https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipinterface_row.
|
||||
type MibIpInterfaceRow struct {
|
||||
Family uint16
|
||||
InterfaceLuid uint64
|
||||
InterfaceIndex uint32
|
||||
MaxReassemblySize uint32
|
||||
InterfaceIdentifier uint64
|
||||
MinRouterAdvertisementInterval uint32
|
||||
MaxRouterAdvertisementInterval uint32
|
||||
AdvertisingEnabled uint8
|
||||
ForwardingEnabled uint8
|
||||
WeakHostSend uint8
|
||||
WeakHostReceive uint8
|
||||
UseAutomaticMetric uint8
|
||||
UseNeighborUnreachabilityDetection uint8
|
||||
ManagedAddressConfigurationSupported uint8
|
||||
OtherStatefulConfigurationSupported uint8
|
||||
AdvertiseDefaultRoute uint8
|
||||
RouterDiscoveryBehavior uint32
|
||||
DadTransmits uint32
|
||||
BaseReachableTime uint32
|
||||
RetransmitTime uint32
|
||||
PathMtuDiscoveryTimeout uint32
|
||||
LinkLocalAddressBehavior uint32
|
||||
LinkLocalAddressTimeout uint32
|
||||
ZoneIndices [ScopeLevelCount]uint32
|
||||
SitePrefixLength uint32
|
||||
Metric uint32
|
||||
NlMtu uint32
|
||||
Connected uint8
|
||||
SupportsWakeUpPatterns uint8
|
||||
SupportsNeighborDiscovery uint8
|
||||
SupportsRouterDiscovery uint8
|
||||
ReachableTime uint32
|
||||
TransmitOffload uint32
|
||||
ReceiveOffload uint32
|
||||
DisableDefaultRoutes uint8
|
||||
}
|
||||
|
||||
// Console related constants used for the mode parameter to SetConsoleMode. See
|
||||
// https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
|
||||
|
||||
|
|
@ -2546,6 +2700,8 @@ type CommTimeouts struct {
|
|||
|
||||
// NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
|
||||
type NTUnicodeString struct {
|
||||
// Note: Length and MaximumLength are in *bytes*, not uint16s.
|
||||
// They should always be even.
|
||||
Length uint16
|
||||
MaximumLength uint16
|
||||
Buffer *uint16
|
||||
|
|
@ -3474,3 +3630,213 @@ const (
|
|||
KLF_NOTELLSHELL = 0x00000080
|
||||
KLF_SETFORPROCESS = 0x00000100
|
||||
)
|
||||
|
||||
// Virtual Key codes
|
||||
// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||
const (
|
||||
VK_LBUTTON = 0x01
|
||||
VK_RBUTTON = 0x02
|
||||
VK_CANCEL = 0x03
|
||||
VK_MBUTTON = 0x04
|
||||
VK_XBUTTON1 = 0x05
|
||||
VK_XBUTTON2 = 0x06
|
||||
VK_BACK = 0x08
|
||||
VK_TAB = 0x09
|
||||
VK_CLEAR = 0x0C
|
||||
VK_RETURN = 0x0D
|
||||
VK_SHIFT = 0x10
|
||||
VK_CONTROL = 0x11
|
||||
VK_MENU = 0x12
|
||||
VK_PAUSE = 0x13
|
||||
VK_CAPITAL = 0x14
|
||||
VK_KANA = 0x15
|
||||
VK_HANGEUL = 0x15
|
||||
VK_HANGUL = 0x15
|
||||
VK_IME_ON = 0x16
|
||||
VK_JUNJA = 0x17
|
||||
VK_FINAL = 0x18
|
||||
VK_HANJA = 0x19
|
||||
VK_KANJI = 0x19
|
||||
VK_IME_OFF = 0x1A
|
||||
VK_ESCAPE = 0x1B
|
||||
VK_CONVERT = 0x1C
|
||||
VK_NONCONVERT = 0x1D
|
||||
VK_ACCEPT = 0x1E
|
||||
VK_MODECHANGE = 0x1F
|
||||
VK_SPACE = 0x20
|
||||
VK_PRIOR = 0x21
|
||||
VK_NEXT = 0x22
|
||||
VK_END = 0x23
|
||||
VK_HOME = 0x24
|
||||
VK_LEFT = 0x25
|
||||
VK_UP = 0x26
|
||||
VK_RIGHT = 0x27
|
||||
VK_DOWN = 0x28
|
||||
VK_SELECT = 0x29
|
||||
VK_PRINT = 0x2A
|
||||
VK_EXECUTE = 0x2B
|
||||
VK_SNAPSHOT = 0x2C
|
||||
VK_INSERT = 0x2D
|
||||
VK_DELETE = 0x2E
|
||||
VK_HELP = 0x2F
|
||||
VK_LWIN = 0x5B
|
||||
VK_RWIN = 0x5C
|
||||
VK_APPS = 0x5D
|
||||
VK_SLEEP = 0x5F
|
||||
VK_NUMPAD0 = 0x60
|
||||
VK_NUMPAD1 = 0x61
|
||||
VK_NUMPAD2 = 0x62
|
||||
VK_NUMPAD3 = 0x63
|
||||
VK_NUMPAD4 = 0x64
|
||||
VK_NUMPAD5 = 0x65
|
||||
VK_NUMPAD6 = 0x66
|
||||
VK_NUMPAD7 = 0x67
|
||||
VK_NUMPAD8 = 0x68
|
||||
VK_NUMPAD9 = 0x69
|
||||
VK_MULTIPLY = 0x6A
|
||||
VK_ADD = 0x6B
|
||||
VK_SEPARATOR = 0x6C
|
||||
VK_SUBTRACT = 0x6D
|
||||
VK_DECIMAL = 0x6E
|
||||
VK_DIVIDE = 0x6F
|
||||
VK_F1 = 0x70
|
||||
VK_F2 = 0x71
|
||||
VK_F3 = 0x72
|
||||
VK_F4 = 0x73
|
||||
VK_F5 = 0x74
|
||||
VK_F6 = 0x75
|
||||
VK_F7 = 0x76
|
||||
VK_F8 = 0x77
|
||||
VK_F9 = 0x78
|
||||
VK_F10 = 0x79
|
||||
VK_F11 = 0x7A
|
||||
VK_F12 = 0x7B
|
||||
VK_F13 = 0x7C
|
||||
VK_F14 = 0x7D
|
||||
VK_F15 = 0x7E
|
||||
VK_F16 = 0x7F
|
||||
VK_F17 = 0x80
|
||||
VK_F18 = 0x81
|
||||
VK_F19 = 0x82
|
||||
VK_F20 = 0x83
|
||||
VK_F21 = 0x84
|
||||
VK_F22 = 0x85
|
||||
VK_F23 = 0x86
|
||||
VK_F24 = 0x87
|
||||
VK_NUMLOCK = 0x90
|
||||
VK_SCROLL = 0x91
|
||||
VK_OEM_NEC_EQUAL = 0x92
|
||||
VK_OEM_FJ_JISHO = 0x92
|
||||
VK_OEM_FJ_MASSHOU = 0x93
|
||||
VK_OEM_FJ_TOUROKU = 0x94
|
||||
VK_OEM_FJ_LOYA = 0x95
|
||||
VK_OEM_FJ_ROYA = 0x96
|
||||
VK_LSHIFT = 0xA0
|
||||
VK_RSHIFT = 0xA1
|
||||
VK_LCONTROL = 0xA2
|
||||
VK_RCONTROL = 0xA3
|
||||
VK_LMENU = 0xA4
|
||||
VK_RMENU = 0xA5
|
||||
VK_BROWSER_BACK = 0xA6
|
||||
VK_BROWSER_FORWARD = 0xA7
|
||||
VK_BROWSER_REFRESH = 0xA8
|
||||
VK_BROWSER_STOP = 0xA9
|
||||
VK_BROWSER_SEARCH = 0xAA
|
||||
VK_BROWSER_FAVORITES = 0xAB
|
||||
VK_BROWSER_HOME = 0xAC
|
||||
VK_VOLUME_MUTE = 0xAD
|
||||
VK_VOLUME_DOWN = 0xAE
|
||||
VK_VOLUME_UP = 0xAF
|
||||
VK_MEDIA_NEXT_TRACK = 0xB0
|
||||
VK_MEDIA_PREV_TRACK = 0xB1
|
||||
VK_MEDIA_STOP = 0xB2
|
||||
VK_MEDIA_PLAY_PAUSE = 0xB3
|
||||
VK_LAUNCH_MAIL = 0xB4
|
||||
VK_LAUNCH_MEDIA_SELECT = 0xB5
|
||||
VK_LAUNCH_APP1 = 0xB6
|
||||
VK_LAUNCH_APP2 = 0xB7
|
||||
VK_OEM_1 = 0xBA
|
||||
VK_OEM_PLUS = 0xBB
|
||||
VK_OEM_COMMA = 0xBC
|
||||
VK_OEM_MINUS = 0xBD
|
||||
VK_OEM_PERIOD = 0xBE
|
||||
VK_OEM_2 = 0xBF
|
||||
VK_OEM_3 = 0xC0
|
||||
VK_OEM_4 = 0xDB
|
||||
VK_OEM_5 = 0xDC
|
||||
VK_OEM_6 = 0xDD
|
||||
VK_OEM_7 = 0xDE
|
||||
VK_OEM_8 = 0xDF
|
||||
VK_OEM_AX = 0xE1
|
||||
VK_OEM_102 = 0xE2
|
||||
VK_ICO_HELP = 0xE3
|
||||
VK_ICO_00 = 0xE4
|
||||
VK_PROCESSKEY = 0xE5
|
||||
VK_ICO_CLEAR = 0xE6
|
||||
VK_OEM_RESET = 0xE9
|
||||
VK_OEM_JUMP = 0xEA
|
||||
VK_OEM_PA1 = 0xEB
|
||||
VK_OEM_PA2 = 0xEC
|
||||
VK_OEM_PA3 = 0xED
|
||||
VK_OEM_WSCTRL = 0xEE
|
||||
VK_OEM_CUSEL = 0xEF
|
||||
VK_OEM_ATTN = 0xF0
|
||||
VK_OEM_FINISH = 0xF1
|
||||
VK_OEM_COPY = 0xF2
|
||||
VK_OEM_AUTO = 0xF3
|
||||
VK_OEM_ENLW = 0xF4
|
||||
VK_OEM_BACKTAB = 0xF5
|
||||
VK_ATTN = 0xF6
|
||||
VK_CRSEL = 0xF7
|
||||
VK_EXSEL = 0xF8
|
||||
VK_EREOF = 0xF9
|
||||
VK_PLAY = 0xFA
|
||||
VK_ZOOM = 0xFB
|
||||
VK_NONAME = 0xFC
|
||||
VK_PA1 = 0xFD
|
||||
VK_OEM_CLEAR = 0xFE
|
||||
)
|
||||
|
||||
// Mouse button constants.
|
||||
// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
|
||||
const (
|
||||
FROM_LEFT_1ST_BUTTON_PRESSED = 0x0001
|
||||
RIGHTMOST_BUTTON_PRESSED = 0x0002
|
||||
FROM_LEFT_2ND_BUTTON_PRESSED = 0x0004
|
||||
FROM_LEFT_3RD_BUTTON_PRESSED = 0x0008
|
||||
FROM_LEFT_4TH_BUTTON_PRESSED = 0x0010
|
||||
)
|
||||
|
||||
// Control key state constaints.
|
||||
// https://docs.microsoft.com/en-us/windows/console/key-event-record-str
|
||||
// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
|
||||
const (
|
||||
CAPSLOCK_ON = 0x0080
|
||||
ENHANCED_KEY = 0x0100
|
||||
LEFT_ALT_PRESSED = 0x0002
|
||||
LEFT_CTRL_PRESSED = 0x0008
|
||||
NUMLOCK_ON = 0x0020
|
||||
RIGHT_ALT_PRESSED = 0x0001
|
||||
RIGHT_CTRL_PRESSED = 0x0004
|
||||
SCROLLLOCK_ON = 0x0040
|
||||
SHIFT_PRESSED = 0x0010
|
||||
)
|
||||
|
||||
// Mouse event record event flags.
|
||||
// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
|
||||
const (
|
||||
MOUSE_MOVED = 0x0001
|
||||
DOUBLE_CLICK = 0x0002
|
||||
MOUSE_WHEELED = 0x0004
|
||||
MOUSE_HWHEELED = 0x0008
|
||||
)
|
||||
|
||||
// Input Record Event Types
|
||||
// https://learn.microsoft.com/en-us/windows/console/input-record-str
|
||||
const (
|
||||
FOCUS_EVENT = 0x0010
|
||||
KEY_EVENT = 0x0001
|
||||
MENU_EVENT = 0x0008
|
||||
MOUSE_EVENT = 0x0002
|
||||
WINDOW_BUFFER_SIZE_EVENT = 0x0004
|
||||
)
|
||||
|
|
|
|||
|
|
@ -181,10 +181,15 @@ var (
|
|||
procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
|
||||
procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
|
||||
procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
|
||||
procCancelMibChangeNotify2 = modiphlpapi.NewProc("CancelMibChangeNotify2")
|
||||
procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
|
||||
procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
|
||||
procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx")
|
||||
procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
|
||||
procGetIfEntry2Ex = modiphlpapi.NewProc("GetIfEntry2Ex")
|
||||
procGetUnicastIpAddressEntry = modiphlpapi.NewProc("GetUnicastIpAddressEntry")
|
||||
procNotifyIpInterfaceChange = modiphlpapi.NewProc("NotifyIpInterfaceChange")
|
||||
procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange")
|
||||
procAddDllDirectory = modkernel32.NewProc("AddDllDirectory")
|
||||
procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
|
||||
procCancelIo = modkernel32.NewProc("CancelIo")
|
||||
|
|
@ -275,8 +280,10 @@ var (
|
|||
procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount")
|
||||
procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
|
||||
procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
|
||||
procGetNamedPipeClientProcessId = modkernel32.NewProc("GetNamedPipeClientProcessId")
|
||||
procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
|
||||
procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
|
||||
procGetNamedPipeServerProcessId = modkernel32.NewProc("GetNamedPipeServerProcessId")
|
||||
procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
|
||||
procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
|
||||
procGetProcAddress = modkernel32.NewProc("GetProcAddress")
|
||||
|
|
@ -504,6 +511,7 @@ var (
|
|||
procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
|
||||
procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
|
||||
procWSACleanup = modws2_32.NewProc("WSACleanup")
|
||||
procWSADuplicateSocketW = modws2_32.NewProc("WSADuplicateSocketW")
|
||||
procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
|
||||
procWSAGetOverlappedResult = modws2_32.NewProc("WSAGetOverlappedResult")
|
||||
procWSAIoctl = modws2_32.NewProc("WSAIoctl")
|
||||
|
|
@ -1606,6 +1614,14 @@ func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, si
|
|||
return
|
||||
}
|
||||
|
||||
func CancelMibChangeNotify2(notificationHandle Handle) (errcode error) {
|
||||
r0, _, _ := syscall.Syscall(procCancelMibChangeNotify2.Addr(), 1, uintptr(notificationHandle), 0, 0)
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
|
||||
r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
|
||||
if r0 != 0 {
|
||||
|
|
@ -1638,6 +1654,46 @@ func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) {
|
||||
r0, _, _ := syscall.Syscall(procGetIfEntry2Ex.Addr(), 2, uintptr(level), uintptr(unsafe.Pointer(row)), 0)
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) {
|
||||
r0, _, _ := syscall.Syscall(procGetUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) {
|
||||
var _p0 uint32
|
||||
if initialNotification {
|
||||
_p0 = 1
|
||||
}
|
||||
r0, _, _ := syscall.Syscall6(procNotifyIpInterfaceChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) {
|
||||
var _p0 uint32
|
||||
if initialNotification {
|
||||
_p0 = 1
|
||||
}
|
||||
r0, _, _ := syscall.Syscall6(procNotifyUnicastIpAddressChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func AddDllDirectory(path *uint16) (cookie uintptr, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procAddDllDirectory.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
|
||||
cookie = uintptr(r0)
|
||||
|
|
@ -2393,6 +2449,14 @@ func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err er
|
|||
return
|
||||
}
|
||||
|
||||
func GetNamedPipeClientProcessId(pipe Handle, clientProcessID *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procGetNamedPipeClientProcessId.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(clientProcessID)), 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
|
||||
if r1 == 0 {
|
||||
|
|
@ -2409,6 +2473,14 @@ func GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint3
|
|||
return
|
||||
}
|
||||
|
||||
func GetNamedPipeServerProcessId(pipe Handle, serverProcessID *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procGetNamedPipeServerProcessId.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(serverProcessID)), 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
|
||||
var _p0 uint32
|
||||
if wait {
|
||||
|
|
@ -4320,6 +4392,14 @@ func WSACleanup() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func WSADuplicateSocket(s Handle, processID uint32, info *WSAProtocolInfo) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procWSADuplicateSocketW.Addr(), 3, uintptr(s), uintptr(processID), uintptr(unsafe.Pointer(info)))
|
||||
if r1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
|
||||
n = int32(r0)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2024 Google LLC
|
||||
// Copyright 2025 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
|
|
@ -1,73 +1,102 @@
|
|||
# How to contribute
|
||||
|
||||
We definitely welcome your patches and contributions to gRPC! Please read the gRPC
|
||||
organization's [governance rules](https://github.com/grpc/grpc-community/blob/master/governance.md)
|
||||
and [contribution guidelines](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md) before proceeding.
|
||||
We welcome your patches and contributions to gRPC! Please read the gRPC
|
||||
organization's [governance
|
||||
rules](https://github.com/grpc/grpc-community/blob/master/governance.md) before
|
||||
proceeding.
|
||||
|
||||
If you are new to GitHub, please start by reading [Pull Request howto](https://help.github.com/articles/about-pull-requests/)
|
||||
|
||||
## Legal requirements
|
||||
|
||||
In order to protect both you and ourselves, you will need to sign the
|
||||
[Contributor License Agreement](https://identity.linuxfoundation.org/projects/cncf).
|
||||
[Contributor License
|
||||
Agreement](https://identity.linuxfoundation.org/projects/cncf). When you create
|
||||
your first PR, a link will be added as a comment that contains the steps needed
|
||||
to complete this process.
|
||||
|
||||
## Getting Started
|
||||
|
||||
A great way to start is by searching through our open issues. [Unassigned issues
|
||||
labeled as "help
|
||||
wanted"](https://github.com/grpc/grpc-go/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20label%3A%22Status%3A%20Help%20Wanted%22%20no%3Aassignee)
|
||||
are especially nice for first-time contributors, as they should be well-defined
|
||||
problems that already have agreed-upon solutions.
|
||||
|
||||
## Code Style
|
||||
|
||||
We follow [Google's published Go style
|
||||
guide](https://google.github.io/styleguide/go/). Note that there are three
|
||||
primary documents that make up this style guide; please follow them as closely
|
||||
as possible. If a reviewer recommends something that contradicts those
|
||||
guidelines, there may be valid reasons to do so, but it should be rare.
|
||||
|
||||
## Guidelines for Pull Requests
|
||||
How to get your contributions merged smoothly and quickly.
|
||||
|
||||
How to get your contributions merged smoothly and quickly:
|
||||
|
||||
- Create **small PRs** that are narrowly focused on **addressing a single
|
||||
concern**. We often times receive PRs that are trying to fix several things at
|
||||
a time, but only one fix is considered acceptable, nothing gets merged and
|
||||
both author's & review's time is wasted. Create more PRs to address different
|
||||
concerns and everyone will be happy.
|
||||
concern**. We often receive PRs that attempt to fix several things at the same
|
||||
time, and if one part of the PR has a problem, that will hold up the entire
|
||||
PR.
|
||||
|
||||
- If you are searching for features to work on, issues labeled [Status: Help
|
||||
Wanted](https://github.com/grpc/grpc-go/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Status%3A+Help+Wanted%22)
|
||||
is a great place to start. These issues are well-documented and usually can be
|
||||
resolved with a single pull request.
|
||||
- For **speculative changes**, consider opening an issue and discussing it
|
||||
first. If you are suggesting a behavioral or API change, consider starting
|
||||
with a [gRFC proposal](https://github.com/grpc/proposal). Many new features
|
||||
that are not bug fixes will require cross-language agreement.
|
||||
|
||||
- If you are adding a new file, make sure it has the copyright message template
|
||||
at the top as a comment. You can copy over the message from an existing file
|
||||
and update the year.
|
||||
- If you want to fix **formatting or style**, consider whether your changes are
|
||||
an obvious improvement or might be considered a personal preference. If a
|
||||
style change is based on preference, it likely will not be accepted. If it
|
||||
corrects widely agreed-upon anti-patterns, then please do create a PR and
|
||||
explain the benefits of the change.
|
||||
|
||||
- The grpc package should only depend on standard Go packages and a small number
|
||||
of exceptions. If your contribution introduces new dependencies which are NOT
|
||||
in the [list](https://godoc.org/google.golang.org/grpc?imports), you need a
|
||||
discussion with gRPC-Go authors and consultants.
|
||||
|
||||
- For speculative changes, consider opening an issue and discussing it first. If
|
||||
you are suggesting a behavioral or API change, consider starting with a [gRFC
|
||||
proposal](https://github.com/grpc/proposal).
|
||||
- For correcting **misspellings**, please be aware that we use some terms that
|
||||
are sometimes flagged by spell checkers. As an example, "if an only if" is
|
||||
often written as "iff". Please do not make spelling correction changes unless
|
||||
you are certain they are misspellings.
|
||||
|
||||
- Provide a good **PR description** as a record of **what** change is being made
|
||||
and **why** it was made. Link to a GitHub issue if it exists.
|
||||
|
||||
- If you want to fix formatting or style, consider whether your changes are an
|
||||
obvious improvement or might be considered a personal preference. If a style
|
||||
change is based on preference, it likely will not be accepted. If it corrects
|
||||
widely agreed-upon anti-patterns, then please do create a PR and explain the
|
||||
benefits of the change.
|
||||
|
||||
- Unless your PR is trivial, you should expect there will be reviewer comments
|
||||
that you'll need to address before merging. We'll mark it as `Status: Requires
|
||||
Reporter Clarification` if we expect you to respond to these comments in a
|
||||
timely manner. If the PR remains inactive for 6 days, it will be marked as
|
||||
`stale` and automatically close 7 days after that if we don't hear back from
|
||||
you.
|
||||
|
||||
- Maintain **clean commit history** and use **meaningful commit messages**. PRs
|
||||
with messy commit history are difficult to review and won't be merged. Use
|
||||
`rebase -i upstream/master` to curate your commit history and/or to bring in
|
||||
latest changes from master (but avoid rebasing in the middle of a code
|
||||
review).
|
||||
|
||||
- Keep your PR up to date with upstream/master (if there are merge conflicts, we
|
||||
can't really merge your change).
|
||||
- Maintain a **clean commit history** and use **meaningful commit messages**.
|
||||
PRs with messy commit histories are difficult to review and won't be merged.
|
||||
Before sending your PR, ensure your changes are based on top of the latest
|
||||
`upstream/master` commits, and avoid rebasing in the middle of a code review.
|
||||
You should **never use `git push -f`** unless absolutely necessary during a
|
||||
review, as it can interfere with GitHub's tracking of comments.
|
||||
|
||||
- **All tests need to be passing** before your change can be merged. We
|
||||
recommend you **run tests locally** before creating your PR to catch breakages
|
||||
early on.
|
||||
- `./scripts/vet.sh` to catch vet errors
|
||||
- `go test -cpu 1,4 -timeout 7m ./...` to run the tests
|
||||
- `go test -race -cpu 1,4 -timeout 7m ./...` to run tests in race mode
|
||||
recommend you run tests locally before creating your PR to catch breakages
|
||||
early on:
|
||||
|
||||
- Exceptions to the rules can be made if there's a compelling reason for doing so.
|
||||
- `./scripts/vet.sh` to catch vet errors.
|
||||
- `go test -cpu 1,4 -timeout 7m ./...` to run the tests.
|
||||
- `go test -race -cpu 1,4 -timeout 7m ./...` to run tests in race mode.
|
||||
|
||||
Note that we have a multi-module repo, so `go test` commands may need to be
|
||||
run from the root of each module in order to cause all tests to run.
|
||||
|
||||
*Alternatively*, you may find it easier to push your changes to your fork on
|
||||
GitHub, which will trigger a GitHub Actions run that you can use to verify
|
||||
everything is passing.
|
||||
|
||||
- If you are adding a new file, make sure it has the **copyright message**
|
||||
template at the top as a comment. You can copy the message from an existing
|
||||
file and update the year.
|
||||
|
||||
- The grpc package should only depend on standard Go packages and a small number
|
||||
of exceptions. **If your contribution introduces new dependencies**, you will
|
||||
need a discussion with gRPC-Go maintainers. A GitHub action check will run on
|
||||
every PR, and will flag any transitive dependency changes from any public
|
||||
package.
|
||||
|
||||
- Unless your PR is trivial, you should **expect reviewer comments** that you
|
||||
will need to address before merging. We'll label the PR as `Status: Requires
|
||||
Reporter Clarification` if we expect you to respond to these comments in a
|
||||
timely manner. If the PR remains inactive for 6 days, it will be marked as
|
||||
`stale`, and we will automatically close it after 7 days if we don't hear back
|
||||
from you. Please feel free to ping issues or bugs if you do not get a response
|
||||
within a week.
|
||||
|
||||
- Exceptions to the rules can be made if there's a compelling reason to do so.
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import "google.golang.org/grpc"
|
|||
- [Low-level technical docs](Documentation) from this repository
|
||||
- [Performance benchmark][]
|
||||
- [Examples](examples)
|
||||
- [Contribution guidelines](CONTRIBUTING.md)
|
||||
|
||||
## FAQ
|
||||
|
||||
|
|
|
|||
|
|
@ -73,17 +73,6 @@ func unregisterForTesting(name string) {
|
|||
delete(m, name)
|
||||
}
|
||||
|
||||
// connectedAddress returns the connected address for a SubConnState. The
|
||||
// address is only valid if the state is READY.
|
||||
func connectedAddress(scs SubConnState) resolver.Address {
|
||||
return scs.connectedAddress
|
||||
}
|
||||
|
||||
// setConnectedAddress sets the connected address for a SubConnState.
|
||||
func setConnectedAddress(scs *SubConnState, addr resolver.Address) {
|
||||
scs.connectedAddress = addr
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.BalancerUnregister = unregisterForTesting
|
||||
internal.ConnectedAddress = connectedAddress
|
||||
|
|
@ -106,57 +95,6 @@ func Get(name string) Builder {
|
|||
return nil
|
||||
}
|
||||
|
||||
// A SubConn represents a single connection to a gRPC backend service.
|
||||
//
|
||||
// Each SubConn contains a list of addresses.
|
||||
//
|
||||
// All SubConns start in IDLE, and will not try to connect. To trigger the
|
||||
// connecting, Balancers must call Connect. If a connection re-enters IDLE,
|
||||
// Balancers must call Connect again to trigger a new connection attempt.
|
||||
//
|
||||
// gRPC will try to connect to the addresses in sequence, and stop trying the
|
||||
// remainder once the first connection is successful. If an attempt to connect
|
||||
// to all addresses encounters an error, the SubConn will enter
|
||||
// TRANSIENT_FAILURE for a backoff period, and then transition to IDLE.
|
||||
//
|
||||
// Once established, if a connection is lost, the SubConn will transition
|
||||
// directly to IDLE.
|
||||
//
|
||||
// This interface is to be implemented by gRPC. Users should not need their own
|
||||
// implementation of this interface. For situations like testing, any
|
||||
// implementations should embed this interface. This allows gRPC to add new
|
||||
// methods to this interface.
|
||||
type SubConn interface {
|
||||
// UpdateAddresses updates the addresses used in this SubConn.
|
||||
// gRPC checks if currently-connected address is still in the new list.
|
||||
// If it's in the list, the connection will be kept.
|
||||
// If it's not in the list, the connection will gracefully close, and
|
||||
// a new connection will be created.
|
||||
//
|
||||
// This will trigger a state transition for the SubConn.
|
||||
//
|
||||
// Deprecated: this method will be removed. Create new SubConns for new
|
||||
// addresses instead.
|
||||
UpdateAddresses([]resolver.Address)
|
||||
// Connect starts the connecting for this SubConn.
|
||||
Connect()
|
||||
// GetOrBuildProducer returns a reference to the existing Producer for this
|
||||
// ProducerBuilder in this SubConn, or, if one does not currently exist,
|
||||
// creates a new one and returns it. Returns a close function which may be
|
||||
// called when the Producer is no longer needed. Otherwise the producer
|
||||
// will automatically be closed upon connection loss or subchannel close.
|
||||
// Should only be called on a SubConn in state Ready. Otherwise the
|
||||
// producer will be unable to create streams.
|
||||
GetOrBuildProducer(ProducerBuilder) (p Producer, close func())
|
||||
// Shutdown shuts down the SubConn gracefully. Any started RPCs will be
|
||||
// allowed to complete. No future calls should be made on the SubConn.
|
||||
// One final state update will be delivered to the StateListener (or
|
||||
// UpdateSubConnState; deprecated) with ConnectivityState of Shutdown to
|
||||
// indicate the shutdown operation. This may be delivered before
|
||||
// in-progress RPCs are complete and the actual connection is closed.
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
// NewSubConnOptions contains options to create new SubConn.
|
||||
type NewSubConnOptions struct {
|
||||
// CredsBundle is the credentials bundle that will be used in the created
|
||||
|
|
@ -191,6 +129,13 @@ type State struct {
|
|||
// brand new implementation of this interface. For the situations like
|
||||
// testing, the new implementation should embed this interface. This allows
|
||||
// gRPC to add new methods to this interface.
|
||||
//
|
||||
// NOTICE: This interface is intended to be implemented by gRPC, or intercepted
|
||||
// by custom load balancing polices. Users should not need their own complete
|
||||
// implementation of this interface -- they should always delegate to a
|
||||
// ClientConn passed to Builder.Build() by embedding it in their
|
||||
// implementations. An embedded ClientConn must never be nil, or runtime panics
|
||||
// will occur.
|
||||
type ClientConn interface {
|
||||
// NewSubConn is called by balancer to create a new SubConn.
|
||||
// It doesn't block and wait for the connections to be established.
|
||||
|
|
@ -229,6 +174,17 @@ type ClientConn interface {
|
|||
//
|
||||
// Deprecated: Use the Target field in the BuildOptions instead.
|
||||
Target() string
|
||||
|
||||
// MetricsRecorder provides the metrics recorder that balancers can use to
|
||||
// record metrics. Balancer implementations which do not register metrics on
|
||||
// metrics registry and record on them can ignore this method. The returned
|
||||
// MetricsRecorder is guaranteed to never be nil.
|
||||
MetricsRecorder() estats.MetricsRecorder
|
||||
|
||||
// EnforceClientConnEmbedding is included to force implementers to embed
|
||||
// another implementation of this interface, allowing gRPC to add methods
|
||||
// without breaking users.
|
||||
internal.EnforceClientConnEmbedding
|
||||
}
|
||||
|
||||
// BuildOptions contains additional information for Build.
|
||||
|
|
@ -260,10 +216,6 @@ type BuildOptions struct {
|
|||
// same resolver.Target as passed to the resolver. See the documentation for
|
||||
// the resolver.Target type for details about what it contains.
|
||||
Target resolver.Target
|
||||
// MetricsRecorder is the metrics recorder that balancers can use to record
|
||||
// metrics. Balancer implementations which do not register metrics on
|
||||
// metrics registry and record on them can ignore this field.
|
||||
MetricsRecorder estats.MetricsRecorder
|
||||
}
|
||||
|
||||
// Builder creates a balancer.
|
||||
|
|
@ -408,6 +360,10 @@ type Balancer interface {
|
|||
// call SubConn.Shutdown for its existing SubConns; however, this will be
|
||||
// required in a future release, so it is recommended.
|
||||
Close()
|
||||
// ExitIdle instructs the LB policy to reconnect to backends / exit the
|
||||
// IDLE state, if appropriate and possible. Note that SubConns that enter
|
||||
// the IDLE state will not reconnect until SubConn.Connect is called.
|
||||
ExitIdle()
|
||||
}
|
||||
|
||||
// ExitIdler is an optional interface for balancers to implement. If
|
||||
|
|
@ -415,8 +371,8 @@ type Balancer interface {
|
|||
// the ClientConn is idle. If unimplemented, ClientConn.Connect will cause
|
||||
// all SubConns to connect.
|
||||
//
|
||||
// Notice: it will be required for all balancers to implement this in a future
|
||||
// release.
|
||||
// Deprecated: All balancers must implement this interface. This interface will
|
||||
// be removed in a future release.
|
||||
type ExitIdler interface {
|
||||
// ExitIdle instructs the LB policy to reconnect to backends / exit the
|
||||
// IDLE state, if appropriate and possible. Note that SubConns that enter
|
||||
|
|
@ -424,18 +380,6 @@ type ExitIdler interface {
|
|||
ExitIdle()
|
||||
}
|
||||
|
||||
// SubConnState describes the state of a SubConn.
|
||||
type SubConnState struct {
|
||||
// ConnectivityState is the connectivity state of the SubConn.
|
||||
ConnectivityState connectivity.State
|
||||
// ConnectionError is set if the ConnectivityState is TransientFailure,
|
||||
// describing the reason the SubConn failed. Otherwise, it is nil.
|
||||
ConnectionError error
|
||||
// connectedAddr contains the connected address when ConnectivityState is
|
||||
// Ready. Otherwise, it is indeterminate.
|
||||
connectedAddress resolver.Address
|
||||
}
|
||||
|
||||
// ClientConnState describes the state of a ClientConn relevant to the
|
||||
// balancer.
|
||||
type ClientConnState struct {
|
||||
|
|
@ -448,22 +392,3 @@ type ClientConnState struct {
|
|||
// ErrBadResolverState may be returned by UpdateClientConnState to indicate a
|
||||
// problem with the provided name resolver data.
|
||||
var ErrBadResolverState = errors.New("bad resolver state")
|
||||
|
||||
// A ProducerBuilder is a simple constructor for a Producer. It is used by the
|
||||
// SubConn to create producers when needed.
|
||||
type ProducerBuilder interface {
|
||||
// Build creates a Producer. The first parameter is always a
|
||||
// grpc.ClientConnInterface (a type to allow creating RPCs/streams on the
|
||||
// associated SubConn), but is declared as `any` to avoid a dependency
|
||||
// cycle. Build also returns a close function that will be called when all
|
||||
// references to the Producer have been given up for a SubConn, or when a
|
||||
// connectivity state change occurs on the SubConn. The close function
|
||||
// should always block until all asynchronous cleanup work is completed.
|
||||
Build(grpcClientConnInterface any) (p Producer, close func())
|
||||
}
|
||||
|
||||
// A Producer is a type shared among potentially many consumers. It is
|
||||
// associated with a SubConn, and an implementation will typically contain
|
||||
// other methods to provide additional functionality, e.g. configuration or
|
||||
// subscription registration.
|
||||
type Producer any
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func (bb *baseBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) ba
|
|||
cc: cc,
|
||||
pickerBuilder: bb.pickerBuilder,
|
||||
|
||||
subConns: resolver.NewAddressMap(),
|
||||
subConns: resolver.NewAddressMapV2[balancer.SubConn](),
|
||||
scStates: make(map[balancer.SubConn]connectivity.State),
|
||||
csEvltr: &balancer.ConnectivityStateEvaluator{},
|
||||
config: bb.config,
|
||||
|
|
@ -65,7 +65,7 @@ type baseBalancer struct {
|
|||
csEvltr *balancer.ConnectivityStateEvaluator
|
||||
state connectivity.State
|
||||
|
||||
subConns *resolver.AddressMap
|
||||
subConns *resolver.AddressMapV2[balancer.SubConn]
|
||||
scStates map[balancer.SubConn]connectivity.State
|
||||
picker balancer.Picker
|
||||
config Config
|
||||
|
|
@ -100,7 +100,7 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
|
|||
// Successful resolution; clear resolver error and ensure we return nil.
|
||||
b.resolverErr = nil
|
||||
// addrsSet is the set converted from addrs, it's used for quick lookup of an address.
|
||||
addrsSet := resolver.NewAddressMap()
|
||||
addrsSet := resolver.NewAddressMapV2[any]()
|
||||
for _, a := range s.ResolverState.Addresses {
|
||||
addrsSet.Set(a, nil)
|
||||
if _, ok := b.subConns.Get(a); !ok {
|
||||
|
|
@ -122,8 +122,7 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
|
|||
}
|
||||
}
|
||||
for _, a := range b.subConns.Keys() {
|
||||
sci, _ := b.subConns.Get(a)
|
||||
sc := sci.(balancer.SubConn)
|
||||
sc, _ := b.subConns.Get(a)
|
||||
// a was removed by resolver.
|
||||
if _, ok := addrsSet.Get(a); !ok {
|
||||
sc.Shutdown()
|
||||
|
|
@ -173,8 +172,7 @@ func (b *baseBalancer) regeneratePicker() {
|
|||
|
||||
// Filter out all ready SCs from full subConn map.
|
||||
for _, addr := range b.subConns.Keys() {
|
||||
sci, _ := b.subConns.Get(addr)
|
||||
sc := sci.(balancer.SubConn)
|
||||
sc, _ := b.subConns.Get(addr)
|
||||
if st, ok := b.scStates[sc]; ok && st == connectivity.Ready {
|
||||
readySCs[sc] = SubConnInfo{Address: addr}
|
||||
}
|
||||
|
|
|
|||
372
vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go
generated
vendored
Normal file
372
vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go
generated
vendored
Normal file
|
|
@ -0,0 +1,372 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2024 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
// Package endpointsharding implements a load balancing policy that manages
|
||||
// homogeneous child policies each owning a single endpoint.
|
||||
//
|
||||
// # Experimental
|
||||
//
|
||||
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
|
||||
// later release.
|
||||
package endpointsharding
|
||||
|
||||
import (
|
||||
"errors"
|
||||
rand "math/rand/v2"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/balancer/base"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
// ChildState is the balancer state of a child along with the endpoint which
|
||||
// identifies the child balancer.
|
||||
type ChildState struct {
|
||||
Endpoint resolver.Endpoint
|
||||
State balancer.State
|
||||
|
||||
// Balancer exposes only the ExitIdler interface of the child LB policy.
|
||||
// Other methods of the child policy are called only by endpointsharding.
|
||||
Balancer ExitIdler
|
||||
}
|
||||
|
||||
// ExitIdler provides access to only the ExitIdle method of the child balancer.
|
||||
type ExitIdler interface {
|
||||
// ExitIdle instructs the LB policy to reconnect to backends / exit the
|
||||
// IDLE state, if appropriate and possible. Note that SubConns that enter
|
||||
// the IDLE state will not reconnect until SubConn.Connect is called.
|
||||
ExitIdle()
|
||||
}
|
||||
|
||||
// Options are the options to configure the behaviour of the
|
||||
// endpointsharding balancer.
|
||||
type Options struct {
|
||||
// DisableAutoReconnect allows the balancer to keep child balancer in the
|
||||
// IDLE state until they are explicitly triggered to exit using the
|
||||
// ChildState obtained from the endpointsharding picker. When set to false,
|
||||
// the endpointsharding balancer will automatically call ExitIdle on child
|
||||
// connections that report IDLE.
|
||||
DisableAutoReconnect bool
|
||||
}
|
||||
|
||||
// ChildBuilderFunc creates a new balancer with the ClientConn. It has the same
|
||||
// type as the balancer.Builder.Build method.
|
||||
type ChildBuilderFunc func(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer
|
||||
|
||||
// NewBalancer returns a load balancing policy that manages homogeneous child
|
||||
// policies each owning a single endpoint. The endpointsharding balancer
|
||||
// forwards the LoadBalancingConfig in ClientConn state updates to its children.
|
||||
func NewBalancer(cc balancer.ClientConn, opts balancer.BuildOptions, childBuilder ChildBuilderFunc, esOpts Options) balancer.Balancer {
|
||||
es := &endpointSharding{
|
||||
cc: cc,
|
||||
bOpts: opts,
|
||||
esOpts: esOpts,
|
||||
childBuilder: childBuilder,
|
||||
}
|
||||
es.children.Store(resolver.NewEndpointMap[*balancerWrapper]())
|
||||
return es
|
||||
}
|
||||
|
||||
// endpointSharding is a balancer that wraps child balancers. It creates a child
|
||||
// balancer with child config for every unique Endpoint received. It updates the
|
||||
// child states on any update from parent or child.
|
||||
type endpointSharding struct {
|
||||
cc balancer.ClientConn
|
||||
bOpts balancer.BuildOptions
|
||||
esOpts Options
|
||||
childBuilder ChildBuilderFunc
|
||||
|
||||
// childMu synchronizes calls to any single child. It must be held for all
|
||||
// calls into a child. To avoid deadlocks, do not acquire childMu while
|
||||
// holding mu.
|
||||
childMu sync.Mutex
|
||||
children atomic.Pointer[resolver.EndpointMap[*balancerWrapper]]
|
||||
|
||||
// inhibitChildUpdates is set during UpdateClientConnState/ResolverError
|
||||
// calls (calls to children will each produce an update, only want one
|
||||
// update).
|
||||
inhibitChildUpdates atomic.Bool
|
||||
|
||||
// mu synchronizes access to the state stored in balancerWrappers in the
|
||||
// children field. mu must not be held during calls into a child since
|
||||
// synchronous calls back from the child may require taking mu, causing a
|
||||
// deadlock. To avoid deadlocks, do not acquire childMu while holding mu.
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// UpdateClientConnState creates a child for new endpoints and deletes children
|
||||
// for endpoints that are no longer present. It also updates all the children,
|
||||
// and sends a single synchronous update of the childrens' aggregated state at
|
||||
// the end of the UpdateClientConnState operation. If any endpoint has no
|
||||
// addresses it will ignore that endpoint. Otherwise, returns first error found
|
||||
// from a child, but fully processes the new update.
|
||||
func (es *endpointSharding) UpdateClientConnState(state balancer.ClientConnState) error {
|
||||
es.childMu.Lock()
|
||||
defer es.childMu.Unlock()
|
||||
|
||||
es.inhibitChildUpdates.Store(true)
|
||||
defer func() {
|
||||
es.inhibitChildUpdates.Store(false)
|
||||
es.updateState()
|
||||
}()
|
||||
var ret error
|
||||
|
||||
children := es.children.Load()
|
||||
newChildren := resolver.NewEndpointMap[*balancerWrapper]()
|
||||
|
||||
// Update/Create new children.
|
||||
for _, endpoint := range state.ResolverState.Endpoints {
|
||||
if _, ok := newChildren.Get(endpoint); ok {
|
||||
// Endpoint child was already created, continue to avoid duplicate
|
||||
// update.
|
||||
continue
|
||||
}
|
||||
childBalancer, ok := children.Get(endpoint)
|
||||
if ok {
|
||||
// Endpoint attributes may have changed, update the stored endpoint.
|
||||
es.mu.Lock()
|
||||
childBalancer.childState.Endpoint = endpoint
|
||||
es.mu.Unlock()
|
||||
} else {
|
||||
childBalancer = &balancerWrapper{
|
||||
childState: ChildState{Endpoint: endpoint},
|
||||
ClientConn: es.cc,
|
||||
es: es,
|
||||
}
|
||||
childBalancer.childState.Balancer = childBalancer
|
||||
childBalancer.child = es.childBuilder(childBalancer, es.bOpts)
|
||||
}
|
||||
newChildren.Set(endpoint, childBalancer)
|
||||
if err := childBalancer.updateClientConnStateLocked(balancer.ClientConnState{
|
||||
BalancerConfig: state.BalancerConfig,
|
||||
ResolverState: resolver.State{
|
||||
Endpoints: []resolver.Endpoint{endpoint},
|
||||
Attributes: state.ResolverState.Attributes,
|
||||
},
|
||||
}); err != nil && ret == nil {
|
||||
// Return first error found, and always commit full processing of
|
||||
// updating children. If desired to process more specific errors
|
||||
// across all endpoints, caller should make these specific
|
||||
// validations, this is a current limitation for simplicity sake.
|
||||
ret = err
|
||||
}
|
||||
}
|
||||
// Delete old children that are no longer present.
|
||||
for _, e := range children.Keys() {
|
||||
child, _ := children.Get(e)
|
||||
if _, ok := newChildren.Get(e); !ok {
|
||||
child.closeLocked()
|
||||
}
|
||||
}
|
||||
es.children.Store(newChildren)
|
||||
if newChildren.Len() == 0 {
|
||||
return balancer.ErrBadResolverState
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// ResolverError forwards the resolver error to all of the endpointSharding's
|
||||
// children and sends a single synchronous update of the childStates at the end
|
||||
// of the ResolverError operation.
|
||||
func (es *endpointSharding) ResolverError(err error) {
|
||||
es.childMu.Lock()
|
||||
defer es.childMu.Unlock()
|
||||
es.inhibitChildUpdates.Store(true)
|
||||
defer func() {
|
||||
es.inhibitChildUpdates.Store(false)
|
||||
es.updateState()
|
||||
}()
|
||||
children := es.children.Load()
|
||||
for _, child := range children.Values() {
|
||||
child.resolverErrorLocked(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (es *endpointSharding) UpdateSubConnState(balancer.SubConn, balancer.SubConnState) {
|
||||
// UpdateSubConnState is deprecated.
|
||||
}
|
||||
|
||||
func (es *endpointSharding) Close() {
|
||||
es.childMu.Lock()
|
||||
defer es.childMu.Unlock()
|
||||
children := es.children.Load()
|
||||
for _, child := range children.Values() {
|
||||
child.closeLocked()
|
||||
}
|
||||
}
|
||||
|
||||
func (es *endpointSharding) ExitIdle() {
|
||||
es.childMu.Lock()
|
||||
defer es.childMu.Unlock()
|
||||
for _, bw := range es.children.Load().Values() {
|
||||
if !bw.isClosed {
|
||||
bw.child.ExitIdle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// updateState updates this component's state. It sends the aggregated state,
|
||||
// and a picker with round robin behavior with all the child states present if
|
||||
// needed.
|
||||
func (es *endpointSharding) updateState() {
|
||||
if es.inhibitChildUpdates.Load() {
|
||||
return
|
||||
}
|
||||
var readyPickers, connectingPickers, idlePickers, transientFailurePickers []balancer.Picker
|
||||
|
||||
es.mu.Lock()
|
||||
defer es.mu.Unlock()
|
||||
|
||||
children := es.children.Load()
|
||||
childStates := make([]ChildState, 0, children.Len())
|
||||
|
||||
for _, child := range children.Values() {
|
||||
childState := child.childState
|
||||
childStates = append(childStates, childState)
|
||||
childPicker := childState.State.Picker
|
||||
switch childState.State.ConnectivityState {
|
||||
case connectivity.Ready:
|
||||
readyPickers = append(readyPickers, childPicker)
|
||||
case connectivity.Connecting:
|
||||
connectingPickers = append(connectingPickers, childPicker)
|
||||
case connectivity.Idle:
|
||||
idlePickers = append(idlePickers, childPicker)
|
||||
case connectivity.TransientFailure:
|
||||
transientFailurePickers = append(transientFailurePickers, childPicker)
|
||||
// connectivity.Shutdown shouldn't appear.
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the round robin picker based off the aggregated state. Whatever
|
||||
// the aggregated state, use the pickers present that are currently in that
|
||||
// state only.
|
||||
var aggState connectivity.State
|
||||
var pickers []balancer.Picker
|
||||
if len(readyPickers) >= 1 {
|
||||
aggState = connectivity.Ready
|
||||
pickers = readyPickers
|
||||
} else if len(connectingPickers) >= 1 {
|
||||
aggState = connectivity.Connecting
|
||||
pickers = connectingPickers
|
||||
} else if len(idlePickers) >= 1 {
|
||||
aggState = connectivity.Idle
|
||||
pickers = idlePickers
|
||||
} else if len(transientFailurePickers) >= 1 {
|
||||
aggState = connectivity.TransientFailure
|
||||
pickers = transientFailurePickers
|
||||
} else {
|
||||
aggState = connectivity.TransientFailure
|
||||
pickers = []balancer.Picker{base.NewErrPicker(errors.New("no children to pick from"))}
|
||||
} // No children (resolver error before valid update).
|
||||
p := &pickerWithChildStates{
|
||||
pickers: pickers,
|
||||
childStates: childStates,
|
||||
next: uint32(rand.IntN(len(pickers))),
|
||||
}
|
||||
es.cc.UpdateState(balancer.State{
|
||||
ConnectivityState: aggState,
|
||||
Picker: p,
|
||||
})
|
||||
}
|
||||
|
||||
// pickerWithChildStates delegates to the pickers it holds in a round robin
|
||||
// fashion. It also contains the childStates of all the endpointSharding's
|
||||
// children.
|
||||
type pickerWithChildStates struct {
|
||||
pickers []balancer.Picker
|
||||
childStates []ChildState
|
||||
next uint32
|
||||
}
|
||||
|
||||
func (p *pickerWithChildStates) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
|
||||
nextIndex := atomic.AddUint32(&p.next, 1)
|
||||
picker := p.pickers[nextIndex%uint32(len(p.pickers))]
|
||||
return picker.Pick(info)
|
||||
}
|
||||
|
||||
// ChildStatesFromPicker returns the state of all the children managed by the
|
||||
// endpoint sharding balancer that created this picker.
|
||||
func ChildStatesFromPicker(picker balancer.Picker) []ChildState {
|
||||
p, ok := picker.(*pickerWithChildStates)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return p.childStates
|
||||
}
|
||||
|
||||
// balancerWrapper is a wrapper of a balancer. It ID's a child balancer by
|
||||
// endpoint, and persists recent child balancer state.
|
||||
type balancerWrapper struct {
|
||||
// The following fields are initialized at build time and read-only after
|
||||
// that and therefore do not need to be guarded by a mutex.
|
||||
|
||||
// child contains the wrapped balancer. Access its methods only through
|
||||
// methods on balancerWrapper to ensure proper synchronization
|
||||
child balancer.Balancer
|
||||
balancer.ClientConn // embed to intercept UpdateState, doesn't deal with SubConns
|
||||
|
||||
es *endpointSharding
|
||||
|
||||
// Access to the following fields is guarded by es.mu.
|
||||
|
||||
childState ChildState
|
||||
isClosed bool
|
||||
}
|
||||
|
||||
func (bw *balancerWrapper) UpdateState(state balancer.State) {
|
||||
bw.es.mu.Lock()
|
||||
bw.childState.State = state
|
||||
bw.es.mu.Unlock()
|
||||
if state.ConnectivityState == connectivity.Idle && !bw.es.esOpts.DisableAutoReconnect {
|
||||
bw.ExitIdle()
|
||||
}
|
||||
bw.es.updateState()
|
||||
}
|
||||
|
||||
// ExitIdle pings an IDLE child balancer to exit idle in a new goroutine to
|
||||
// avoid deadlocks due to synchronous balancer state updates.
|
||||
func (bw *balancerWrapper) ExitIdle() {
|
||||
go func() {
|
||||
bw.es.childMu.Lock()
|
||||
if !bw.isClosed {
|
||||
bw.child.ExitIdle()
|
||||
}
|
||||
bw.es.childMu.Unlock()
|
||||
}()
|
||||
}
|
||||
|
||||
// updateClientConnStateLocked delivers the ClientConnState to the child
|
||||
// balancer. Callers must hold the child mutex of the parent endpointsharding
|
||||
// balancer.
|
||||
func (bw *balancerWrapper) updateClientConnStateLocked(ccs balancer.ClientConnState) error {
|
||||
return bw.child.UpdateClientConnState(ccs)
|
||||
}
|
||||
|
||||
// closeLocked closes the child balancer. Callers must hold the child mutext of
|
||||
// the parent endpointsharding balancer.
|
||||
func (bw *balancerWrapper) closeLocked() {
|
||||
bw.child.Close()
|
||||
bw.isClosed = true
|
||||
}
|
||||
|
||||
func (bw *balancerWrapper) resolverErrorLocked(err error) {
|
||||
bw.child.ResolverError(err)
|
||||
}
|
||||
|
|
@ -18,7 +18,18 @@
|
|||
// Package internal contains code internal to the pickfirst package.
|
||||
package internal
|
||||
|
||||
import "math/rand"
|
||||
import (
|
||||
rand "math/rand/v2"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RandShuffle pseudo-randomizes the order of addresses.
|
||||
var RandShuffle = rand.Shuffle
|
||||
var (
|
||||
// RandShuffle pseudo-randomizes the order of addresses.
|
||||
RandShuffle = rand.Shuffle
|
||||
// TimeAfterFunc allows mocking the timer for testing connection delay
|
||||
// related functionality.
|
||||
TimeAfterFunc = func(d time.Duration, f func()) func() {
|
||||
timer := time.AfterFunc(d, f)
|
||||
return func() { timer.Stop() }
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
rand "math/rand/v2"
|
||||
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/balancer/pickfirst/internal"
|
||||
|
|
|
|||
495
vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
generated
vendored
495
vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
generated
vendored
|
|
@ -29,11 +29,15 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/balancer/pickfirst/internal"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
expstats "google.golang.org/grpc/experimental/stats"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal/envconfig"
|
||||
internalgrpclog "google.golang.org/grpc/internal/grpclog"
|
||||
|
|
@ -50,26 +54,68 @@ func init() {
|
|||
balancer.Register(pickfirstBuilder{})
|
||||
}
|
||||
|
||||
// enableHealthListenerKeyType is a unique key type used in resolver
|
||||
// attributes to indicate whether the health listener usage is enabled.
|
||||
type enableHealthListenerKeyType struct{}
|
||||
|
||||
var (
|
||||
logger = grpclog.Component("pick-first-leaf-lb")
|
||||
// Name is the name of the pick_first_leaf balancer.
|
||||
// It is changed to "pick_first" in init() if this balancer is to be
|
||||
// registered as the default pickfirst.
|
||||
Name = "pick_first_leaf"
|
||||
Name = "pick_first_leaf"
|
||||
disconnectionsMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{
|
||||
Name: "grpc.lb.pick_first.disconnections",
|
||||
Description: "EXPERIMENTAL. Number of times the selected subchannel becomes disconnected.",
|
||||
Unit: "disconnection",
|
||||
Labels: []string{"grpc.target"},
|
||||
Default: false,
|
||||
})
|
||||
connectionAttemptsSucceededMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{
|
||||
Name: "grpc.lb.pick_first.connection_attempts_succeeded",
|
||||
Description: "EXPERIMENTAL. Number of successful connection attempts.",
|
||||
Unit: "attempt",
|
||||
Labels: []string{"grpc.target"},
|
||||
Default: false,
|
||||
})
|
||||
connectionAttemptsFailedMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{
|
||||
Name: "grpc.lb.pick_first.connection_attempts_failed",
|
||||
Description: "EXPERIMENTAL. Number of failed connection attempts.",
|
||||
Unit: "attempt",
|
||||
Labels: []string{"grpc.target"},
|
||||
Default: false,
|
||||
})
|
||||
)
|
||||
|
||||
// TODO: change to pick-first when this becomes the default pick_first policy.
|
||||
const logPrefix = "[pick-first-leaf-lb %p] "
|
||||
const (
|
||||
// TODO: change to pick-first when this becomes the default pick_first policy.
|
||||
logPrefix = "[pick-first-leaf-lb %p] "
|
||||
// connectionDelayInterval is the time to wait for during the happy eyeballs
|
||||
// pass before starting the next connection attempt.
|
||||
connectionDelayInterval = 250 * time.Millisecond
|
||||
)
|
||||
|
||||
type ipAddrFamily int
|
||||
|
||||
const (
|
||||
// ipAddrFamilyUnknown represents strings that can't be parsed as an IP
|
||||
// address.
|
||||
ipAddrFamilyUnknown ipAddrFamily = iota
|
||||
ipAddrFamilyV4
|
||||
ipAddrFamilyV6
|
||||
)
|
||||
|
||||
type pickfirstBuilder struct{}
|
||||
|
||||
func (pickfirstBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
|
||||
func (pickfirstBuilder) Build(cc balancer.ClientConn, bo balancer.BuildOptions) balancer.Balancer {
|
||||
b := &pickfirstBalancer{
|
||||
cc: cc,
|
||||
addressList: addressList{},
|
||||
subConns: resolver.NewAddressMap(),
|
||||
state: connectivity.Connecting,
|
||||
mu: sync.Mutex{},
|
||||
cc: cc,
|
||||
target: bo.Target.String(),
|
||||
metricsRecorder: cc.MetricsRecorder(),
|
||||
|
||||
subConns: resolver.NewAddressMapV2[*scData](),
|
||||
state: connectivity.Connecting,
|
||||
cancelConnectionTimer: func() {},
|
||||
}
|
||||
b.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(logPrefix, b))
|
||||
return b
|
||||
|
|
@ -87,6 +133,13 @@ func (pickfirstBuilder) ParseConfig(js json.RawMessage) (serviceconfig.LoadBalan
|
|||
return cfg, nil
|
||||
}
|
||||
|
||||
// EnableHealthListener updates the state to configure pickfirst for using a
|
||||
// generic health listener.
|
||||
func EnableHealthListener(state resolver.State) resolver.State {
|
||||
state.Attributes = state.Attributes.WithValue(enableHealthListenerKeyType{}, true)
|
||||
return state
|
||||
}
|
||||
|
||||
type pfConfig struct {
|
||||
serviceconfig.LoadBalancingConfig `json:"-"`
|
||||
|
||||
|
|
@ -104,14 +157,19 @@ type scData struct {
|
|||
subConn balancer.SubConn
|
||||
addr resolver.Address
|
||||
|
||||
state connectivity.State
|
||||
lastErr error
|
||||
rawConnectivityState connectivity.State
|
||||
// The effective connectivity state based on raw connectivity, health state
|
||||
// and after following sticky TransientFailure behaviour defined in A62.
|
||||
effectiveState connectivity.State
|
||||
lastErr error
|
||||
connectionFailedInFirstPass bool
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) newSCData(addr resolver.Address) (*scData, error) {
|
||||
sd := &scData{
|
||||
state: connectivity.Idle,
|
||||
addr: addr,
|
||||
rawConnectivityState: connectivity.Idle,
|
||||
effectiveState: connectivity.Idle,
|
||||
addr: addr,
|
||||
}
|
||||
sc, err := b.cc.NewSubConn([]resolver.Address{addr}, balancer.NewSubConnOptions{
|
||||
StateListener: func(state balancer.SubConnState) {
|
||||
|
|
@ -128,19 +186,25 @@ func (b *pickfirstBalancer) newSCData(addr resolver.Address) (*scData, error) {
|
|||
type pickfirstBalancer struct {
|
||||
// The following fields are initialized at build time and read-only after
|
||||
// that and therefore do not need to be guarded by a mutex.
|
||||
logger *internalgrpclog.PrefixLogger
|
||||
cc balancer.ClientConn
|
||||
logger *internalgrpclog.PrefixLogger
|
||||
cc balancer.ClientConn
|
||||
target string
|
||||
metricsRecorder expstats.MetricsRecorder // guaranteed to be non nil
|
||||
|
||||
// The mutex is used to ensure synchronization of updates triggered
|
||||
// from the idle picker and the already serialized resolver,
|
||||
// SubConn state updates.
|
||||
mu sync.Mutex
|
||||
mu sync.Mutex
|
||||
// State reported to the channel based on SubConn states and resolver
|
||||
// updates.
|
||||
state connectivity.State
|
||||
// scData for active subonns mapped by address.
|
||||
subConns *resolver.AddressMap
|
||||
addressList addressList
|
||||
firstPass bool
|
||||
numTF int
|
||||
subConns *resolver.AddressMapV2[*scData]
|
||||
addressList addressList
|
||||
firstPass bool
|
||||
numTF int
|
||||
cancelConnectionTimer func()
|
||||
healthCheckingEnabled bool
|
||||
}
|
||||
|
||||
// ResolverError is called by the ClientConn when the name resolver produces
|
||||
|
|
@ -166,7 +230,7 @@ func (b *pickfirstBalancer) resolverErrorLocked(err error) {
|
|||
return
|
||||
}
|
||||
|
||||
b.cc.UpdateState(balancer.State{
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.TransientFailure,
|
||||
Picker: &picker{err: fmt.Errorf("name resolver error: %v", err)},
|
||||
})
|
||||
|
|
@ -175,15 +239,16 @@ func (b *pickfirstBalancer) resolverErrorLocked(err error) {
|
|||
func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState) error {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
b.cancelConnectionTimer()
|
||||
if len(state.ResolverState.Addresses) == 0 && len(state.ResolverState.Endpoints) == 0 {
|
||||
// Cleanup state pertaining to the previous resolver state.
|
||||
// Treat an empty address list like an error by calling b.ResolverError.
|
||||
b.state = connectivity.TransientFailure
|
||||
b.closeSubConnsLocked()
|
||||
b.addressList.updateAddrs(nil)
|
||||
b.resolverErrorLocked(errors.New("produced zero addresses"))
|
||||
return balancer.ErrBadResolverState
|
||||
}
|
||||
b.healthCheckingEnabled = state.ResolverState.Attributes.Value(enableHealthListenerKeyType{}) != nil
|
||||
cfg, ok := state.BalancerConfig.(pfConfig)
|
||||
if state.BalancerConfig != nil && !ok {
|
||||
return fmt.Errorf("pickfirst: received illegal BalancerConfig (type %T): %v: %w", state.BalancerConfig, state.BalancerConfig, balancer.ErrBadResolverState)
|
||||
|
|
@ -206,9 +271,6 @@ func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState
|
|||
// "Flatten the list by concatenating the ordered list of addresses for
|
||||
// each of the endpoints, in order." - A61
|
||||
for _, endpoint := range endpoints {
|
||||
// "In the flattened list, interleave addresses from the two address
|
||||
// families, as per RFC-8305 section 4." - A61
|
||||
// TODO: support the above language.
|
||||
newAddrs = append(newAddrs, endpoint.Addresses...)
|
||||
}
|
||||
} else {
|
||||
|
|
@ -231,16 +293,17 @@ func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState
|
|||
// Not de-duplicating would result in attempting to connect to the same
|
||||
// SubConn multiple times in the same pass. We don't want this.
|
||||
newAddrs = deDupAddresses(newAddrs)
|
||||
newAddrs = interleaveAddresses(newAddrs)
|
||||
|
||||
// Since we have a new set of addresses, we are again at first pass.
|
||||
b.firstPass = true
|
||||
prevAddr := b.addressList.currentAddress()
|
||||
prevSCData, found := b.subConns.Get(prevAddr)
|
||||
prevAddrsCount := b.addressList.size()
|
||||
isPrevRawConnectivityStateReady := found && prevSCData.rawConnectivityState == connectivity.Ready
|
||||
b.addressList.updateAddrs(newAddrs)
|
||||
|
||||
// If the previous ready SubConn exists in new address list,
|
||||
// keep this connection and don't create new SubConns.
|
||||
prevAddr := b.addressList.currentAddress()
|
||||
prevAddrsCount := b.addressList.size()
|
||||
b.addressList.updateAddrs(newAddrs)
|
||||
if b.state == connectivity.Ready && b.addressList.seekTo(prevAddr) {
|
||||
if isPrevRawConnectivityStateReady && b.addressList.seekTo(prevAddr) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -252,18 +315,17 @@ func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState
|
|||
// we should still enter CONNECTING because the sticky TF behaviour
|
||||
// mentioned in A62 applies only when the TRANSIENT_FAILURE is reported
|
||||
// due to connectivity failures.
|
||||
if b.state == connectivity.Ready || b.state == connectivity.Connecting || prevAddrsCount == 0 {
|
||||
if isPrevRawConnectivityStateReady || b.state == connectivity.Connecting || prevAddrsCount == 0 {
|
||||
// Start connection attempt at first address.
|
||||
b.state = connectivity.Connecting
|
||||
b.cc.UpdateState(balancer.State{
|
||||
b.forceUpdateConcludedStateLocked(balancer.State{
|
||||
ConnectivityState: connectivity.Connecting,
|
||||
Picker: &picker{err: balancer.ErrNoSubConnAvailable},
|
||||
})
|
||||
b.requestConnectionLocked()
|
||||
b.startFirstPassLocked()
|
||||
} else if b.state == connectivity.TransientFailure {
|
||||
// If we're in TRANSIENT_FAILURE, we stay in TRANSIENT_FAILURE until
|
||||
// we're READY. See A62.
|
||||
b.requestConnectionLocked()
|
||||
b.startFirstPassLocked()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -278,6 +340,7 @@ func (b *pickfirstBalancer) Close() {
|
|||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
b.closeSubConnsLocked()
|
||||
b.cancelConnectionTimer()
|
||||
b.state = connectivity.Shutdown
|
||||
}
|
||||
|
||||
|
|
@ -287,22 +350,31 @@ func (b *pickfirstBalancer) Close() {
|
|||
func (b *pickfirstBalancer) ExitIdle() {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
if b.state == connectivity.Idle && b.addressList.currentAddress() == b.addressList.first() {
|
||||
b.firstPass = true
|
||||
b.requestConnectionLocked()
|
||||
if b.state == connectivity.Idle {
|
||||
b.startFirstPassLocked()
|
||||
}
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) startFirstPassLocked() {
|
||||
b.firstPass = true
|
||||
b.numTF = 0
|
||||
// Reset the connection attempt record for existing SubConns.
|
||||
for _, sd := range b.subConns.Values() {
|
||||
sd.connectionFailedInFirstPass = false
|
||||
}
|
||||
b.requestConnectionLocked()
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) closeSubConnsLocked() {
|
||||
for _, sd := range b.subConns.Values() {
|
||||
sd.(*scData).subConn.Shutdown()
|
||||
sd.subConn.Shutdown()
|
||||
}
|
||||
b.subConns = resolver.NewAddressMap()
|
||||
b.subConns = resolver.NewAddressMapV2[*scData]()
|
||||
}
|
||||
|
||||
// deDupAddresses ensures that each address appears only once in the slice.
|
||||
func deDupAddresses(addrs []resolver.Address) []resolver.Address {
|
||||
seenAddrs := resolver.NewAddressMap()
|
||||
seenAddrs := resolver.NewAddressMapV2[*scData]()
|
||||
retAddrs := []resolver.Address{}
|
||||
|
||||
for _, addr := range addrs {
|
||||
|
|
@ -314,6 +386,70 @@ func deDupAddresses(addrs []resolver.Address) []resolver.Address {
|
|||
return retAddrs
|
||||
}
|
||||
|
||||
// interleaveAddresses interleaves addresses of both families (IPv4 and IPv6)
|
||||
// as per RFC-8305 section 4.
|
||||
// Whichever address family is first in the list is followed by an address of
|
||||
// the other address family; that is, if the first address in the list is IPv6,
|
||||
// then the first IPv4 address should be moved up in the list to be second in
|
||||
// the list. It doesn't support configuring "First Address Family Count", i.e.
|
||||
// there will always be a single member of the first address family at the
|
||||
// beginning of the interleaved list.
|
||||
// Addresses that are neither IPv4 nor IPv6 are treated as part of a third
|
||||
// "unknown" family for interleaving.
|
||||
// See: https://datatracker.ietf.org/doc/html/rfc8305#autoid-6
|
||||
func interleaveAddresses(addrs []resolver.Address) []resolver.Address {
|
||||
familyAddrsMap := map[ipAddrFamily][]resolver.Address{}
|
||||
interleavingOrder := []ipAddrFamily{}
|
||||
for _, addr := range addrs {
|
||||
family := addressFamily(addr.Addr)
|
||||
if _, found := familyAddrsMap[family]; !found {
|
||||
interleavingOrder = append(interleavingOrder, family)
|
||||
}
|
||||
familyAddrsMap[family] = append(familyAddrsMap[family], addr)
|
||||
}
|
||||
|
||||
interleavedAddrs := make([]resolver.Address, 0, len(addrs))
|
||||
|
||||
for curFamilyIdx := 0; len(interleavedAddrs) < len(addrs); curFamilyIdx = (curFamilyIdx + 1) % len(interleavingOrder) {
|
||||
// Some IP types may have fewer addresses than others, so we look for
|
||||
// the next type that has a remaining member to add to the interleaved
|
||||
// list.
|
||||
family := interleavingOrder[curFamilyIdx]
|
||||
remainingMembers := familyAddrsMap[family]
|
||||
if len(remainingMembers) > 0 {
|
||||
interleavedAddrs = append(interleavedAddrs, remainingMembers[0])
|
||||
familyAddrsMap[family] = remainingMembers[1:]
|
||||
}
|
||||
}
|
||||
|
||||
return interleavedAddrs
|
||||
}
|
||||
|
||||
// addressFamily returns the ipAddrFamily after parsing the address string.
|
||||
// If the address isn't of the format "ip-address:port", it returns
|
||||
// ipAddrFamilyUnknown. The address may be valid even if it's not an IP when
|
||||
// using a resolver like passthrough where the address may be a hostname in
|
||||
// some format that the dialer can resolve.
|
||||
func addressFamily(address string) ipAddrFamily {
|
||||
// Parse the IP after removing the port.
|
||||
host, _, err := net.SplitHostPort(address)
|
||||
if err != nil {
|
||||
return ipAddrFamilyUnknown
|
||||
}
|
||||
ip, err := netip.ParseAddr(host)
|
||||
if err != nil {
|
||||
return ipAddrFamilyUnknown
|
||||
}
|
||||
switch {
|
||||
case ip.Is4() || ip.Is4In6():
|
||||
return ipAddrFamilyV4
|
||||
case ip.Is6():
|
||||
return ipAddrFamilyV6
|
||||
default:
|
||||
return ipAddrFamilyUnknown
|
||||
}
|
||||
}
|
||||
|
||||
// reconcileSubConnsLocked updates the active subchannels based on a new address
|
||||
// list from the resolver. It does this by:
|
||||
// - closing subchannels: any existing subchannels associated with addresses
|
||||
|
|
@ -324,7 +460,7 @@ func deDupAddresses(addrs []resolver.Address) []resolver.Address {
|
|||
// This ensures that the subchannel map accurately reflects the current set of
|
||||
// addresses received from the name resolver.
|
||||
func (b *pickfirstBalancer) reconcileSubConnsLocked(newAddrs []resolver.Address) {
|
||||
newAddrsMap := resolver.NewAddressMap()
|
||||
newAddrsMap := resolver.NewAddressMapV2[bool]()
|
||||
for _, addr := range newAddrs {
|
||||
newAddrsMap.Set(addr, true)
|
||||
}
|
||||
|
|
@ -334,7 +470,7 @@ func (b *pickfirstBalancer) reconcileSubConnsLocked(newAddrs []resolver.Address)
|
|||
continue
|
||||
}
|
||||
val, _ := b.subConns.Get(oldAddr)
|
||||
val.(*scData).subConn.Shutdown()
|
||||
val.subConn.Shutdown()
|
||||
b.subConns.Delete(oldAddr)
|
||||
}
|
||||
}
|
||||
|
|
@ -342,13 +478,13 @@ func (b *pickfirstBalancer) reconcileSubConnsLocked(newAddrs []resolver.Address)
|
|||
// shutdownRemainingLocked shuts down remaining subConns. Called when a subConn
|
||||
// becomes ready, which means that all other subConn must be shutdown.
|
||||
func (b *pickfirstBalancer) shutdownRemainingLocked(selected *scData) {
|
||||
for _, v := range b.subConns.Values() {
|
||||
sd := v.(*scData)
|
||||
b.cancelConnectionTimer()
|
||||
for _, sd := range b.subConns.Values() {
|
||||
if sd.subConn != selected.subConn {
|
||||
sd.subConn.Shutdown()
|
||||
}
|
||||
}
|
||||
b.subConns = resolver.NewAddressMap()
|
||||
b.subConns = resolver.NewAddressMapV2[*scData]()
|
||||
b.subConns.Set(selected.addr, selected)
|
||||
}
|
||||
|
||||
|
|
@ -381,47 +517,89 @@ func (b *pickfirstBalancer) requestConnectionLocked() {
|
|||
b.subConns.Set(curAddr, sd)
|
||||
}
|
||||
|
||||
scd := sd.(*scData)
|
||||
switch scd.state {
|
||||
switch sd.rawConnectivityState {
|
||||
case connectivity.Idle:
|
||||
scd.subConn.Connect()
|
||||
sd.subConn.Connect()
|
||||
b.scheduleNextConnectionLocked()
|
||||
return
|
||||
case connectivity.TransientFailure:
|
||||
// Try the next address.
|
||||
lastErr = scd.lastErr
|
||||
// The SubConn is being re-used and failed during a previous pass
|
||||
// over the addressList. It has not completed backoff yet.
|
||||
// Mark it as having failed and try the next address.
|
||||
sd.connectionFailedInFirstPass = true
|
||||
lastErr = sd.lastErr
|
||||
continue
|
||||
case connectivity.Ready:
|
||||
// Should never happen.
|
||||
b.logger.Errorf("Requesting a connection even though we have a READY SubConn")
|
||||
case connectivity.Shutdown:
|
||||
// Should never happen.
|
||||
b.logger.Errorf("SubConn with state SHUTDOWN present in SubConns map")
|
||||
case connectivity.Connecting:
|
||||
// Wait for the SubConn to report success or failure.
|
||||
// Wait for the connection attempt to complete or the timer to fire
|
||||
// before attempting the next address.
|
||||
b.scheduleNextConnectionLocked()
|
||||
return
|
||||
default:
|
||||
b.logger.Errorf("SubConn with unexpected state %v present in SubConns map.", sd.rawConnectivityState)
|
||||
return
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// All the remaining addresses in the list are in TRANSIENT_FAILURE, end the
|
||||
// first pass if possible.
|
||||
b.endFirstPassIfPossibleLocked(lastErr)
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) scheduleNextConnectionLocked() {
|
||||
b.cancelConnectionTimer()
|
||||
if !b.addressList.hasNext() {
|
||||
return
|
||||
}
|
||||
// All the remaining addresses in the list are in TRANSIENT_FAILURE, end the
|
||||
// first pass.
|
||||
b.endFirstPassLocked(lastErr)
|
||||
curAddr := b.addressList.currentAddress()
|
||||
cancelled := false // Access to this is protected by the balancer's mutex.
|
||||
closeFn := internal.TimeAfterFunc(connectionDelayInterval, func() {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
// If the scheduled task is cancelled while acquiring the mutex, return.
|
||||
if cancelled {
|
||||
return
|
||||
}
|
||||
if b.logger.V(2) {
|
||||
b.logger.Infof("Happy Eyeballs timer expired while waiting for connection to %q.", curAddr.Addr)
|
||||
}
|
||||
if b.addressList.increment() {
|
||||
b.requestConnectionLocked()
|
||||
}
|
||||
})
|
||||
// Access to the cancellation callback held by the balancer is guarded by
|
||||
// the balancer's mutex, so it's safe to set the boolean from the callback.
|
||||
b.cancelConnectionTimer = sync.OnceFunc(func() {
|
||||
cancelled = true
|
||||
closeFn()
|
||||
})
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.SubConnState) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
oldState := sd.state
|
||||
sd.state = newState.ConnectivityState
|
||||
oldState := sd.rawConnectivityState
|
||||
sd.rawConnectivityState = newState.ConnectivityState
|
||||
// Previously relevant SubConns can still callback with state updates.
|
||||
// To prevent pickers from returning these obsolete SubConns, this logic
|
||||
// is included to check if the current list of active SubConns includes this
|
||||
// SubConn.
|
||||
if activeSD, found := b.subConns.Get(sd.addr); !found || activeSD != sd {
|
||||
if !b.isActiveSCData(sd) {
|
||||
return
|
||||
}
|
||||
if newState.ConnectivityState == connectivity.Shutdown {
|
||||
sd.effectiveState = connectivity.Shutdown
|
||||
return
|
||||
}
|
||||
|
||||
// Record a connection attempt when exiting CONNECTING.
|
||||
if newState.ConnectivityState == connectivity.TransientFailure {
|
||||
sd.connectionFailedInFirstPass = true
|
||||
connectionAttemptsFailedMetric.Record(b.metricsRecorder, 1, b.target)
|
||||
}
|
||||
|
||||
if newState.ConnectivityState == connectivity.Ready {
|
||||
connectionAttemptsSucceededMetric.Record(b.metricsRecorder, 1, b.target)
|
||||
b.shutdownRemainingLocked(sd)
|
||||
if !b.addressList.seekTo(sd.addr) {
|
||||
// This should not fail as we should have only one SubConn after
|
||||
|
|
@ -429,10 +607,30 @@ func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.Sub
|
|||
b.logger.Errorf("Address %q not found address list in %v", sd.addr, b.addressList.addresses)
|
||||
return
|
||||
}
|
||||
b.state = connectivity.Ready
|
||||
b.cc.UpdateState(balancer.State{
|
||||
ConnectivityState: connectivity.Ready,
|
||||
Picker: &picker{result: balancer.PickResult{SubConn: sd.subConn}},
|
||||
if !b.healthCheckingEnabled {
|
||||
if b.logger.V(2) {
|
||||
b.logger.Infof("SubConn %p reported connectivity state READY and the health listener is disabled. Transitioning SubConn to READY.", sd.subConn)
|
||||
}
|
||||
|
||||
sd.effectiveState = connectivity.Ready
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.Ready,
|
||||
Picker: &picker{result: balancer.PickResult{SubConn: sd.subConn}},
|
||||
})
|
||||
return
|
||||
}
|
||||
if b.logger.V(2) {
|
||||
b.logger.Infof("SubConn %p reported connectivity state READY. Registering health listener.", sd.subConn)
|
||||
}
|
||||
// Send a CONNECTING update to take the SubConn out of sticky-TF if
|
||||
// required.
|
||||
sd.effectiveState = connectivity.Connecting
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.Connecting,
|
||||
Picker: &picker{err: balancer.ErrNoSubConnAvailable},
|
||||
})
|
||||
sd.subConn.RegisterHealthListener(func(scs balancer.SubConnState) {
|
||||
b.updateSubConnHealthState(sd, scs)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
@ -443,13 +641,24 @@ func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.Sub
|
|||
// a transport is successfully created, but the connection fails
|
||||
// before the SubConn can send the notification for READY. We treat
|
||||
// this as a successful connection and transition to IDLE.
|
||||
if (b.state == connectivity.Ready && newState.ConnectivityState != connectivity.Ready) || (oldState == connectivity.Connecting && newState.ConnectivityState == connectivity.Idle) {
|
||||
// TODO: https://github.com/grpc/grpc-go/issues/7862 - Remove the second
|
||||
// part of the if condition below once the issue is fixed.
|
||||
if oldState == connectivity.Ready || (oldState == connectivity.Connecting && newState.ConnectivityState == connectivity.Idle) {
|
||||
// Once a transport fails, the balancer enters IDLE and starts from
|
||||
// the first address when the picker is used.
|
||||
b.shutdownRemainingLocked(sd)
|
||||
b.state = connectivity.Idle
|
||||
sd.effectiveState = newState.ConnectivityState
|
||||
// READY SubConn interspliced in between CONNECTING and IDLE, need to
|
||||
// account for that.
|
||||
if oldState == connectivity.Connecting {
|
||||
// A known issue (https://github.com/grpc/grpc-go/issues/7862)
|
||||
// causes a race that prevents the READY state change notification.
|
||||
// This works around it.
|
||||
connectionAttemptsSucceededMetric.Record(b.metricsRecorder, 1, b.target)
|
||||
}
|
||||
disconnectionsMetric.Record(b.metricsRecorder, 1, b.target)
|
||||
b.addressList.reset()
|
||||
b.cc.UpdateState(balancer.State{
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.Idle,
|
||||
Picker: &idlePicker{exitIdle: sync.OnceFunc(b.ExitIdle)},
|
||||
})
|
||||
|
|
@ -459,32 +668,35 @@ func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.Sub
|
|||
if b.firstPass {
|
||||
switch newState.ConnectivityState {
|
||||
case connectivity.Connecting:
|
||||
// The balancer can be in either IDLE, CONNECTING or
|
||||
// TRANSIENT_FAILURE. If it's in TRANSIENT_FAILURE, stay in
|
||||
// The effective state can be in either IDLE, CONNECTING or
|
||||
// TRANSIENT_FAILURE. If it's TRANSIENT_FAILURE, stay in
|
||||
// TRANSIENT_FAILURE until it's READY. See A62.
|
||||
// If the balancer is already in CONNECTING, no update is needed.
|
||||
if b.state == connectivity.Idle {
|
||||
b.state = connectivity.Connecting
|
||||
b.cc.UpdateState(balancer.State{
|
||||
if sd.effectiveState != connectivity.TransientFailure {
|
||||
sd.effectiveState = connectivity.Connecting
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.Connecting,
|
||||
Picker: &picker{err: balancer.ErrNoSubConnAvailable},
|
||||
})
|
||||
}
|
||||
case connectivity.TransientFailure:
|
||||
sd.lastErr = newState.ConnectionError
|
||||
sd.effectiveState = connectivity.TransientFailure
|
||||
// Since we're re-using common SubConns while handling resolver
|
||||
// updates, we could receive an out of turn TRANSIENT_FAILURE from
|
||||
// a pass over the previous address list. We ignore such updates.
|
||||
// a pass over the previous address list. Happy Eyeballs will also
|
||||
// cause out of order updates to arrive.
|
||||
|
||||
if curAddr := b.addressList.currentAddress(); !equalAddressIgnoringBalAttributes(&curAddr, &sd.addr) {
|
||||
return
|
||||
if curAddr := b.addressList.currentAddress(); equalAddressIgnoringBalAttributes(&curAddr, &sd.addr) {
|
||||
b.cancelConnectionTimer()
|
||||
if b.addressList.increment() {
|
||||
b.requestConnectionLocked()
|
||||
return
|
||||
}
|
||||
}
|
||||
if b.addressList.increment() {
|
||||
b.requestConnectionLocked()
|
||||
return
|
||||
}
|
||||
// End of the first pass.
|
||||
b.endFirstPassLocked(newState.ConnectionError)
|
||||
|
||||
// End the first pass if we've seen a TRANSIENT_FAILURE from all
|
||||
// SubConns once.
|
||||
b.endFirstPassIfPossibleLocked(newState.ConnectionError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -495,7 +707,7 @@ func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.Sub
|
|||
b.numTF = (b.numTF + 1) % b.subConns.Len()
|
||||
sd.lastErr = newState.ConnectionError
|
||||
if b.numTF%b.subConns.Len() == 0 {
|
||||
b.cc.UpdateState(balancer.State{
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.TransientFailure,
|
||||
Picker: &picker{err: newState.ConnectionError},
|
||||
})
|
||||
|
|
@ -509,24 +721,93 @@ func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.Sub
|
|||
}
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) endFirstPassLocked(lastErr error) {
|
||||
// endFirstPassIfPossibleLocked ends the first happy-eyeballs pass if all the
|
||||
// addresses are tried and their SubConns have reported a failure.
|
||||
func (b *pickfirstBalancer) endFirstPassIfPossibleLocked(lastErr error) {
|
||||
// An optimization to avoid iterating over the entire SubConn map.
|
||||
if b.addressList.isValid() {
|
||||
return
|
||||
}
|
||||
// Connect() has been called on all the SubConns. The first pass can be
|
||||
// ended if all the SubConns have reported a failure.
|
||||
for _, sd := range b.subConns.Values() {
|
||||
if !sd.connectionFailedInFirstPass {
|
||||
return
|
||||
}
|
||||
}
|
||||
b.firstPass = false
|
||||
b.numTF = 0
|
||||
b.state = connectivity.TransientFailure
|
||||
|
||||
b.cc.UpdateState(balancer.State{
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.TransientFailure,
|
||||
Picker: &picker{err: lastErr},
|
||||
})
|
||||
// Start re-connecting all the SubConns that are already in IDLE.
|
||||
for _, v := range b.subConns.Values() {
|
||||
sd := v.(*scData)
|
||||
if sd.state == connectivity.Idle {
|
||||
for _, sd := range b.subConns.Values() {
|
||||
if sd.rawConnectivityState == connectivity.Idle {
|
||||
sd.subConn.Connect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) isActiveSCData(sd *scData) bool {
|
||||
activeSD, found := b.subConns.Get(sd.addr)
|
||||
return found && activeSD == sd
|
||||
}
|
||||
|
||||
func (b *pickfirstBalancer) updateSubConnHealthState(sd *scData, state balancer.SubConnState) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
// Previously relevant SubConns can still callback with state updates.
|
||||
// To prevent pickers from returning these obsolete SubConns, this logic
|
||||
// is included to check if the current list of active SubConns includes
|
||||
// this SubConn.
|
||||
if !b.isActiveSCData(sd) {
|
||||
return
|
||||
}
|
||||
sd.effectiveState = state.ConnectivityState
|
||||
switch state.ConnectivityState {
|
||||
case connectivity.Ready:
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.Ready,
|
||||
Picker: &picker{result: balancer.PickResult{SubConn: sd.subConn}},
|
||||
})
|
||||
case connectivity.TransientFailure:
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.TransientFailure,
|
||||
Picker: &picker{err: fmt.Errorf("pickfirst: health check failure: %v", state.ConnectionError)},
|
||||
})
|
||||
case connectivity.Connecting:
|
||||
b.updateBalancerState(balancer.State{
|
||||
ConnectivityState: connectivity.Connecting,
|
||||
Picker: &picker{err: balancer.ErrNoSubConnAvailable},
|
||||
})
|
||||
default:
|
||||
b.logger.Errorf("Got unexpected health update for SubConn %p: %v", state)
|
||||
}
|
||||
}
|
||||
|
||||
// updateBalancerState stores the state reported to the channel and calls
|
||||
// ClientConn.UpdateState(). As an optimization, it avoids sending duplicate
|
||||
// updates to the channel.
|
||||
func (b *pickfirstBalancer) updateBalancerState(newState balancer.State) {
|
||||
// In case of TransientFailures allow the picker to be updated to update
|
||||
// the connectivity error, in all other cases don't send duplicate state
|
||||
// updates.
|
||||
if newState.ConnectivityState == b.state && b.state != connectivity.TransientFailure {
|
||||
return
|
||||
}
|
||||
b.forceUpdateConcludedStateLocked(newState)
|
||||
}
|
||||
|
||||
// forceUpdateConcludedStateLocked stores the state reported to the channel and
|
||||
// calls ClientConn.UpdateState().
|
||||
// A separate function is defined to force update the ClientConn state since the
|
||||
// channel doesn't correctly assume that LB policies start in CONNECTING and
|
||||
// relies on LB policy to send an initial CONNECTING update.
|
||||
func (b *pickfirstBalancer) forceUpdateConcludedStateLocked(newState balancer.State) {
|
||||
b.state = newState.ConnectivityState
|
||||
b.cc.UpdateState(newState)
|
||||
}
|
||||
|
||||
type picker struct {
|
||||
result balancer.PickResult
|
||||
err error
|
||||
|
|
@ -583,15 +864,6 @@ func (al *addressList) currentAddress() resolver.Address {
|
|||
return al.addresses[al.idx]
|
||||
}
|
||||
|
||||
// first returns the first address in the list. If the list is empty, it returns
|
||||
// an empty address instead.
|
||||
func (al *addressList) first() resolver.Address {
|
||||
if len(al.addresses) == 0 {
|
||||
return resolver.Address{}
|
||||
}
|
||||
return al.addresses[0]
|
||||
}
|
||||
|
||||
func (al *addressList) reset() {
|
||||
al.idx = 0
|
||||
}
|
||||
|
|
@ -614,12 +886,21 @@ func (al *addressList) seekTo(needle resolver.Address) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// hasNext returns whether incrementing the addressList will result in moving
|
||||
// past the end of the list. If the list has already moved past the end, it
|
||||
// returns false.
|
||||
func (al *addressList) hasNext() bool {
|
||||
if !al.isValid() {
|
||||
return false
|
||||
}
|
||||
return al.idx+1 < len(al.addresses)
|
||||
}
|
||||
|
||||
// equalAddressIgnoringBalAttributes returns true is a and b are considered
|
||||
// equal. This is different from the Equal method on the resolver.Address type
|
||||
// which considers all fields to determine equality. Here, we only consider
|
||||
// fields that are meaningful to the SubConn.
|
||||
func equalAddressIgnoringBalAttributes(a, b *resolver.Address) bool {
|
||||
return a.Addr == b.Addr && a.ServerName == b.ServerName &&
|
||||
a.Attributes.Equal(b.Attributes) &&
|
||||
a.Metadata == b.Metadata
|
||||
a.Attributes.Equal(b.Attributes)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,13 @@
|
|||
package roundrobin
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"sync/atomic"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/balancer/base"
|
||||
"google.golang.org/grpc/balancer/endpointsharding"
|
||||
"google.golang.org/grpc/balancer/pickfirst/pickfirstleaf"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
internalgrpclog "google.golang.org/grpc/internal/grpclog"
|
||||
)
|
||||
|
||||
// Name is the name of round_robin balancer.
|
||||
|
|
@ -35,47 +36,37 @@ const Name = "round_robin"
|
|||
|
||||
var logger = grpclog.Component("roundrobin")
|
||||
|
||||
// newBuilder creates a new roundrobin balancer builder.
|
||||
func newBuilder() balancer.Builder {
|
||||
return base.NewBalancerBuilder(Name, &rrPickerBuilder{}, base.Config{HealthCheck: true})
|
||||
}
|
||||
|
||||
func init() {
|
||||
balancer.Register(newBuilder())
|
||||
balancer.Register(builder{})
|
||||
}
|
||||
|
||||
type rrPickerBuilder struct{}
|
||||
type builder struct{}
|
||||
|
||||
func (*rrPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker {
|
||||
logger.Infof("roundrobinPicker: Build called with info: %v", info)
|
||||
if len(info.ReadySCs) == 0 {
|
||||
return base.NewErrPicker(balancer.ErrNoSubConnAvailable)
|
||||
}
|
||||
scs := make([]balancer.SubConn, 0, len(info.ReadySCs))
|
||||
for sc := range info.ReadySCs {
|
||||
scs = append(scs, sc)
|
||||
}
|
||||
return &rrPicker{
|
||||
subConns: scs,
|
||||
// Start at a random index, as the same RR balancer rebuilds a new
|
||||
// picker when SubConn states change, and we don't want to apply excess
|
||||
// load to the first server in the list.
|
||||
next: uint32(rand.Intn(len(scs))),
|
||||
func (bb builder) Name() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (bb builder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer {
|
||||
childBuilder := balancer.Get(pickfirstleaf.Name).Build
|
||||
bal := &rrBalancer{
|
||||
cc: cc,
|
||||
Balancer: endpointsharding.NewBalancer(cc, opts, childBuilder, endpointsharding.Options{}),
|
||||
}
|
||||
bal.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[%p] ", bal))
|
||||
bal.logger.Infof("Created")
|
||||
return bal
|
||||
}
|
||||
|
||||
type rrPicker struct {
|
||||
// subConns is the snapshot of the roundrobin balancer when this picker was
|
||||
// created. The slice is immutable. Each Get() will do a round robin
|
||||
// selection from it and return the selected SubConn.
|
||||
subConns []balancer.SubConn
|
||||
next uint32
|
||||
type rrBalancer struct {
|
||||
balancer.Balancer
|
||||
cc balancer.ClientConn
|
||||
logger *internalgrpclog.PrefixLogger
|
||||
}
|
||||
|
||||
func (p *rrPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
|
||||
subConnsLen := uint32(len(p.subConns))
|
||||
nextIndex := atomic.AddUint32(&p.next, 1)
|
||||
|
||||
sc := p.subConns[nextIndex%subConnsLen]
|
||||
return balancer.PickResult{SubConn: sc}, nil
|
||||
func (b *rrBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error {
|
||||
return b.Balancer.UpdateClientConnState(balancer.ClientConnState{
|
||||
// Enable the health listener in pickfirst children for client side health
|
||||
// checks and outlier detection, if configured.
|
||||
ResolverState: pickfirstleaf.EnableHealthListener(ccs.ResolverState),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2024 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package balancer
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
// A SubConn represents a single connection to a gRPC backend service.
|
||||
//
|
||||
// All SubConns start in IDLE, and will not try to connect. To trigger a
|
||||
// connection attempt, Balancers must call Connect.
|
||||
//
|
||||
// If the connection attempt fails, the SubConn will transition to
|
||||
// TRANSIENT_FAILURE for a backoff period, and then return to IDLE. If the
|
||||
// connection attempt succeeds, it will transition to READY.
|
||||
//
|
||||
// If a READY SubConn becomes disconnected, the SubConn will transition to IDLE.
|
||||
//
|
||||
// If a connection re-enters IDLE, Balancers must call Connect again to trigger
|
||||
// a new connection attempt.
|
||||
//
|
||||
// Each SubConn contains a list of addresses. gRPC will try to connect to the
|
||||
// addresses in sequence, and stop trying the remainder once the first
|
||||
// connection is successful. However, this behavior is deprecated. SubConns
|
||||
// should only use a single address.
|
||||
//
|
||||
// NOTICE: This interface is intended to be implemented by gRPC, or intercepted
|
||||
// by custom load balancing polices. Users should not need their own complete
|
||||
// implementation of this interface -- they should always delegate to a SubConn
|
||||
// returned by ClientConn.NewSubConn() by embedding it in their implementations.
|
||||
// An embedded SubConn must never be nil, or runtime panics will occur.
|
||||
type SubConn interface {
|
||||
// UpdateAddresses updates the addresses used in this SubConn.
|
||||
// gRPC checks if currently-connected address is still in the new list.
|
||||
// If it's in the list, the connection will be kept.
|
||||
// If it's not in the list, the connection will gracefully close, and
|
||||
// a new connection will be created.
|
||||
//
|
||||
// This will trigger a state transition for the SubConn.
|
||||
//
|
||||
// Deprecated: this method will be removed. Create new SubConns for new
|
||||
// addresses instead.
|
||||
UpdateAddresses([]resolver.Address)
|
||||
// Connect starts the connecting for this SubConn.
|
||||
Connect()
|
||||
// GetOrBuildProducer returns a reference to the existing Producer for this
|
||||
// ProducerBuilder in this SubConn, or, if one does not currently exist,
|
||||
// creates a new one and returns it. Returns a close function which may be
|
||||
// called when the Producer is no longer needed. Otherwise the producer
|
||||
// will automatically be closed upon connection loss or subchannel close.
|
||||
// Should only be called on a SubConn in state Ready. Otherwise the
|
||||
// producer will be unable to create streams.
|
||||
GetOrBuildProducer(ProducerBuilder) (p Producer, close func())
|
||||
// Shutdown shuts down the SubConn gracefully. Any started RPCs will be
|
||||
// allowed to complete. No future calls should be made on the SubConn.
|
||||
// One final state update will be delivered to the StateListener (or
|
||||
// UpdateSubConnState; deprecated) with ConnectivityState of Shutdown to
|
||||
// indicate the shutdown operation. This may be delivered before
|
||||
// in-progress RPCs are complete and the actual connection is closed.
|
||||
Shutdown()
|
||||
// RegisterHealthListener registers a health listener that receives health
|
||||
// updates for a Ready SubConn. Only one health listener can be registered
|
||||
// at a time. A health listener should be registered each time the SubConn's
|
||||
// connectivity state changes to READY. Registering a health listener when
|
||||
// the connectivity state is not READY may result in undefined behaviour.
|
||||
// This method must not be called synchronously while handling an update
|
||||
// from a previously registered health listener.
|
||||
RegisterHealthListener(func(SubConnState))
|
||||
// EnforceSubConnEmbedding is included to force implementers to embed
|
||||
// another implementation of this interface, allowing gRPC to add methods
|
||||
// without breaking users.
|
||||
internal.EnforceSubConnEmbedding
|
||||
}
|
||||
|
||||
// A ProducerBuilder is a simple constructor for a Producer. It is used by the
|
||||
// SubConn to create producers when needed.
|
||||
type ProducerBuilder interface {
|
||||
// Build creates a Producer. The first parameter is always a
|
||||
// grpc.ClientConnInterface (a type to allow creating RPCs/streams on the
|
||||
// associated SubConn), but is declared as `any` to avoid a dependency
|
||||
// cycle. Build also returns a close function that will be called when all
|
||||
// references to the Producer have been given up for a SubConn, or when a
|
||||
// connectivity state change occurs on the SubConn. The close function
|
||||
// should always block until all asynchronous cleanup work is completed.
|
||||
Build(grpcClientConnInterface any) (p Producer, close func())
|
||||
}
|
||||
|
||||
// SubConnState describes the state of a SubConn.
|
||||
type SubConnState struct {
|
||||
// ConnectivityState is the connectivity state of the SubConn.
|
||||
ConnectivityState connectivity.State
|
||||
// ConnectionError is set if the ConnectivityState is TransientFailure,
|
||||
// describing the reason the SubConn failed. Otherwise, it is nil.
|
||||
ConnectionError error
|
||||
// connectedAddr contains the connected address when ConnectivityState is
|
||||
// Ready. Otherwise, it is indeterminate.
|
||||
connectedAddress resolver.Address
|
||||
}
|
||||
|
||||
// connectedAddress returns the connected address for a SubConnState. The
|
||||
// address is only valid if the state is READY.
|
||||
func connectedAddress(scs SubConnState) resolver.Address {
|
||||
return scs.connectedAddress
|
||||
}
|
||||
|
||||
// setConnectedAddress sets the connected address for a SubConnState.
|
||||
func setConnectedAddress(scs *SubConnState, addr resolver.Address) {
|
||||
scs.connectedAddress = addr
|
||||
}
|
||||
|
||||
// A Producer is a type shared among potentially many consumers. It is
|
||||
// associated with a SubConn, and an implementation will typically contain
|
||||
// other methods to provide additional functionality, e.g. configuration or
|
||||
// subscription registration.
|
||||
type Producer any
|
||||
|
|
@ -26,6 +26,7 @@ import (
|
|||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/experimental/stats"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/internal/balancer/gracefulswitch"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
|
|
@ -34,7 +35,15 @@ import (
|
|||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
|
||||
var (
|
||||
setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
|
||||
// noOpRegisterHealthListenerFn is used when client side health checking is
|
||||
// disabled. It sends a single READY update on the registered listener.
|
||||
noOpRegisterHealthListenerFn = func(_ context.Context, listener func(balancer.SubConnState)) func() {
|
||||
listener(balancer.SubConnState{ConnectivityState: connectivity.Ready})
|
||||
return func() {}
|
||||
}
|
||||
)
|
||||
|
||||
// ccBalancerWrapper sits between the ClientConn and the Balancer.
|
||||
//
|
||||
|
|
@ -51,6 +60,7 @@ var setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnSt
|
|||
// It uses the gracefulswitch.Balancer internally to ensure that balancer
|
||||
// switches happen in a graceful manner.
|
||||
type ccBalancerWrapper struct {
|
||||
internal.EnforceClientConnEmbedding
|
||||
// The following fields are initialized when the wrapper is created and are
|
||||
// read-only afterwards, and therefore can be accessed without a mutex.
|
||||
cc *ClientConn
|
||||
|
|
@ -84,7 +94,6 @@ func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper {
|
|||
CustomUserAgent: cc.dopts.copts.UserAgent,
|
||||
ChannelzParent: cc.channelz,
|
||||
Target: cc.parsedTarget,
|
||||
MetricsRecorder: cc.metricsRecorderList,
|
||||
},
|
||||
serializer: grpcsync.NewCallbackSerializer(ctx),
|
||||
serializerCancel: cancel,
|
||||
|
|
@ -93,6 +102,10 @@ func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper {
|
|||
return ccb
|
||||
}
|
||||
|
||||
func (ccb *ccBalancerWrapper) MetricsRecorder() stats.MetricsRecorder {
|
||||
return ccb.cc.metricsRecorderList
|
||||
}
|
||||
|
||||
// updateClientConnState is invoked by grpc to push a ClientConnState update to
|
||||
// the underlying balancer. This is always executed from the serializer, so
|
||||
// it is safe to call into the balancer here.
|
||||
|
|
@ -189,6 +202,7 @@ func (ccb *ccBalancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer
|
|||
ac: ac,
|
||||
producers: make(map[balancer.ProducerBuilder]*refCountedProducer),
|
||||
stateListener: opts.StateListener,
|
||||
healthData: newHealthData(connectivity.Idle),
|
||||
}
|
||||
ac.acbw = acbw
|
||||
return acbw, nil
|
||||
|
|
@ -254,12 +268,39 @@ func (ccb *ccBalancerWrapper) Target() string {
|
|||
// acBalancerWrapper is a wrapper on top of ac for balancers.
|
||||
// It implements balancer.SubConn interface.
|
||||
type acBalancerWrapper struct {
|
||||
internal.EnforceSubConnEmbedding
|
||||
ac *addrConn // read-only
|
||||
ccb *ccBalancerWrapper // read-only
|
||||
stateListener func(balancer.SubConnState)
|
||||
|
||||
producersMu sync.Mutex
|
||||
producers map[balancer.ProducerBuilder]*refCountedProducer
|
||||
|
||||
// Access to healthData is protected by healthMu.
|
||||
healthMu sync.Mutex
|
||||
// healthData is stored as a pointer to detect when the health listener is
|
||||
// dropped or updated. This is required as closures can't be compared for
|
||||
// equality.
|
||||
healthData *healthData
|
||||
}
|
||||
|
||||
// healthData holds data related to health state reporting.
|
||||
type healthData struct {
|
||||
// connectivityState stores the most recent connectivity state delivered
|
||||
// to the LB policy. This is stored to avoid sending updates when the
|
||||
// SubConn has already exited connectivity state READY.
|
||||
connectivityState connectivity.State
|
||||
// closeHealthProducer stores function to close the ref counted health
|
||||
// producer. The health producer is automatically closed when the SubConn
|
||||
// state changes.
|
||||
closeHealthProducer func()
|
||||
}
|
||||
|
||||
func newHealthData(s connectivity.State) *healthData {
|
||||
return &healthData{
|
||||
connectivityState: s,
|
||||
closeHealthProducer: func() {},
|
||||
}
|
||||
}
|
||||
|
||||
// updateState is invoked by grpc to push a subConn state update to the
|
||||
|
|
@ -279,6 +320,24 @@ func (acbw *acBalancerWrapper) updateState(s connectivity.State, curAddr resolve
|
|||
if s == connectivity.Ready {
|
||||
setConnectedAddress(&scs, curAddr)
|
||||
}
|
||||
// Invalidate the health listener by updating the healthData.
|
||||
acbw.healthMu.Lock()
|
||||
// A race may occur if a health listener is registered soon after the
|
||||
// connectivity state is set but before the stateListener is called.
|
||||
// Two cases may arise:
|
||||
// 1. The new state is not READY: RegisterHealthListener has checks to
|
||||
// ensure no updates are sent when the connectivity state is not
|
||||
// READY.
|
||||
// 2. The new state is READY: This means that the old state wasn't Ready.
|
||||
// The RegisterHealthListener API mentions that a health listener
|
||||
// must not be registered when a SubConn is not ready to avoid such
|
||||
// races. When this happens, the LB policy would get health updates
|
||||
// on the old listener. When the LB policy registers a new listener
|
||||
// on receiving the connectivity update, the health updates will be
|
||||
// sent to the new health listener.
|
||||
acbw.healthData = newHealthData(scs.ConnectivityState)
|
||||
acbw.healthMu.Unlock()
|
||||
|
||||
acbw.stateListener(scs)
|
||||
})
|
||||
}
|
||||
|
|
@ -361,7 +420,7 @@ func (acbw *acBalancerWrapper) GetOrBuildProducer(pb balancer.ProducerBuilder) (
|
|||
}
|
||||
acbw.producersMu.Unlock()
|
||||
}
|
||||
return pData.producer, grpcsync.OnceFunc(unref)
|
||||
return pData.producer, sync.OnceFunc(unref)
|
||||
}
|
||||
|
||||
func (acbw *acBalancerWrapper) closeProducers() {
|
||||
|
|
@ -373,3 +432,89 @@ func (acbw *acBalancerWrapper) closeProducers() {
|
|||
delete(acbw.producers, pb)
|
||||
}
|
||||
}
|
||||
|
||||
// healthProducerRegisterFn is a type alias for the health producer's function
|
||||
// for registering listeners.
|
||||
type healthProducerRegisterFn = func(context.Context, balancer.SubConn, string, func(balancer.SubConnState)) func()
|
||||
|
||||
// healthListenerRegFn returns a function to register a listener for health
|
||||
// updates. If client side health checks are disabled, the registered listener
|
||||
// will get a single READY (raw connectivity state) update.
|
||||
//
|
||||
// Client side health checking is enabled when all the following
|
||||
// conditions are satisfied:
|
||||
// 1. Health checking is not disabled using the dial option.
|
||||
// 2. The health package is imported.
|
||||
// 3. The health check config is present in the service config.
|
||||
func (acbw *acBalancerWrapper) healthListenerRegFn() func(context.Context, func(balancer.SubConnState)) func() {
|
||||
if acbw.ccb.cc.dopts.disableHealthCheck {
|
||||
return noOpRegisterHealthListenerFn
|
||||
}
|
||||
regHealthLisFn := internal.RegisterClientHealthCheckListener
|
||||
if regHealthLisFn == nil {
|
||||
// The health package is not imported.
|
||||
return noOpRegisterHealthListenerFn
|
||||
}
|
||||
cfg := acbw.ac.cc.healthCheckConfig()
|
||||
if cfg == nil {
|
||||
return noOpRegisterHealthListenerFn
|
||||
}
|
||||
return func(ctx context.Context, listener func(balancer.SubConnState)) func() {
|
||||
return regHealthLisFn.(healthProducerRegisterFn)(ctx, acbw, cfg.ServiceName, listener)
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterHealthListener accepts a health listener from the LB policy. It sends
|
||||
// updates to the health listener as long as the SubConn's connectivity state
|
||||
// doesn't change and a new health listener is not registered. To invalidate
|
||||
// the currently registered health listener, acbw updates the healthData. If a
|
||||
// nil listener is registered, the active health listener is dropped.
|
||||
func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.SubConnState)) {
|
||||
acbw.healthMu.Lock()
|
||||
defer acbw.healthMu.Unlock()
|
||||
acbw.healthData.closeHealthProducer()
|
||||
// listeners should not be registered when the connectivity state
|
||||
// isn't Ready. This may happen when the balancer registers a listener
|
||||
// after the connectivityState is updated, but before it is notified
|
||||
// of the update.
|
||||
if acbw.healthData.connectivityState != connectivity.Ready {
|
||||
return
|
||||
}
|
||||
// Replace the health data to stop sending updates to any previously
|
||||
// registered health listeners.
|
||||
hd := newHealthData(connectivity.Ready)
|
||||
acbw.healthData = hd
|
||||
if listener == nil {
|
||||
return
|
||||
}
|
||||
|
||||
registerFn := acbw.healthListenerRegFn()
|
||||
acbw.ccb.serializer.TrySchedule(func(ctx context.Context) {
|
||||
if ctx.Err() != nil || acbw.ccb.balancer == nil {
|
||||
return
|
||||
}
|
||||
// Don't send updates if a new listener is registered.
|
||||
acbw.healthMu.Lock()
|
||||
defer acbw.healthMu.Unlock()
|
||||
if acbw.healthData != hd {
|
||||
return
|
||||
}
|
||||
// Serialize the health updates from the health producer with
|
||||
// other calls into the LB policy.
|
||||
listenerWrapper := func(scs balancer.SubConnState) {
|
||||
acbw.ccb.serializer.TrySchedule(func(ctx context.Context) {
|
||||
if ctx.Err() != nil || acbw.ccb.balancer == nil {
|
||||
return
|
||||
}
|
||||
acbw.healthMu.Lock()
|
||||
defer acbw.healthMu.Unlock()
|
||||
if acbw.healthData != hd {
|
||||
return
|
||||
}
|
||||
listener(scs)
|
||||
})
|
||||
}
|
||||
|
||||
hd.closeHealthProducer = registerFn(ctx, listenerWrapper)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc-gen-go v1.36.6
|
||||
// protoc v5.27.1
|
||||
// source: grpc/binlog/v1/binarylog.proto
|
||||
|
||||
|
|
@ -31,6 +31,7 @@ import (
|
|||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -233,10 +234,7 @@ func (Address_Type) EnumDescriptor() ([]byte, []int) {
|
|||
|
||||
// Log entry we store in binary logs
|
||||
type GrpcLogEntry struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The timestamp of the binary log message
|
||||
Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
|
||||
// Uniquely identifies a call. The value must not be 0 in order to disambiguate
|
||||
|
|
@ -255,7 +253,7 @@ type GrpcLogEntry struct {
|
|||
// The logger uses one of the following fields to record the payload,
|
||||
// according to the type of the log entry.
|
||||
//
|
||||
// Types that are assignable to Payload:
|
||||
// Types that are valid to be assigned to Payload:
|
||||
//
|
||||
// *GrpcLogEntry_ClientHeader
|
||||
// *GrpcLogEntry_ServerHeader
|
||||
|
|
@ -269,16 +267,16 @@ type GrpcLogEntry struct {
|
|||
// EVENT_TYPE_SERVER_HEADER normally or EVENT_TYPE_SERVER_TRAILER in
|
||||
// the case of trailers-only. On server side, peer is always
|
||||
// logged on EVENT_TYPE_CLIENT_HEADER.
|
||||
Peer *Address `protobuf:"bytes,11,opt,name=peer,proto3" json:"peer,omitempty"`
|
||||
Peer *Address `protobuf:"bytes,11,opt,name=peer,proto3" json:"peer,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) Reset() {
|
||||
*x = GrpcLogEntry{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) String() string {
|
||||
|
|
@ -289,7 +287,7 @@ func (*GrpcLogEntry) ProtoMessage() {}
|
|||
|
||||
func (x *GrpcLogEntry) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -339,37 +337,45 @@ func (x *GrpcLogEntry) GetLogger() GrpcLogEntry_Logger {
|
|||
return GrpcLogEntry_LOGGER_UNKNOWN
|
||||
}
|
||||
|
||||
func (m *GrpcLogEntry) GetPayload() isGrpcLogEntry_Payload {
|
||||
if m != nil {
|
||||
return m.Payload
|
||||
func (x *GrpcLogEntry) GetPayload() isGrpcLogEntry_Payload {
|
||||
if x != nil {
|
||||
return x.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetClientHeader() *ClientHeader {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_ClientHeader); ok {
|
||||
return x.ClientHeader
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_ClientHeader); ok {
|
||||
return x.ClientHeader
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetServerHeader() *ServerHeader {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_ServerHeader); ok {
|
||||
return x.ServerHeader
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_ServerHeader); ok {
|
||||
return x.ServerHeader
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetMessage() *Message {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_Message); ok {
|
||||
return x.Message
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_Message); ok {
|
||||
return x.Message
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetTrailer() *Trailer {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_Trailer); ok {
|
||||
return x.Trailer
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_Trailer); ok {
|
||||
return x.Trailer
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -418,10 +424,7 @@ func (*GrpcLogEntry_Message) isGrpcLogEntry_Payload() {}
|
|||
func (*GrpcLogEntry_Trailer) isGrpcLogEntry_Payload() {}
|
||||
|
||||
type ClientHeader struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// This contains only the metadata from the application.
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// The name of the RPC method, which looks something like:
|
||||
|
|
@ -435,16 +438,16 @@ type ClientHeader struct {
|
|||
// <host> or <host>:<port> .
|
||||
Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"`
|
||||
// the RPC timeout
|
||||
Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"`
|
||||
Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ClientHeader) Reset() {
|
||||
*x = ClientHeader{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ClientHeader) String() string {
|
||||
|
|
@ -455,7 +458,7 @@ func (*ClientHeader) ProtoMessage() {}
|
|||
|
||||
func (x *ClientHeader) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -499,21 +502,18 @@ func (x *ClientHeader) GetTimeout() *durationpb.Duration {
|
|||
}
|
||||
|
||||
type ServerHeader struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// This contains only the metadata from the application.
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ServerHeader) Reset() {
|
||||
*x = ServerHeader{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ServerHeader) String() string {
|
||||
|
|
@ -524,7 +524,7 @@ func (*ServerHeader) ProtoMessage() {}
|
|||
|
||||
func (x *ServerHeader) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -547,10 +547,7 @@ func (x *ServerHeader) GetMetadata() *Metadata {
|
|||
}
|
||||
|
||||
type Trailer struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// This contains only the metadata from the application.
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// The gRPC status code.
|
||||
|
|
@ -561,15 +558,15 @@ type Trailer struct {
|
|||
// The value of the 'grpc-status-details-bin' metadata key. If
|
||||
// present, this is always an encoded 'google.rpc.Status' message.
|
||||
StatusDetails []byte `protobuf:"bytes,4,opt,name=status_details,json=statusDetails,proto3" json:"status_details,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Trailer) Reset() {
|
||||
*x = Trailer{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Trailer) String() string {
|
||||
|
|
@ -580,7 +577,7 @@ func (*Trailer) ProtoMessage() {}
|
|||
|
||||
func (x *Trailer) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -625,24 +622,21 @@ func (x *Trailer) GetStatusDetails() []byte {
|
|||
|
||||
// Message payload, used by CLIENT_MESSAGE and SERVER_MESSAGE
|
||||
type Message struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Length of the message. It may not be the same as the length of the
|
||||
// data field, as the logging payload can be truncated or omitted.
|
||||
Length uint32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"`
|
||||
// May be truncated or omitted.
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Message) Reset() {
|
||||
*x = Message{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Message) String() string {
|
||||
|
|
@ -653,7 +647,7 @@ func (*Message) ProtoMessage() {}
|
|||
|
||||
func (x *Message) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -704,20 +698,17 @@ func (x *Message) GetData() []byte {
|
|||
// header is just a normal metadata key.
|
||||
// The pair will not count towards the size limit.
|
||||
type Metadata struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Entry []*MetadataEntry `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Entry []*MetadataEntry `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"`
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Metadata) Reset() {
|
||||
*x = Metadata{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Metadata) String() string {
|
||||
|
|
@ -728,7 +719,7 @@ func (*Metadata) ProtoMessage() {}
|
|||
|
||||
func (x *Metadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -752,21 +743,18 @@ func (x *Metadata) GetEntry() []*MetadataEntry {
|
|||
|
||||
// A metadata key value pair
|
||||
type MetadataEntry struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MetadataEntry) Reset() {
|
||||
*x = MetadataEntry{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MetadataEntry) String() string {
|
||||
|
|
@ -777,7 +765,7 @@ func (*MetadataEntry) ProtoMessage() {}
|
|||
|
||||
func (x *MetadataEntry) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -808,23 +796,20 @@ func (x *MetadataEntry) GetValue() []byte {
|
|||
|
||||
// Address information
|
||||
type Address struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Type Address_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.binarylog.v1.Address_Type" json:"type,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type Address_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.binarylog.v1.Address_Type" json:"type,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
// only for TYPE_IPV4 and TYPE_IPV6
|
||||
IpPort uint32 `protobuf:"varint,3,opt,name=ip_port,json=ipPort,proto3" json:"ip_port,omitempty"`
|
||||
IpPort uint32 `protobuf:"varint,3,opt,name=ip_port,json=ipPort,proto3" json:"ip_port,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Address) Reset() {
|
||||
*x = Address{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Address) String() string {
|
||||
|
|
@ -835,7 +820,7 @@ func (*Address) ProtoMessage() {}
|
|||
|
||||
func (x *Address) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
|
|
@ -873,142 +858,77 @@ func (x *Address) GetIpPort() uint32 {
|
|||
|
||||
var File_grpc_binlog_v1_binarylog_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_grpc_binlog_v1_binarylog_proto_rawDesc = []byte{
|
||||
0x0a, 0x1e, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x69, 0x6e, 0x6c, 0x6f, 0x67, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x11, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67,
|
||||
0x2e, 0x76, 0x31, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbb, 0x07, 0x0a, 0x0c, 0x47, 0x72, 0x70, 0x63, 0x4c, 0x6f, 0x67,
|
||||
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
|
||||
0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12,
|
||||
0x17, 0x0a, 0x07, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04,
|
||||
0x52, 0x06, 0x63, 0x61, 0x6c, 0x6c, 0x49, 0x64, 0x12, 0x35, 0x0a, 0x17, 0x73, 0x65, 0x71, 0x75,
|
||||
0x65, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x5f, 0x63,
|
||||
0x61, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x73, 0x65, 0x71, 0x75, 0x65,
|
||||
0x6e, 0x63, 0x65, 0x49, 0x64, 0x57, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x12,
|
||||
0x3d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e,
|
||||
0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x2e, 0x45,
|
||||
0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3e,
|
||||
0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26,
|
||||
0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e,
|
||||
0x76, 0x31, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x2e,
|
||||
0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x52, 0x06, 0x6c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x12, 0x46,
|
||||
0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18,
|
||||
0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e,
|
||||
0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74,
|
||||
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
|
||||
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x46, 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e,
|
||||
0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00,
|
||||
0x52, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x36,
|
||||
0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x07, 0x6d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x65,
|
||||
0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62,
|
||||
0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69,
|
||||
0x6c, 0x65, 0x72, 0x48, 0x00, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x12, 0x2b,
|
||||
0x0a, 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x74, 0x72, 0x75, 0x6e, 0x63, 0x61,
|
||||
0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x70, 0x61, 0x79, 0x6c, 0x6f,
|
||||
0x61, 0x64, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x70,
|
||||
0x65, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63,
|
||||
0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64,
|
||||
0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x22, 0xf5, 0x01, 0x0a, 0x09,
|
||||
0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x45, 0x56, 0x45,
|
||||
0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10,
|
||||
0x00, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f,
|
||||
0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x01, 0x12,
|
||||
0x1c, 0x0a, 0x18, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45,
|
||||
0x52, 0x56, 0x45, 0x52, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x02, 0x12, 0x1d, 0x0a,
|
||||
0x19, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x4c, 0x49, 0x45,
|
||||
0x4e, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19,
|
||||
0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45,
|
||||
0x52, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x04, 0x12, 0x20, 0x0a, 0x1c, 0x45,
|
||||
0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54,
|
||||
0x5f, 0x48, 0x41, 0x4c, 0x46, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x10, 0x05, 0x12, 0x1d, 0x0a,
|
||||
0x19, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56,
|
||||
0x45, 0x52, 0x5f, 0x54, 0x52, 0x41, 0x49, 0x4c, 0x45, 0x52, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11,
|
||||
0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45,
|
||||
0x4c, 0x10, 0x07, 0x22, 0x42, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x12, 0x12, 0x0a,
|
||||
0x0e, 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10,
|
||||
0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x43, 0x4c, 0x49, 0x45,
|
||||
0x4e, 0x54, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x53,
|
||||
0x45, 0x52, 0x56, 0x45, 0x52, 0x10, 0x02, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f,
|
||||
0x61, 0x64, 0x22, 0xbb, 0x01, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61,
|
||||
0x64, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e,
|
||||
0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
|
||||
0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1f, 0x0a, 0x0b,
|
||||
0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0a, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a,
|
||||
0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x33, 0x0a, 0x07, 0x74,
|
||||
0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67,
|
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44,
|
||||
0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74,
|
||||
0x22, 0x47, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
|
||||
0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79,
|
||||
0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52,
|
||||
0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0xb1, 0x01, 0x0a, 0x07, 0x54, 0x72,
|
||||
0x61, 0x69, 0x6c, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
||||
0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62,
|
||||
0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61,
|
||||
0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1f,
|
||||
0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x25, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||
0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x35, 0x0a,
|
||||
0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67,
|
||||
0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04,
|
||||
0x64, 0x61, 0x74, 0x61, 0x22, 0x42, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
|
||||
0x12, 0x36, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||
0x20, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x37, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61,
|
||||
0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
|
||||
0x65, 0x22, 0xb8, 0x01, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x33, 0x0a,
|
||||
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x67, 0x72,
|
||||
0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79,
|
||||
0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x17, 0x0a, 0x07,
|
||||
0x69, 0x70, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x69,
|
||||
0x70, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x45, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a,
|
||||
0x0c, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12,
|
||||
0x0d, 0x0a, 0x09, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x50, 0x56, 0x34, 0x10, 0x01, 0x12, 0x0d,
|
||||
0x0a, 0x09, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x50, 0x56, 0x36, 0x10, 0x02, 0x12, 0x0d, 0x0a,
|
||||
0x09, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x49, 0x58, 0x10, 0x03, 0x42, 0x5c, 0x0a, 0x14,
|
||||
0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f,
|
||||
0x67, 0x2e, 0x76, 0x31, 0x42, 0x0e, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x4c, 0x6f, 0x67, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67,
|
||||
0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x62,
|
||||
0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x69,
|
||||
0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x5f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
const file_grpc_binlog_v1_binarylog_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1egrpc/binlog/v1/binarylog.proto\x12\x11grpc.binarylog.v1\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xbb\a\n" +
|
||||
"\fGrpcLogEntry\x128\n" +
|
||||
"\ttimestamp\x18\x01 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12\x17\n" +
|
||||
"\acall_id\x18\x02 \x01(\x04R\x06callId\x125\n" +
|
||||
"\x17sequence_id_within_call\x18\x03 \x01(\x04R\x14sequenceIdWithinCall\x12=\n" +
|
||||
"\x04type\x18\x04 \x01(\x0e2).grpc.binarylog.v1.GrpcLogEntry.EventTypeR\x04type\x12>\n" +
|
||||
"\x06logger\x18\x05 \x01(\x0e2&.grpc.binarylog.v1.GrpcLogEntry.LoggerR\x06logger\x12F\n" +
|
||||
"\rclient_header\x18\x06 \x01(\v2\x1f.grpc.binarylog.v1.ClientHeaderH\x00R\fclientHeader\x12F\n" +
|
||||
"\rserver_header\x18\a \x01(\v2\x1f.grpc.binarylog.v1.ServerHeaderH\x00R\fserverHeader\x126\n" +
|
||||
"\amessage\x18\b \x01(\v2\x1a.grpc.binarylog.v1.MessageH\x00R\amessage\x126\n" +
|
||||
"\atrailer\x18\t \x01(\v2\x1a.grpc.binarylog.v1.TrailerH\x00R\atrailer\x12+\n" +
|
||||
"\x11payload_truncated\x18\n" +
|
||||
" \x01(\bR\x10payloadTruncated\x12.\n" +
|
||||
"\x04peer\x18\v \x01(\v2\x1a.grpc.binarylog.v1.AddressR\x04peer\"\xf5\x01\n" +
|
||||
"\tEventType\x12\x16\n" +
|
||||
"\x12EVENT_TYPE_UNKNOWN\x10\x00\x12\x1c\n" +
|
||||
"\x18EVENT_TYPE_CLIENT_HEADER\x10\x01\x12\x1c\n" +
|
||||
"\x18EVENT_TYPE_SERVER_HEADER\x10\x02\x12\x1d\n" +
|
||||
"\x19EVENT_TYPE_CLIENT_MESSAGE\x10\x03\x12\x1d\n" +
|
||||
"\x19EVENT_TYPE_SERVER_MESSAGE\x10\x04\x12 \n" +
|
||||
"\x1cEVENT_TYPE_CLIENT_HALF_CLOSE\x10\x05\x12\x1d\n" +
|
||||
"\x19EVENT_TYPE_SERVER_TRAILER\x10\x06\x12\x15\n" +
|
||||
"\x11EVENT_TYPE_CANCEL\x10\a\"B\n" +
|
||||
"\x06Logger\x12\x12\n" +
|
||||
"\x0eLOGGER_UNKNOWN\x10\x00\x12\x11\n" +
|
||||
"\rLOGGER_CLIENT\x10\x01\x12\x11\n" +
|
||||
"\rLOGGER_SERVER\x10\x02B\t\n" +
|
||||
"\apayload\"\xbb\x01\n" +
|
||||
"\fClientHeader\x127\n" +
|
||||
"\bmetadata\x18\x01 \x01(\v2\x1b.grpc.binarylog.v1.MetadataR\bmetadata\x12\x1f\n" +
|
||||
"\vmethod_name\x18\x02 \x01(\tR\n" +
|
||||
"methodName\x12\x1c\n" +
|
||||
"\tauthority\x18\x03 \x01(\tR\tauthority\x123\n" +
|
||||
"\atimeout\x18\x04 \x01(\v2\x19.google.protobuf.DurationR\atimeout\"G\n" +
|
||||
"\fServerHeader\x127\n" +
|
||||
"\bmetadata\x18\x01 \x01(\v2\x1b.grpc.binarylog.v1.MetadataR\bmetadata\"\xb1\x01\n" +
|
||||
"\aTrailer\x127\n" +
|
||||
"\bmetadata\x18\x01 \x01(\v2\x1b.grpc.binarylog.v1.MetadataR\bmetadata\x12\x1f\n" +
|
||||
"\vstatus_code\x18\x02 \x01(\rR\n" +
|
||||
"statusCode\x12%\n" +
|
||||
"\x0estatus_message\x18\x03 \x01(\tR\rstatusMessage\x12%\n" +
|
||||
"\x0estatus_details\x18\x04 \x01(\fR\rstatusDetails\"5\n" +
|
||||
"\aMessage\x12\x16\n" +
|
||||
"\x06length\x18\x01 \x01(\rR\x06length\x12\x12\n" +
|
||||
"\x04data\x18\x02 \x01(\fR\x04data\"B\n" +
|
||||
"\bMetadata\x126\n" +
|
||||
"\x05entry\x18\x01 \x03(\v2 .grpc.binarylog.v1.MetadataEntryR\x05entry\"7\n" +
|
||||
"\rMetadataEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\fR\x05value\"\xb8\x01\n" +
|
||||
"\aAddress\x123\n" +
|
||||
"\x04type\x18\x01 \x01(\x0e2\x1f.grpc.binarylog.v1.Address.TypeR\x04type\x12\x18\n" +
|
||||
"\aaddress\x18\x02 \x01(\tR\aaddress\x12\x17\n" +
|
||||
"\aip_port\x18\x03 \x01(\rR\x06ipPort\"E\n" +
|
||||
"\x04Type\x12\x10\n" +
|
||||
"\fTYPE_UNKNOWN\x10\x00\x12\r\n" +
|
||||
"\tTYPE_IPV4\x10\x01\x12\r\n" +
|
||||
"\tTYPE_IPV6\x10\x02\x12\r\n" +
|
||||
"\tTYPE_UNIX\x10\x03B\\\n" +
|
||||
"\x14io.grpc.binarylog.v1B\x0eBinaryLogProtoP\x01Z2google.golang.org/grpc/binarylog/grpc_binarylog_v1b\x06proto3"
|
||||
|
||||
var (
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescOnce sync.Once
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData = file_grpc_binlog_v1_binarylog_proto_rawDesc
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_grpc_binlog_v1_binarylog_proto_rawDescGZIP() []byte {
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescOnce.Do(func() {
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_binlog_v1_binarylog_proto_rawDescData)
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_grpc_binlog_v1_binarylog_proto_rawDesc), len(file_grpc_binlog_v1_binarylog_proto_rawDesc)))
|
||||
})
|
||||
return file_grpc_binlog_v1_binarylog_proto_rawDescData
|
||||
}
|
||||
|
|
@ -1057,104 +977,6 @@ func file_grpc_binlog_v1_binarylog_proto_init() {
|
|||
if File_grpc_binlog_v1_binarylog_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GrpcLogEntry); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ClientHeader); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServerHeader); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Trailer); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Message); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Metadata); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*MetadataEntry); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Address); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_grpc_binlog_v1_binarylog_proto_msgTypes[0].OneofWrappers = []any{
|
||||
(*GrpcLogEntry_ClientHeader)(nil),
|
||||
(*GrpcLogEntry_ServerHeader)(nil),
|
||||
|
|
@ -1165,7 +987,7 @@ func file_grpc_binlog_v1_binarylog_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_grpc_binlog_v1_binarylog_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_grpc_binlog_v1_binarylog_proto_rawDesc), len(file_grpc_binlog_v1_binarylog_proto_rawDesc)),
|
||||
NumEnums: 3,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
|
|
@ -1177,7 +999,6 @@ func file_grpc_binlog_v1_binarylog_proto_init() {
|
|||
MessageInfos: file_grpc_binlog_v1_binarylog_proto_msgTypes,
|
||||
}.Build()
|
||||
File_grpc_binlog_v1_binarylog_proto = out.File
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDesc = nil
|
||||
file_grpc_binlog_v1_binarylog_proto_goTypes = nil
|
||||
file_grpc_binlog_v1_binarylog_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,12 +118,26 @@ func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*ires
|
|||
|
||||
// NewClient creates a new gRPC "channel" for the target URI provided. No I/O
|
||||
// is performed. Use of the ClientConn for RPCs will automatically cause it to
|
||||
// connect. Connect may be used to manually create a connection, but for most
|
||||
// users this is unnecessary.
|
||||
// connect. The Connect method may be called to manually create a connection,
|
||||
// but for most users this should be unnecessary.
|
||||
//
|
||||
// The target name syntax is defined in
|
||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md. e.g. to use dns
|
||||
// resolver, a "dns:///" prefix should be applied to the target.
|
||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md. E.g. to use the dns
|
||||
// name resolver, a "dns:///" prefix may be applied to the target. The default
|
||||
// name resolver will be used if no scheme is detected, or if the parsed scheme
|
||||
// is not a registered name resolver. The default resolver is "dns" but can be
|
||||
// overridden using the resolver package's SetDefaultScheme.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// - "foo.googleapis.com:8080"
|
||||
// - "dns:///foo.googleapis.com:8080"
|
||||
// - "dns:///foo.googleapis.com"
|
||||
// - "dns:///10.0.0.213:8080"
|
||||
// - "dns:///%5B2001:db8:85a3:8d3:1319:8a2e:370:7348%5D:443"
|
||||
// - "dns://8.8.8.8/foo.googleapis.com:8080"
|
||||
// - "dns://8.8.8.8/foo.googleapis.com"
|
||||
// - "zookeeper://zk.example.com:9900/example_service"
|
||||
//
|
||||
// The DialOptions returned by WithBlock, WithTimeout,
|
||||
// WithReturnConnectionError, and FailOnNonTempDialError are ignored by this
|
||||
|
|
@ -181,7 +195,7 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error)
|
|||
}
|
||||
cc.dopts.defaultServiceConfig, _ = scpr.Config.(*ServiceConfig)
|
||||
}
|
||||
cc.mkp = cc.dopts.copts.KeepaliveParams
|
||||
cc.keepaliveParams = cc.dopts.copts.KeepaliveParams
|
||||
|
||||
if err = cc.initAuthority(); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -225,7 +239,12 @@ func Dial(target string, opts ...DialOption) (*ClientConn, error) {
|
|||
func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *ClientConn, err error) {
|
||||
// At the end of this method, we kick the channel out of idle, rather than
|
||||
// waiting for the first rpc.
|
||||
opts = append([]DialOption{withDefaultScheme("passthrough")}, opts...)
|
||||
//
|
||||
// WithLocalDNSResolution dial option in `grpc.Dial` ensures that it
|
||||
// preserves behavior: when default scheme passthrough is used, skip
|
||||
// hostname resolution, when "dns" is used for resolution, perform
|
||||
// resolution on the client.
|
||||
opts = append([]DialOption{withDefaultScheme("passthrough"), WithLocalDNSResolution()}, opts...)
|
||||
cc, err := NewClient(target, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -618,7 +637,7 @@ type ClientConn struct {
|
|||
balancerWrapper *ccBalancerWrapper // Always recreated whenever entering idle to simplify Close.
|
||||
sc *ServiceConfig // Latest service config received from the resolver.
|
||||
conns map[*addrConn]struct{} // Set to nil on close.
|
||||
mkp keepalive.ClientParameters // May be updated upon receipt of a GoAway.
|
||||
keepaliveParams keepalive.ClientParameters // May be updated upon receipt of a GoAway.
|
||||
// firstResolveEvent is used to track whether the name resolver sent us at
|
||||
// least one update. RPCs block on this event. May be accessed without mu
|
||||
// if we know we cannot be asked to enter idle mode while accessing it (e.g.
|
||||
|
|
@ -670,22 +689,31 @@ func (cc *ClientConn) Connect() {
|
|||
cc.mu.Unlock()
|
||||
}
|
||||
|
||||
// waitForResolvedAddrs blocks until the resolver has provided addresses or the
|
||||
// context expires. Returns nil unless the context expires first; otherwise
|
||||
// returns a status error based on the context.
|
||||
func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error {
|
||||
// waitForResolvedAddrs blocks until the resolver provides addresses or the
|
||||
// context expires, whichever happens first.
|
||||
//
|
||||
// Error is nil unless the context expires first; otherwise returns a status
|
||||
// error based on the context.
|
||||
//
|
||||
// The returned boolean indicates whether it did block or not. If the
|
||||
// resolution has already happened once before, it returns false without
|
||||
// blocking. Otherwise, it wait for the resolution and return true if
|
||||
// resolution has succeeded or return false along with error if resolution has
|
||||
// failed.
|
||||
func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) (bool, error) {
|
||||
// This is on the RPC path, so we use a fast path to avoid the
|
||||
// more-expensive "select" below after the resolver has returned once.
|
||||
if cc.firstResolveEvent.HasFired() {
|
||||
return nil
|
||||
return false, nil
|
||||
}
|
||||
internal.NewStreamWaitingForResolver()
|
||||
select {
|
||||
case <-cc.firstResolveEvent.Done():
|
||||
return nil
|
||||
return true, nil
|
||||
case <-ctx.Done():
|
||||
return status.FromContextError(ctx.Err()).Err()
|
||||
return false, status.FromContextError(ctx.Err()).Err()
|
||||
case <-cc.ctx.Done():
|
||||
return ErrClientConnClosing
|
||||
return false, ErrClientConnClosing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -775,10 +803,7 @@ func (cc *ClientConn) updateResolverStateAndUnlock(s resolver.State, err error)
|
|||
}
|
||||
}
|
||||
|
||||
var balCfg serviceconfig.LoadBalancingConfig
|
||||
if cc.sc != nil && cc.sc.lbConfig != nil {
|
||||
balCfg = cc.sc.lbConfig
|
||||
}
|
||||
balCfg := cc.sc.lbConfig
|
||||
bw := cc.balancerWrapper
|
||||
cc.mu.Unlock()
|
||||
|
||||
|
|
@ -870,7 +895,13 @@ func (cc *ClientConn) Target() string {
|
|||
return cc.target
|
||||
}
|
||||
|
||||
// CanonicalTarget returns the canonical target string of the ClientConn.
|
||||
// CanonicalTarget returns the canonical target string used when creating cc.
|
||||
//
|
||||
// This always has the form "<scheme>://[authority]/<endpoint>". For example:
|
||||
//
|
||||
// - "dns:///example.com:42"
|
||||
// - "dns://8.8.8.8/example.com:42"
|
||||
// - "unix:///path/to/socket"
|
||||
func (cc *ClientConn) CanonicalTarget() string {
|
||||
return cc.parsedTarget.String()
|
||||
}
|
||||
|
|
@ -1209,12 +1240,11 @@ func (ac *addrConn) updateConnectivityState(s connectivity.State, lastErr error)
|
|||
// adjustParams updates parameters used to create transports upon
|
||||
// receiving a GoAway.
|
||||
func (ac *addrConn) adjustParams(r transport.GoAwayReason) {
|
||||
switch r {
|
||||
case transport.GoAwayTooManyPings:
|
||||
if r == transport.GoAwayTooManyPings {
|
||||
v := 2 * ac.dopts.copts.KeepaliveParams.Time
|
||||
ac.cc.mu.Lock()
|
||||
if v > ac.cc.mkp.Time {
|
||||
ac.cc.mkp.Time = v
|
||||
if v > ac.cc.keepaliveParams.Time {
|
||||
ac.cc.keepaliveParams.Time = v
|
||||
}
|
||||
ac.cc.mu.Unlock()
|
||||
}
|
||||
|
|
@ -1310,7 +1340,7 @@ func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, c
|
|||
ac.mu.Lock()
|
||||
|
||||
ac.cc.mu.RLock()
|
||||
ac.dopts.copts.KeepaliveParams = ac.cc.mkp
|
||||
ac.dopts.copts.KeepaliveParams = ac.cc.keepaliveParams
|
||||
ac.cc.mu.RUnlock()
|
||||
|
||||
copts := ac.dopts.copts
|
||||
|
|
@ -1374,7 +1404,7 @@ func (ac *addrConn) createTransport(ctx context.Context, addr resolver.Address,
|
|||
defer cancel()
|
||||
copts.ChannelzParent = ac.channelz
|
||||
|
||||
newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, addr, copts, onClose)
|
||||
newTr, err := transport.NewHTTP2Client(connectCtx, ac.cc.ctx, addr, copts, onClose)
|
||||
if err != nil {
|
||||
if logger.V(2) {
|
||||
logger.Infof("Creating new client transport to %q: %v", addr, err)
|
||||
|
|
@ -1448,7 +1478,7 @@ func (ac *addrConn) startHealthCheck(ctx context.Context) {
|
|||
if !ac.scopts.HealthCheckEnabled {
|
||||
return
|
||||
}
|
||||
healthCheckFunc := ac.cc.dopts.healthCheckFunc
|
||||
healthCheckFunc := internal.HealthCheckFunc
|
||||
if healthCheckFunc == nil {
|
||||
// The health package is not imported to set health check function.
|
||||
//
|
||||
|
|
@ -1480,7 +1510,7 @@ func (ac *addrConn) startHealthCheck(ctx context.Context) {
|
|||
}
|
||||
// Start the health checking stream.
|
||||
go func() {
|
||||
err := ac.cc.dopts.healthCheckFunc(ctx, newStream, setConnectivityState, healthCheckConfig.ServiceName)
|
||||
err := healthCheckFunc(ctx, newStream, setConnectivityState, healthCheckConfig.ServiceName)
|
||||
if err != nil {
|
||||
if status.Code(err) == codes.Unimplemented {
|
||||
channelz.Error(logger, ac.channelz, "Subchannel health check is unimplemented at server side, thus health check is disabled")
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func (c codecV0Bridge) Marshal(v any) (mem.BufferSlice, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mem.BufferSlice{mem.NewBuffer(&data, nil)}, nil
|
||||
return mem.BufferSlice{mem.SliceBuffer(data)}, nil
|
||||
}
|
||||
|
||||
func (c codecV0Bridge) Unmarshal(data mem.BufferSlice, v any) (err error) {
|
||||
|
|
|
|||
|
|
@ -120,6 +120,20 @@ type AuthInfo interface {
|
|||
AuthType() string
|
||||
}
|
||||
|
||||
// AuthorityValidator validates the authority used to override the `:authority`
|
||||
// header. This is an optional interface that implementations of AuthInfo can
|
||||
// implement if they support per-RPC authority overrides. It is invoked when the
|
||||
// application attempts to override the HTTP/2 `:authority` header using the
|
||||
// CallAuthority call option.
|
||||
type AuthorityValidator interface {
|
||||
// ValidateAuthority checks the authority value used to override the
|
||||
// `:authority` header. The authority parameter is the override value
|
||||
// provided by the application via the CallAuthority option. This value
|
||||
// typically corresponds to the server hostname or endpoint the RPC is
|
||||
// targeting. It returns non-nil error if the validation fails.
|
||||
ValidateAuthority(authority string) error
|
||||
}
|
||||
|
||||
// ErrConnDispatched indicates that rawConn has been dispatched out of gRPC
|
||||
// and the caller should not close rawConn.
|
||||
var ErrConnDispatched = errors.New("credentials: rawConn is dispatched out of gRPC")
|
||||
|
|
@ -207,14 +221,32 @@ type RequestInfo struct {
|
|||
AuthInfo AuthInfo
|
||||
}
|
||||
|
||||
// requestInfoKey is a struct to be used as the key to store RequestInfo in a
|
||||
// context.
|
||||
type requestInfoKey struct{}
|
||||
|
||||
// RequestInfoFromContext extracts the RequestInfo from the context if it exists.
|
||||
//
|
||||
// This API is experimental.
|
||||
func RequestInfoFromContext(ctx context.Context) (ri RequestInfo, ok bool) {
|
||||
ri, ok = icredentials.RequestInfoFromContext(ctx).(RequestInfo)
|
||||
ri, ok = ctx.Value(requestInfoKey{}).(RequestInfo)
|
||||
return ri, ok
|
||||
}
|
||||
|
||||
// NewContextWithRequestInfo creates a new context from ctx and attaches ri to it.
|
||||
//
|
||||
// This RequestInfo will be accessible via RequestInfoFromContext.
|
||||
//
|
||||
// Intended to be used from tests for PerRPCCredentials implementations (that
|
||||
// often need to check connection's SecurityLevel). Should not be used from
|
||||
// non-test code: the gRPC client already prepares a context with the correct
|
||||
// RequestInfo attached when calling PerRPCCredentials.GetRequestMetadata.
|
||||
//
|
||||
// This API is experimental.
|
||||
func NewContextWithRequestInfo(ctx context.Context, ri RequestInfo) context.Context {
|
||||
return context.WithValue(ctx, requestInfoKey{}, ri)
|
||||
}
|
||||
|
||||
// ClientHandshakeInfo holds data to be passed to ClientHandshake. This makes
|
||||
// it possible to pass arbitrary data to the handshaker from gRPC, resolver,
|
||||
// balancer etc. Individual credential implementations control the actual
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import (
|
|||
// NewCredentials returns a credentials which disables transport security.
|
||||
//
|
||||
// Note that using this credentials with per-RPC credentials which require
|
||||
// transport security is incompatible and will cause grpc.Dial() to fail.
|
||||
// transport security is incompatible and will cause RPCs to fail.
|
||||
func NewCredentials() credentials.TransportCredentials {
|
||||
return insecureTC{}
|
||||
}
|
||||
|
|
@ -71,6 +71,12 @@ func (info) AuthType() string {
|
|||
return "insecure"
|
||||
}
|
||||
|
||||
// ValidateAuthority allows any value to be overridden for the :authority
|
||||
// header.
|
||||
func (info) ValidateAuthority(string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// insecureBundle implements an insecure bundle.
|
||||
// An insecure bundle provides a thin wrapper around insecureTC to support
|
||||
// the credentials.Bundle interface.
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
|
|
@ -32,6 +33,8 @@ import (
|
|||
"google.golang.org/grpc/internal/envconfig"
|
||||
)
|
||||
|
||||
const alpnFailureHelpMessage = "If you upgraded from a grpc-go version earlier than 1.67, your TLS connections may have stopped working due to ALPN enforcement. For more details, see: https://github.com/grpc/grpc-go/issues/434"
|
||||
|
||||
var logger = grpclog.Component("credentials")
|
||||
|
||||
// TLSInfo contains the auth information for a TLS authenticated connection.
|
||||
|
|
@ -48,6 +51,21 @@ func (t TLSInfo) AuthType() string {
|
|||
return "tls"
|
||||
}
|
||||
|
||||
// ValidateAuthority validates the provided authority being used to override the
|
||||
// :authority header by verifying it against the peer certificates. It returns a
|
||||
// non-nil error if the validation fails.
|
||||
func (t TLSInfo) ValidateAuthority(authority string) error {
|
||||
var errs []error
|
||||
for _, cert := range t.State.PeerCertificates {
|
||||
var err error
|
||||
if err = cert.VerifyHostname(authority); err == nil {
|
||||
return nil
|
||||
}
|
||||
errs = append(errs, err)
|
||||
}
|
||||
return fmt.Errorf("credentials: invalid authority %q: %v", authority, errors.Join(errs...))
|
||||
}
|
||||
|
||||
// cipherSuiteLookup returns the string version of a TLS cipher suite ID.
|
||||
func cipherSuiteLookup(cipherSuiteID uint16) string {
|
||||
for _, s := range tls.CipherSuites() {
|
||||
|
|
@ -128,7 +146,7 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, authority string, rawCon
|
|||
if np == "" {
|
||||
if envconfig.EnforceALPNEnabled {
|
||||
conn.Close()
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property")
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property. %s", alpnFailureHelpMessage)
|
||||
}
|
||||
logger.Warningf("Allowing TLS connection to server %q with ALPN disabled. TLS connections to servers with ALPN disabled will be disallowed in future grpc-go releases", cfg.ServerName)
|
||||
}
|
||||
|
|
@ -158,7 +176,7 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error)
|
|||
if cs.NegotiatedProtocol == "" {
|
||||
if envconfig.EnforceALPNEnabled {
|
||||
conn.Close()
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property")
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property. %s", alpnFailureHelpMessage)
|
||||
} else if logger.V(2) {
|
||||
logger.Info("Allowing TLS connection from client with ALPN disabled. TLS connections with ALPN disabled will be disallowed in future grpc-go releases")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ type dialOptions struct {
|
|||
chainUnaryInts []UnaryClientInterceptor
|
||||
chainStreamInts []StreamClientInterceptor
|
||||
|
||||
cp Compressor
|
||||
compressorV0 Compressor
|
||||
dc Decompressor
|
||||
bs internalbackoff.Strategy
|
||||
block bool
|
||||
|
|
@ -87,7 +87,6 @@ type dialOptions struct {
|
|||
disableServiceConfig bool
|
||||
disableRetry bool
|
||||
disableHealthCheck bool
|
||||
healthCheckFunc internal.HealthChecker
|
||||
minConnectTimeout func() time.Duration
|
||||
defaultServiceConfig *ServiceConfig // defaultServiceConfig is parsed from defaultServiceConfigRawJSON.
|
||||
defaultServiceConfigRawJSON *string
|
||||
|
|
@ -95,6 +94,8 @@ type dialOptions struct {
|
|||
idleTimeout time.Duration
|
||||
defaultScheme string
|
||||
maxCallAttempts int
|
||||
enableLocalDNSResolution bool // Specifies if target hostnames should be resolved when proxying is enabled.
|
||||
useProxy bool // Specifies if a server should be connected via proxy.
|
||||
}
|
||||
|
||||
// DialOption configures how we set up the connection.
|
||||
|
|
@ -212,6 +213,7 @@ func WithReadBufferSize(s int) DialOption {
|
|||
func WithInitialWindowSize(s int32) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.copts.InitialWindowSize = s
|
||||
o.copts.StaticWindowSize = true
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -221,6 +223,26 @@ func WithInitialWindowSize(s int32) DialOption {
|
|||
func WithInitialConnWindowSize(s int32) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.copts.InitialConnWindowSize = s
|
||||
o.copts.StaticWindowSize = true
|
||||
})
|
||||
}
|
||||
|
||||
// WithStaticStreamWindowSize returns a DialOption which sets the initial
|
||||
// stream window size to the value provided and disables dynamic flow control.
|
||||
func WithStaticStreamWindowSize(s int32) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.copts.InitialWindowSize = s
|
||||
o.copts.StaticWindowSize = true
|
||||
})
|
||||
}
|
||||
|
||||
// WithStaticConnWindowSize returns a DialOption which sets the initial
|
||||
// connection window size to the value provided and disables dynamic flow
|
||||
// control.
|
||||
func WithStaticConnWindowSize(s int32) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.copts.InitialConnWindowSize = s
|
||||
o.copts.StaticWindowSize = true
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +279,7 @@ func WithCodec(c Codec) DialOption {
|
|||
// Deprecated: use UseCompressor instead. Will be supported throughout 1.x.
|
||||
func WithCompressor(cp Compressor) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.cp = cp
|
||||
o.compressorV0 = cp
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +381,7 @@ func WithReturnConnectionError() DialOption {
|
|||
//
|
||||
// Note that using this DialOption with per-RPC credentials (through
|
||||
// WithCredentialsBundle or WithPerRPCCredentials) which require transport
|
||||
// security is incompatible and will cause grpc.Dial() to fail.
|
||||
// security is incompatible and will cause RPCs to fail.
|
||||
//
|
||||
// Deprecated: use WithTransportCredentials and insecure.NewCredentials()
|
||||
// instead. Will be supported throughout 1.x.
|
||||
|
|
@ -378,7 +400,22 @@ func WithInsecure() DialOption {
|
|||
// later release.
|
||||
func WithNoProxy() DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.copts.UseProxy = false
|
||||
o.useProxy = false
|
||||
})
|
||||
}
|
||||
|
||||
// WithLocalDNSResolution forces local DNS name resolution even when a proxy is
|
||||
// specified in the environment. By default, the server name is provided
|
||||
// directly to the proxy as part of the CONNECT handshake. This is ignored if
|
||||
// WithNoProxy is used.
|
||||
//
|
||||
// # Experimental
|
||||
//
|
||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
||||
// later release.
|
||||
func WithLocalDNSResolution() DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.enableLocalDNSResolution = true
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -429,6 +466,11 @@ func WithTimeout(d time.Duration) DialOption {
|
|||
// returned by f, gRPC checks the error's Temporary() method to decide if it
|
||||
// should try to reconnect to the network address.
|
||||
//
|
||||
// Note that gRPC by default performs name resolution on the target passed to
|
||||
// NewClient. To bypass name resolution and cause the target string to be
|
||||
// passed directly to the dialer here instead, use the "passthrough" resolver
|
||||
// by specifying it in the target string, e.g. "passthrough:target".
|
||||
//
|
||||
// Note: All supported releases of Go (as of December 2023) override the OS
|
||||
// defaults for TCP keepalive time and interval to 15s. To enable TCP keepalive
|
||||
// with OS defaults for keepalive time and interval, use a net.Dialer that sets
|
||||
|
|
@ -445,10 +487,6 @@ func WithContextDialer(f func(context.Context, string) (net.Conn, error)) DialOp
|
|||
})
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.WithHealthCheckFunc = withHealthCheckFunc
|
||||
}
|
||||
|
||||
// WithDialer returns a DialOption that specifies a function to use for dialing
|
||||
// network addresses. If FailOnNonTempDialError() is set to true, and an error
|
||||
// is returned by f, gRPC checks the error's Temporary() method to decide if it
|
||||
|
|
@ -662,30 +700,20 @@ func WithDisableHealthCheck() DialOption {
|
|||
})
|
||||
}
|
||||
|
||||
// withHealthCheckFunc replaces the default health check function with the
|
||||
// provided one. It makes tests easier to change the health check function.
|
||||
//
|
||||
// For testing purpose only.
|
||||
func withHealthCheckFunc(f internal.HealthChecker) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.healthCheckFunc = f
|
||||
})
|
||||
}
|
||||
|
||||
func defaultDialOptions() dialOptions {
|
||||
return dialOptions{
|
||||
copts: transport.ConnectOptions{
|
||||
ReadBufferSize: defaultReadBufSize,
|
||||
WriteBufferSize: defaultWriteBufSize,
|
||||
UseProxy: true,
|
||||
UserAgent: grpcUA,
|
||||
BufferPool: mem.DefaultBufferPool(),
|
||||
},
|
||||
bs: internalbackoff.DefaultExponential,
|
||||
healthCheckFunc: internal.HealthCheckFunc,
|
||||
idleTimeout: 30 * time.Minute,
|
||||
defaultScheme: "dns",
|
||||
maxCallAttempts: defaultMaxCallAttempts,
|
||||
bs: internalbackoff.DefaultExponential,
|
||||
idleTimeout: 30 * time.Minute,
|
||||
defaultScheme: "dns",
|
||||
maxCallAttempts: defaultMaxCallAttempts,
|
||||
useProxy: true,
|
||||
enableLocalDNSResolution: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -34,7 +35,7 @@ var logger = grpclog.Component("metrics-registry")
|
|||
// DefaultMetrics are the default metrics registered through global metrics
|
||||
// registry. This is written to at initialization time only, and is read only
|
||||
// after initialization.
|
||||
var DefaultMetrics = NewMetrics()
|
||||
var DefaultMetrics = stats.NewMetricSet()
|
||||
|
||||
// MetricDescriptor is the data for a registered metric.
|
||||
type MetricDescriptor struct {
|
||||
|
|
@ -42,7 +43,7 @@ type MetricDescriptor struct {
|
|||
// (including any per call metrics). See
|
||||
// https://github.com/grpc/proposal/blob/master/A79-non-per-call-metrics-architecture.md#metric-instrument-naming-conventions
|
||||
// for metric naming conventions.
|
||||
Name Metric
|
||||
Name string
|
||||
// The description of this metric.
|
||||
Description string
|
||||
// The unit (e.g. entries, seconds) of this metric.
|
||||
|
|
@ -154,27 +155,27 @@ func (h *Int64GaugeHandle) Record(recorder MetricsRecorder, incr int64, labels .
|
|||
}
|
||||
|
||||
// registeredMetrics are the registered metric descriptor names.
|
||||
var registeredMetrics = make(map[Metric]bool)
|
||||
var registeredMetrics = make(map[string]bool)
|
||||
|
||||
// metricsRegistry contains all of the registered metrics.
|
||||
//
|
||||
// This is written to only at init time, and read only after that.
|
||||
var metricsRegistry = make(map[Metric]*MetricDescriptor)
|
||||
var metricsRegistry = make(map[string]*MetricDescriptor)
|
||||
|
||||
// DescriptorForMetric returns the MetricDescriptor from the global registry.
|
||||
//
|
||||
// Returns nil if MetricDescriptor not present.
|
||||
func DescriptorForMetric(metric Metric) *MetricDescriptor {
|
||||
return metricsRegistry[metric]
|
||||
func DescriptorForMetric(metricName string) *MetricDescriptor {
|
||||
return metricsRegistry[metricName]
|
||||
}
|
||||
|
||||
func registerMetric(name Metric, def bool) {
|
||||
if registeredMetrics[name] {
|
||||
logger.Fatalf("metric %v already registered", name)
|
||||
func registerMetric(metricName string, def bool) {
|
||||
if registeredMetrics[metricName] {
|
||||
logger.Fatalf("metric %v already registered", metricName)
|
||||
}
|
||||
registeredMetrics[name] = true
|
||||
registeredMetrics[metricName] = true
|
||||
if def {
|
||||
DefaultMetrics = DefaultMetrics.Add(name)
|
||||
DefaultMetrics = DefaultMetrics.Add(metricName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,8 +257,8 @@ func snapshotMetricsRegistryForTesting() func() {
|
|||
oldRegisteredMetrics := registeredMetrics
|
||||
oldMetricsRegistry := metricsRegistry
|
||||
|
||||
registeredMetrics = make(map[Metric]bool)
|
||||
metricsRegistry = make(map[Metric]*MetricDescriptor)
|
||||
registeredMetrics = make(map[string]bool)
|
||||
metricsRegistry = make(map[string]*MetricDescriptor)
|
||||
maps.Copy(registeredMetrics, registeredMetrics)
|
||||
maps.Copy(metricsRegistry, metricsRegistry)
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue