1
0

userserv.rb 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. require "webrick"
  2. require "xmlrpc/server"
  3. require 'xmlrpc/client'
  4. require 'config.rb'
  5. class SessionServlet < WEBrick::HTTPServlet::AbstractServlet
  6. def do_DELETE(req, res)
  7. # does nothing, obviously
  8. STDERR.print "----\n"
  9. end
  10. end
  11. s = XMLRPC::WEBrickServlet.new
  12. s.add_handler("login_to_simulator") do |param|
  13. sc = SimConfig.new
  14. #
  15. # Some stuff just grabbed from a sniff of the session with OGS
  16. #
  17. zSessionId = "133086b6-1270-78c6-66f7-c7f64865b16c"
  18. zSecureSessionId = "6ee4df6a-0ea9-4cf5-8ac7-9745acbacccc"
  19. zAgentId = "0f00ba47-42d1-498e-b010-aa585a81862e"
  20. zAgentId = UUID.new.to_dashed_s
  21. STDERR.print "AgentID: #{zAgentId}\n"
  22. zCircuitCode = rand(0x1000000)
  23. zRegionX = sc.cfgSimX
  24. zRegionY = sc.cfgSimY
  25. xxSimParams = Hash.new
  26. xxSimParams["session_id"] = zSessionId.gsub("-","")
  27. xxSimParams["secure_session_id"] = zSecureSessionId.gsub("-","")
  28. xxSimParams["firstname"] = param["first"];
  29. xxSimParams["lastname"] = param["last"];
  30. xxSimParams["agent_id"] = zAgentId.gsub("-", "")
  31. xxSimParams["circuit_code"] = zCircuitCode
  32. xxSimParams["startpos_x"] = 128
  33. xxSimParams["startpos_y"] = 128
  34. xxSimParams["startpos_z"] = 30
  35. xxSimParams["regionhandle"] = ((zRegionX << 40) + (zRegionY *256)).to_s
  36. STDERR.print "Region handle: #{xxSimParams["regionhandle"]}\n"
  37. server = XMLRPC::Client.new2("http://#{sc.cfgSimIP}:#{sc.cfgSimPort}/")
  38. # the dispatcher in OpenSim.exe did not get excited from specifying
  39. # the content-type in the request.. no XML was executed at all.
  40. # this "fixes" it.
  41. server.http_header_extra = { "Content-Type" => "text/xml" };
  42. result = server.call("expect_user", xxSimParams )
  43. # STDERR.print result.inspect
  44. STDERR.print "---- notified the sim ----\n"
  45. responseData = Hash.new
  46. xxGlobalT = Hash.new
  47. xxGlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
  48. xxGlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
  49. xxGlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
  50. xxLoginFlags = Hash.new
  51. xxLoginFlags["daylight_savings"] = "N"
  52. xxLoginFlags["stipend_since_login"] = "N"
  53. xxLoginFlags["gendered"] = "Y"
  54. xxLoginFlags["ever_logged_in"] = "Y"
  55. responseData["first_name"] = param["first"]
  56. responseData["last_name"] = param["last"]
  57. responseData["ui-config"] = [ { "allow_first_life" => "Y" } ]
  58. responseData["login-flags"] = [ xxLoginFlags ]
  59. responseData["global-textures"] = [ xxGlobalT ]
  60. # responseData["classified_categories"] = [ { category_name => "Generic", category_id => 1 } ]
  61. # responseData["event_categories"] =
  62. responseData["inventory-skeleton"] = [
  63. { "folder_id" => "9846e02a-f41b-4199-860e-cde46cc25649",
  64. "parent_id" => "00000000-0000-0000-0000-000000000000",
  65. "name" => "My Inventory test",
  66. "type_default" => 8,
  67. "version" => 1 },
  68. { "folder_id" => "b846e02a-f41b-4199-860e-cde46cc25649",
  69. "parent_id" => "9846e02a-f41b-4199-860e-cde46cc25649",
  70. "name" => "test",
  71. "type_default" => 0,
  72. "version" => 1 }
  73. ]
  74. responseData["inventory-skel-lib"] = [
  75. { "folder_id" => "a846e02a-f41b-4199-860e-cde46cc25649",
  76. "parent_id" => "00000000-0000-0000-0000-000000000000",
  77. "name" => "Lib Inventory",
  78. "type_default" => 8,
  79. "version" => 1 }
  80. ]
  81. responseData["inventory-root"] = [ { "folder_id" => "9846e02a-f41b-4199-860e-cde46cc25649" } ]
  82. # responseData["event_notifications"] = [ ]
  83. responseData["gestures"] = [ ]
  84. # responseData["inventory-lib-owner"] =
  85. responseData["initial-outfit"] = [
  86. { "folder_name" => "Nightclub female", "gender" => "female" }
  87. ]
  88. responseData["seconds_since_epoch"] = Time.new.to_i
  89. responseData["start_location"] = "last";
  90. responseData["message"] = "Hello there!"
  91. responseData["circuit_code"] = zCircuitCode # random
  92. # responseData["look_at"] =
  93. responseData["agent_id"] = zAgentId
  94. responseData["home"] = "\{'region_handle':[r#{zRegionX*256}.0,r#{zRegionY*256}.0], 'position':[r128.0,r128.0,r30.0], 'look_at':[r0.0,r0.0,r0.0]\}"
  95. # responseData["home"] = "\{'region_handle':[r255232,r254976], 'position':[r128,r128,r100], 'look_at':[r128,r128,r100]\}"
  96. responseData["region_x"] = zRegionX*256
  97. responseData["region_y"] = zRegionY*256
  98. responseData["sim_ip"] = "192.168.1.103"
  99. responseData["sim_port"] = 9000
  100. # responseData["seed_capability"]
  101. responseData["agent_access"] = "M";
  102. responseData["session_id"] = zSessionId
  103. responseData["secure_session_id"] = zSecureSessionId
  104. responseData["login"] = "true"
  105. # raise XMLRPC::FaultException.new(1, "just some exception")
  106. responseData
  107. end
  108. s.set_default_handler do |name, *args|
  109. STDERR.print "Unknown method #{name}, #{args.inspect}\n\n"
  110. raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
  111. " or wrong number of parameters!")
  112. end
  113. httpserver = WEBrick::HTTPServer.new(:Port => 8002)
  114. httpserver.mount("/", s)
  115. httpserver.mount("/usersessions", SessionServlet);
  116. trap(:INT) { httpserver.shutdown }
  117. httpserver.start