From e5ca8e3fbccb2a494947a2df2ec5375b6cb0e21d Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Thu, 16 Sep 2021 08:29:27 -0300 Subject: [PATCH] Add variant route --- protobuf/Makefile | 1 + protobuf/variants.proto | 9 +++ protobuf/variants_pb2.py | 118 +++++++++++++++++++++++++++++++++++++++ zwift_offline.py | 34 +++++++++++ 4 files changed, 162 insertions(+) create mode 100644 protobuf/variants.proto create mode 100644 protobuf/variants_pb2.py diff --git a/protobuf/Makefile b/protobuf/Makefile index bdbf3e7..669c7b7 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -12,6 +12,7 @@ all: protoc --python_out=. tcp-node-msgs.proto protoc --python_out=. hash-seeds.proto protoc --python_out=. events.proto + protoc --python_out=. variants.proto clean: rm -f *_pb2.py *_pb2.pyc diff --git a/protobuf/variants.proto b/protobuf/variants.proto new file mode 100644 index 0000000..013792d --- /dev/null +++ b/protobuf/variants.proto @@ -0,0 +1,9 @@ +syntax = "proto2"; +message Variant { + required string name = 1; + optional uint32 value = 2; +} + +message Variants { + repeated Variant variants = 1; +} diff --git a/protobuf/variants_pb2.py b/protobuf/variants_pb2.py new file mode 100644 index 0000000..769d269 --- /dev/null +++ b/protobuf/variants_pb2.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: variants.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='variants.proto', + package='', + syntax='proto2', + serialized_options=None, + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n\x0evariants.proto\"&\n\x07Variant\x12\x0c\n\x04name\x18\x01 \x02(\t\x12\r\n\x05value\x18\x02 \x01(\r\"&\n\x08Variants\x12\x1a\n\x08variants\x18\x01 \x03(\x0b\x32\x08.Variant' +) + + + + +_VARIANT = _descriptor.Descriptor( + name='Variant', + full_name='Variant', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='Variant.name', index=0, + number=1, type=9, cpp_type=9, label=2, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='value', full_name='Variant.value', index=1, + number=2, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto2', + extension_ranges=[], + oneofs=[ + ], + serialized_start=18, + serialized_end=56, +) + + +_VARIANTS = _descriptor.Descriptor( + name='Variants', + full_name='Variants', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='variants', full_name='Variants.variants', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto2', + extension_ranges=[], + oneofs=[ + ], + serialized_start=58, + serialized_end=96, +) + +_VARIANTS.fields_by_name['variants'].message_type = _VARIANT +DESCRIPTOR.message_types_by_name['Variant'] = _VARIANT +DESCRIPTOR.message_types_by_name['Variants'] = _VARIANTS +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Variant = _reflection.GeneratedProtocolMessageType('Variant', (_message.Message,), { + 'DESCRIPTOR' : _VARIANT, + '__module__' : 'variants_pb2' + # @@protoc_insertion_point(class_scope:Variant) + }) +_sym_db.RegisterMessage(Variant) + +Variants = _reflection.GeneratedProtocolMessageType('Variants', (_message.Message,), { + 'DESCRIPTOR' : _VARIANTS, + '__module__' : 'variants_pb2' + # @@protoc_insertion_point(class_scope:Variants) + }) +_sym_db.RegisterMessage(Variants) + + +# @@protoc_insertion_point(module_scope) diff --git a/zwift_offline.py b/zwift_offline.py index 8ed8a6d..8e34abe 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -44,6 +44,7 @@ import protobuf.world_pb2 as world_pb2 import protobuf.zfiles_pb2 as zfiles_pb2 import protobuf.hash_seeds_pb2 as hash_seeds_pb2 import protobuf.events_pb2 as events_pb2 +import protobuf.variants_pb2 as variants_pb2 import online_sync logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) @@ -1984,6 +1985,39 @@ def auth_realms_zwift_tokens_access_codes(): return FAKE_JWT, 200 +@app.route('/experimentation/v1/variant', methods=['POST']) +def experimentation_v1_variant(): + variant_list = [('game_1_12_pc_skip_activity_save_retry', None), + ('return_to_home', 1), + ('game_1_12_nhd_v1', 1), + ('game_1_13_japanese_medium_font', 1), + ('game_1_12_1_retire_client_chat_culling', 1), + ('game_1_14_draftlock_fix', None), + ('xplatform_partner_connection_vitality', None), + ('game_1_16_new_route_ui', 1), + ('pack_dynamics_30_global', None), + ('pack_dynamics_30_makuri', None), + ('pack_dynamics_30_london', None), + ('pack_dynamics_30_watopia', None), + ('pack_dynamics_30_exclude_events', None), + ('game_1_17_server_connection_notifications', None), + ('zc_ios_aug_2021_release_sync', None), + ('game_1_16_2_ble_alternate_unpair_all_paired_devices', 1), + ('game_1_17_game_client_activity_event', None), + ('game_1_17_tdf_femmes_yellow_jersey', None), + ('game_1_17_ble_disable_component_sport_filter', None), + ('game_1_15_assert_disable_abort', 1), + ('game_1_14_settings_refactor', None)] + + variants = variants_pb2.Variants() + for variant in variant_list: + item = variants.variants.add() + item.name = variant[0] + if variant[1] is not None: + item.value = variant[1] + return variants.SerializeToString(), 200 + + def run_standalone(passed_online, passed_global_pace_partners, passed_global_bots, passed_global_ghosts, passed_ghosts_enabled, passed_save_ghost, passed_player_update_queue, passed_discord): global online global global_pace_partners