示例#1
0
def add_user(uuid,
             email,
             security_type=SECURITY_TYPE_LEGACY,
             level=0,
             alter_id=32):
    channel = grpc.insecure_channel('%s:%s' % (SERVER_ADDRESS, SERVER_PORT))
    stub = command_pb2_grpc.HandlerServiceStub(channel)

    resp = stub.AlterInbound(
        command_pb2.AlterInboundRequest(
            tag=INBOUND_TAG,
            operation=typed_message_pb2.TypedMessage(
                type=command_pb2._ADDUSEROPERATION.full_name,
                value=command_pb2.AddUserOperation(user=user_pb2.User(
                    level=level,
                    email=email,
                    account=typed_message_pb2.TypedMessage(
                        type=account_pb2._ACCOUNT.full_name,
                        value=account_pb2.Account(
                            id=uuid,
                            alter_id=alter_id,
                            security_settings=headers_pb2.SecurityConfig(
                                type=security_type)).SerializeToString()))
                                                   ).SerializeToString())))
    print(resp)
示例#2
0
def remove_user(uuid, email):
    channel = grpc.insecure_channel('%s:%s' % (SERVER_ADDRESS, SERVER_PORT))
    stub = command_pb2_grpc.HandlerServiceStub(channel)

    resp = stub.AlterInbound(
        command_pb2.AlterInboundRequest(
            tag=INBOUND_TAG,
            operation=typed_message_pb2.TypedMessage(
                type=command_pb2._REMOVEUSEROPERATION.full_name,
                value=command_pb2.RemoveUserOperation(
                    email=email).SerializeToString())))
    print(resp)
示例#3
0
def add_inbound(tag):
    channel = grpc.insecure_channel('%s:%s' % (SERVER_ADDRESS, SERVER_PORT))
    stub = command_pb2_grpc.HandlerServiceStub(channel)

    resp = stub.AddInbound(
        command_pb2.AlterInboundRequest(
            inbound=config_pb2.InboundHandlerConfig(
                tag=tag,
                receiver_settings=typed_message_pb2.TypedMessage(
                    type=proxy_config_pb2._RECEIVERCONFIG.full_name,
                    value=proxy_config_pb2.ReceiverConfig(
                        port_range=port_pb2.PortRange(From=30, To=20),
                        listen=None,
                        allocation_strategy=None,
                        stream_settings=None,
                        receive_original_destination=None,
                        domain_override=None).SerializeToString()),
                proxy_settings=typed_message_pb2.TypedMessage(
                    type=command_pb2._ADDUSEROPERATION.full_name,
                    value=command_pb2.RemoveUserOperation(
                        email=email).SerializeToString()),
            )))
    print(resp)
示例#4
0
def to_typed_message(message):
    return typed_message_pb2.TypedMessage(type=message.DESCRIPTOR.full_name,
                                          value=message.SerializeToString())