module S = Tiny_httpd
open Protocol

let query_dispatch _req =
  let data = default_global_dispatch_data
    ~retcode:0l
    ~msg:"OK"
    ~server_list:[{
      name = "lingsha_sr";
      display_name = "LingshaSR";
      title = "LingshaSR";
      env_type = "2";
      msg = "OK";
      dispatch_url = "http://127.0.0.1:21000/query_gateway";
    }] () in

  let encoder = Pbrt.Encoder.create () in
  encode_pb_global_dispatch_data data encoder;

  let buf = Pbrt.Encoder.to_string encoder in
  S.Response.make_string (Ok (Base64.encode_string buf))

let query_gateway _req =
  let data = default_gateserver
    ~retcode:0l
    ~ip:"127.0.0.1"
    ~port:23301l
    ~use_tcp:true
    ~asset_bundle_url:"https://autopatchcn-ipv6.bhsr.com/asb/BetaLive/output_7663997_cd086af3f307"
    ~ex_resource_url:"https://autopatchcn-ipv6.bhsr.com/design_data/BetaLive/output_7680597_a60760caba0f"
    ~lua_url:"https://autopatchcn-ipv6.bhsr.com/lua/BetaLive/output_7668875_0231727458ad"
    ~lua_version:"7668875"
    ~fkenkkhlhhd:true
    ~opgmnlinakc:true
    ~mbdacjejamf:true
    ~bgpcckkddmb:true
    ~kjadmknddjl:true
    ~gjaeghbeaio:true
    ~lamjdogmfam:true
    ~hafcipegpin:true
    () in

  let encoder = Pbrt.Encoder.create () in
  encode_pb_gateserver data encoder;

  let buf = Pbrt.Encoder.to_string encoder in
  S.Response.make_string (Ok (Base64.encode_string buf))
