WebSocketProtocol.smali 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. .class public final Lokhttp3/internal/ws/WebSocketProtocol;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # static fields
  5. .field static final ACCEPT_MAGIC:Ljava/lang/String; = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
  6. .field static final B0_FLAG_FIN:I = 0x80
  7. .field static final B0_FLAG_RSV1:I = 0x40
  8. .field static final B0_FLAG_RSV2:I = 0x20
  9. .field static final B0_FLAG_RSV3:I = 0x10
  10. .field static final B0_MASK_OPCODE:I = 0xf
  11. .field static final B1_FLAG_MASK:I = 0x80
  12. .field static final B1_MASK_LENGTH:I = 0x7f
  13. .field static final CLOSE_ABNORMAL_TERMINATION:I = 0x3ee
  14. .field static final CLOSE_CLIENT_GOING_AWAY:I = 0x3e9
  15. .field static final CLOSE_MESSAGE_MAX:J = 0x7bL
  16. .field static final CLOSE_NO_STATUS_CODE:I = 0x3ed
  17. .field static final CLOSE_PROTOCOL_EXCEPTION:I = 0x3ea
  18. .field static final OPCODE_BINARY:I = 0x2
  19. .field static final OPCODE_CONTINUATION:I = 0x0
  20. .field static final OPCODE_CONTROL_CLOSE:I = 0x8
  21. .field static final OPCODE_CONTROL_PING:I = 0x9
  22. .field static final OPCODE_CONTROL_PONG:I = 0xa
  23. .field static final OPCODE_FLAG_CONTROL:I = 0x8
  24. .field static final OPCODE_TEXT:I = 0x1
  25. .field static final PAYLOAD_BYTE_MAX:J = 0x7dL
  26. .field static final PAYLOAD_LONG:I = 0x7f
  27. .field static final PAYLOAD_SHORT:I = 0x7e
  28. .field static final PAYLOAD_SHORT_MAX:J = 0xffffL
  29. # direct methods
  30. .method private constructor <init>()V
  31. .locals 2
  32. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  33. new-instance v0, Ljava/lang/AssertionError;
  34. const-string v1, "No instances."
  35. invoke-direct {v0, v1}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  36. throw v0
  37. .end method
  38. .method public static acceptHeader(Ljava/lang/String;)Ljava/lang/String;
  39. .locals 1
  40. new-instance v0, Ljava/lang/StringBuilder;
  41. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  42. invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  43. const-string p0, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
  44. invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  45. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  46. move-result-object p0
  47. invoke-static {p0}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
  48. move-result-object p0
  49. invoke-virtual {p0}, Lokio/ByteString;->sha1()Lokio/ByteString;
  50. move-result-object p0
  51. invoke-virtual {p0}, Lokio/ByteString;->base64()Ljava/lang/String;
  52. move-result-object p0
  53. return-object p0
  54. .end method
  55. .method static closeCodeExceptionMessage(I)Ljava/lang/String;
  56. .locals 2
  57. const/16 v0, 0x3e8
  58. if-lt p0, v0, :cond_4
  59. const/16 v0, 0x1388
  60. if-lt p0, v0, :cond_0
  61. goto :goto_1
  62. :cond_0
  63. const/16 v0, 0x3ec
  64. if-lt p0, v0, :cond_1
  65. const/16 v0, 0x3ee
  66. if-le p0, v0, :cond_2
  67. :cond_1
  68. const/16 v0, 0x3f4
  69. if-lt p0, v0, :cond_3
  70. const/16 v0, 0xbb7
  71. if-gt p0, v0, :cond_3
  72. :cond_2
  73. new-instance v0, Ljava/lang/StringBuilder;
  74. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  75. const-string v1, "Code "
  76. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  77. invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  78. const-string p0, " is reserved and may not be used."
  79. invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  80. :goto_0
  81. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  82. move-result-object p0
  83. return-object p0
  84. :cond_3
  85. const/4 p0, 0x0
  86. return-object p0
  87. :cond_4
  88. :goto_1
  89. new-instance v0, Ljava/lang/StringBuilder;
  90. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  91. const-string v1, "Code must be in range [1000,5000): "
  92. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  93. invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  94. goto :goto_0
  95. .end method
  96. .method static toggleMask([BJ[BJ)V
  97. .locals 5
  98. array-length v0, p3
  99. const/4 v1, 0x0
  100. :goto_0
  101. int-to-long v2, v1
  102. cmp-long v4, v2, p1
  103. if-gez v4, :cond_0
  104. int-to-long v2, v0
  105. rem-long v2, p4, v2
  106. long-to-int v3, v2
  107. aget-byte v2, p0, v1
  108. aget-byte v3, p3, v3
  109. xor-int/2addr v2, v3
  110. int-to-byte v2, v2
  111. aput-byte v2, p0, v1
  112. add-int/lit8 v1, v1, 0x1
  113. const-wide/16 v2, 0x1
  114. add-long/2addr p4, v2
  115. goto :goto_0
  116. :cond_0
  117. return-void
  118. .end method
  119. .method static validateCloseCode(I)V
  120. .locals 1
  121. invoke-static {p0}, Lokhttp3/internal/ws/WebSocketProtocol;->closeCodeExceptionMessage(I)Ljava/lang/String;
  122. move-result-object p0
  123. if-nez p0, :cond_0
  124. return-void
  125. :cond_0
  126. new-instance v0, Ljava/lang/IllegalArgumentException;
  127. invoke-direct {v0, p0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  128. throw v0
  129. .end method