Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
dd050152
Commit
dd050152
authored
Oct 31, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore ip resolver
parent
048fe647
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
9 deletions
+16
-9
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMProtocol.kt
...otlin/net.mamoe.mirai/network/protocol/tim/TIMProtocol.kt
+3
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotNetworkConfiguration.kt
...n/kotlin/net.mamoe.mirai/utils/BotNetworkConfiguration.kt
+4
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/PlatformUtils.kt
.../commonMain/kotlin/net.mamoe.mirai/utils/PlatformUtils.kt
+6
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/HexComparator.kt
...in/kotlin/net.mamoe.mirai/utils/internal/HexComparator.kt
+0
-0
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
.../jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
+1
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocketJvm.kt
...Main/kotlin/net/mamoe/mirai/utils/io/PlatformSocketJvm.kt
+2
-0
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMProtocol.kt
View file @
dd050152
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
package
net.mamoe.mirai.network.protocol.tim
package
net.mamoe.mirai.network.protocol.tim
import
net.mamoe.mirai.utils.solveIpAddress
object
TIMProtocol
{
object
TIMProtocol
{
val
SERVER_IP
:
List
<
String
>
=
{
val
SERVER_IP
:
List
<
String
>
=
{
//add("183.60.56.29")
//add("183.60.56.29")
...
@@ -14,7 +16,7 @@ object TIMProtocol {
...
@@ -14,7 +16,7 @@ object TIMProtocol {
"sz8.tencent.com"
,
"sz8.tencent.com"
,
"sz9.tencent.com"
,
"sz9.tencent.com"
,
"sz2.tencent.com"
"sz2.tencent.com"
).
forEach
{
list
.
add
(
it
)
}
).
forEach
{
list
.
add
(
solveIpAddress
(
it
))
}
// 需 IPv4 地址
list
.
toList
()
list
.
toList
()
}()
//不使用lazy, 在初始化时就加载.
}()
//不使用lazy, 在初始化时就加载.
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotNetworkConfiguration.kt
View file @
dd050152
...
@@ -4,32 +4,30 @@ import com.soywiz.klock.TimeSpan
...
@@ -4,32 +4,30 @@ import com.soywiz.klock.TimeSpan
import
com.soywiz.klock.seconds
import
com.soywiz.klock.seconds
import
net.mamoe.mirai.network.protocol.tim.packet.login.TouchResponsePacket
import
net.mamoe.mirai.network.protocol.tim.packet.login.TouchResponsePacket
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmOverloads
/**
/**
* 网络和连接配置
* 网络和连接配置
*/
*/
class
BotNetworkConfiguration
@JvmOverloads
constructor
(
class
BotNetworkConfiguration
{
/**
/**
* 等待 [TouchResponsePacket] 的时间
* 等待 [TouchResponsePacket] 的时间
*/
*/
var
touchTimeout
:
TimeSpan
=
2
.
seconds
,
var
touchTimeout
:
TimeSpan
=
2
.
seconds
/**
/**
* 是否使用随机的设备名.
* 是否使用随机的设备名.
* 使用随机可以降低被封禁的风险, 但可能导致每次登录都需要输入验证码
* 使用随机可以降低被封禁的风险, 但可能导致每次登录都需要输入验证码
* 当一台设备只登录少量账号时, 将此项设置为 `true` 可能更好.
* 当一台设备只登录少量账号时, 将此项设置为 `true` 可能更好.
*/
*/
var
randomDeviceName
:
Boolean
=
false
,
var
randomDeviceName
:
Boolean
=
false
/**
/**
* 心跳周期. 过长会导致被服务器断开连接.
* 心跳周期. 过长会导致被服务器断开连接.
*/
*/
var
heartbeatPeriod
:
TimeSpan
=
60
.
seconds
,
var
heartbeatPeriod
:
TimeSpan
=
60
.
seconds
/**
/**
* 每次心跳时等待结果的时间.
* 每次心跳时等待结果的时间.
* 一旦心跳超时, 整个网络服务将会重启 (将消耗约 1s). 除正在进行的任务 (如图片上传) 会被中断外, 事件和插件均不受影响.
* 一旦心跳超时, 整个网络服务将会重启 (将消耗约 1s). 除正在进行的任务 (如图片上传) 会被中断外, 事件和插件均不受影响.
*/
*/
var
heartbeatTimeout
:
TimeSpan
=
2
.
seconds
var
heartbeatTimeout
:
TimeSpan
=
2
.
seconds
)
{
companion
object
{
companion
object
{
/**
/**
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/PlatformUtils.kt
View file @
dd050152
...
@@ -30,6 +30,11 @@ expect fun crc32(key: ByteArray): Int
...
@@ -30,6 +30,11 @@ expect fun crc32(key: ByteArray): Int
*/
*/
expect
fun
md5
(
byteArray
:
ByteArray
):
ByteArray
expect
fun
md5
(
byteArray
:
ByteArray
):
ByteArray
/**
* hostname 解析 ipv4
*/
expect
fun
solveIpAddress
(
hostname
:
String
):
String
/**
/**
* Localhost 解析
* Localhost 解析
*/
*/
...
@@ -42,4 +47,4 @@ internal expect val httpClient: HttpClient
...
@@ -42,4 +47,4 @@ internal expect val httpClient: HttpClient
// FIXME: 2019/10/28 这个方法不是很好的实现
// FIXME: 2019/10/28 这个方法不是很好的实现
internal
expect
fun
HttpRequestBuilder
.
configureBody
(
inputSize
:
Long
,
input
:
Input
)
internal
expect
fun
HttpRequestBuilder
.
configureBody
(
inputSize
:
Long
,
input
:
Input
)
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/i
o
/HexComparator.kt
→
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/i
nternal
/HexComparator.kt
View file @
dd050152
File moved
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
View file @
dd050152
...
@@ -51,7 +51,7 @@ fun DataInput.md5(): ByteArray {
...
@@ -51,7 +51,7 @@ fun DataInput.md5(): ByteArray {
return
digest
.
digest
()
return
digest
.
digest
()
}
}
//
actual fun solveIpAddress(hostname: String): String = InetAddress.getByName(hostname).hostAddress
actual
fun
solveIpAddress
(
hostname
:
String
):
String
=
InetAddress
.
getByName
(
hostname
).
hostAddress
actual
fun
localIpAddress
():
String
=
InetAddress
.
getLocalHost
().
hostAddress
actual
fun
localIpAddress
():
String
=
InetAddress
.
getLocalHost
().
hostAddress
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocketJvm.kt
View file @
dd050152
...
@@ -17,6 +17,8 @@ actual class PlatformDatagramChannel actual constructor(serverHost: String, serv
...
@@ -17,6 +17,8 @@ actual class PlatformDatagramChannel actual constructor(serverHost: String, serv
actual
suspend
fun
read
(
buffer
:
IoBuffer
)
=
withContext
(
Dispatchers
.
IO
)
{
actual
suspend
fun
read
(
buffer
:
IoBuffer
)
=
withContext
(
Dispatchers
.
IO
)
{
try
{
try
{
(
channel
as
ReadableByteChannel
).
read
(
buffer
)
(
channel
as
ReadableByteChannel
).
read
(
buffer
)
}
catch
(
e
:
ClosedChannelException
)
{
throw
e
}
catch
(
e
:
Throwable
)
{
}
catch
(
e
:
Throwable
)
{
throw
ReadPacketInternalException
(
e
)
throw
ReadPacketInternalException
(
e
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment