Exemple #1
0
        futures.ThreadPoolExecutor(2),
        interceptors=[ErrorSanitizationInterceptor(),
                      LoggingInterceptor()])
    open_server.add_insecure_port("[::]:1752")
    auth_pb2_grpc.add_AuthServicer_to_server(auth, open_server)
    bugs_pb2_grpc.add_BugsServicer_to_server(Bugs(), open_server)
    resources_pb2_grpc.add_ResourcesServicer_to_server(Resources(),
                                                       open_server)
    open_server.start()

    jailed_server = grpc.server(
        futures.ThreadPoolExecutor(2),
        interceptors=[
            ErrorSanitizationInterceptor(),
            LoggingInterceptor(),
            auth.get_auth_interceptor(allow_jailed=True),
        ],
    )
    jailed_server.add_insecure_port("[::]:1754")
    jail_pb2_grpc.add_JailServicer_to_server(Jail(), jailed_server)
    jailed_server.start()

    servicer = API()
    server = grpc.server(
        futures.ThreadPoolExecutor(2),
        interceptors=[
            ErrorSanitizationInterceptor(),
            LoggingInterceptor(),
            auth.get_auth_interceptor(allow_jailed=False),
        ],
    )
Exemple #2
0
logging.info(f"Adding dummy data")

try:
    add_dummy_data("src/dummy_data.json")
except IntegrityError as e:
    print("Failed to insert dummy data, is it already inserted?")

with session_scope(Session) as session:
    for user in session.query(User).all():
        print(user)

auth = Auth(Session)
auth_server = grpc.server(futures.ThreadPoolExecutor(2))
auth_server.add_insecure_port("[::]:1752")
auth_pb2_grpc.add_AuthServicer_to_server(auth, auth_server)
auth_server.start()

server = grpc.server(futures.ThreadPoolExecutor(2))
server = intercept_server(server, LoggingInterceptor())
server = intercept_server(server, auth.get_auth_interceptor())
server.add_insecure_port("[::]:1751")
servicer = API(Session)
api_pb2_grpc.add_APIServicer_to_server(servicer, server)
server.start()

logging.info(f"Serving on 1751 and 1752 (auth)")

server.wait_for_termination()
auth_server.wait_for_termination()
Exemple #3
0
apply_migrations()

if config.config["ADD_DUMMY_DATA"]:
    add_dummy_data(Session, "src/dummy_data.json")

logger.info(f"Starting")

auth = Auth(Session)
open_server = grpc.server(futures.ThreadPoolExecutor(2), interceptors=[LoggingInterceptor()])
open_server.add_insecure_port("[::]:1752")
auth_pb2_grpc.add_AuthServicer_to_server(auth, open_server)
bugs_pb2_grpc.add_BugsServicer_to_server(Bugs(), open_server)
open_server.start()

jailed_server = grpc.server(
    futures.ThreadPoolExecutor(2), interceptors=[LoggingInterceptor(), auth.get_auth_interceptor(allow_jailed=True)]
)
jailed_server.add_insecure_port("[::]:1754")
jail_pb2_grpc.add_JailServicer_to_server(Jail(Session), jailed_server)
jailed_server.start()

servicer = API(Session)
server = grpc.server(
    futures.ThreadPoolExecutor(2),
    interceptors=[
        LoggingInterceptor(),
        auth.get_auth_interceptor(allow_jailed=False),
        UpdateLastActiveTimeInterceptor(servicer.update_last_active_time),
    ],
)
server.add_insecure_port("[::]:1751")