Commit Graph

2898 Commits

Author SHA1 Message Date
Him188
d114d0a2e6 Optimize BotInitProcessor and add tests 2021-07-02 00:39:10 +08:00
Him188
b78c276aef ChunkedFlowSession: Ensure channel is closed on completion 2021-07-02 00:39:10 +08:00
Him188
fa9d236949 Avoid using TopLevel logger in tests 2021-07-02 00:39:10 +08:00
Him188
f379a617fd NetworkHandlerSupport: catch all exceptions in coroutine scope and direct it to network logger 2021-07-02 00:39:10 +08:00
Him188
6012f33574 Add selector logging, helps #1361 2021-07-02 00:39:10 +08:00
Him188
4d3a9e7cc5 Add SynchronizedStdoutLogger for tests 2021-07-01 11:06:58 +08:00
Him188
0d339c7303 Remove redundant suspension in BotOfflineEventMonitorImpl 2021-06-30 23:01:42 +08:00
Him188
e10155a7b3 AbstractKeepAliveNetworkHandlerSelector do not yield() but check for cancellation manually. 2021-06-30 23:01:22 +08:00
Him188
c4d129542f Unwrap CancellationException on JobAttachStateObserver.stateChanged0 2021-06-29 23:10:06 +08:00
Him188
f1bb7c566f Add generic type to SelectorNetworkHandler, improve test framework:
- Make `AbstractRealNetworkHandlerTest` sealed with subtypes;
  - `AbstractNettyNHTest`
  - `AbstractNettyNHTestWithSelector`
- Set `mirai.event.launch.undispatched` to `true` for network tests
- Use real `BotOfflineEventMonitor` in tests with selector
2021-06-29 22:47:56 +08:00
sandtechnology
2ce549e56f
Fix #1322, remove redundant cookie (#1372)
* Fix #1322, removed useless parms

* Add missed perms

* Remove redundant cookie
2021-06-28 19:19:18 +08:00
Karlatemp
eb5c7414d7
Add hashCode and equals for Image, close #1302 2021-06-26 16:29:40 +08:00
Karlatemp
f7170f2052
Delete unused internal AbstractImage 2021-06-26 16:17:53 +08:00
Karlatemp
ae54a5fb41
Private voice support (#1310)
* Support voice for private messaging

* typo

* Add extension functions for `uploadAsVoice`; Update KDocs

* Update KDoc

* Update error message

* Fix `C2CPttStoreBDH` error

* Deprecated `ExternalResource.uploadAsVoice(Contact): Voice`

* Update mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt

* apiDump

Co-authored-by: Him188 <Him188@mamoe.net>
2021-06-26 10:02:23 +08:00
sandtechnology
d349c19c2e
StatSvc.SimpleGet: Decode the resp (#1241)
* StatSvc.SimpleGet: Decode the resp

* Close network on `StatSvc.SimpleGet.Response.Error`

* Use new `IncomingPacket`

Co-authored-by: Him188 <Him188@mamoe.net>
2021-06-25 20:29:28 +08:00
Him188
ce4373a322 Use Either for IncomingPacket.result 2021-06-25 20:11:41 +08:00
Him188
11ffb324c9 Add Either 2021-06-25 20:05:28 +08:00
Him188
b02fa15b33 Broadcast BotReloginEvent stably 2021-06-24 01:04:39 +08:00
Noire
b8de3f77ff
GroupAnnoucement (#1141)
* Add more comment about GroupAnnouncement.kt

* Edit comment about GroupAnnouncement.kt
Provide experimental api

* Api Dump

* After review

* Change to interface and API dump

* More change

* More change

* More more change

* Some change

* api dump

* Fix name

* Redesign Announcement public api

* Edit comment about GroupAnnouncement.kt
Provide experimental api

* After review

* Change to interface and API dump

* More change

* Modify to extension fun

* Fix sendAnnouncement and change place

* Change Group.deleteAnnouncement to group companion

* fix publish

* Api dump

* Reformat code

* Add `@since 2.7`

* Fix build

Co-authored-by: Him188 <Him188@mamoe.net>
2021-06-24 00:59:53 +08:00
Him188
a8dbd761eb Use start=UNDISPATCHED in launchRecovery 2021-06-24 00:42:57 +08:00
Him188
47f1ae8134 Enable tests NettyHandlerEventTest #1311 2021-06-23 15:44:52 +08:00
Him188
2e47740b1b Move setState from coroutine scope completion handler to network.close, fix #1311 2021-06-23 15:44:52 +08:00
Him188
8d4eb45386 Rearrange functions in NettyNetworkHandler 2021-06-23 15:44:52 +08:00
sandtechnology
636584cdd1
ECDH: Replacing old curve, thanks to MiraiGo (#1237)
* ECDH: Replacing old curve, thanks to MiraiGo

* Move ecdhWithPublicKey to EcdhInitialPublicKeyUpdater

* Making ECDHInitialPublicKey internal

* Remove useless log

* Improve message

Co-authored-by: Him188 <Him188@mamoe.net>

Co-authored-by: Him188 <Him188@mamoe.net>
2021-06-23 14:59:12 +08:00
sandtechnology
ad7f95d0f0
Fix #1192, request admin when loading groups (#1257)
* Fix #1192, request admin when loading groups

* Improve message

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>
2021-06-23 14:58:56 +08:00
Karlatemp
509be910c0
Avoid resource leak 2021-06-22 18:14:29 +08:00
Karlatemp
d1fdddf9e6
Break network when received LoginFailedException; fix #1352 2021-06-22 13:37:54 +08:00
Him188
f2ca8e1eff Revert "Fix kt compiler errors (#1159)"
This reverts commit b227f719
2021-06-19 23:58:27 +08:00
Him188
c37457cafb Cleanup and move local serializable classes to top-level 2021-06-19 18:28:21 +08:00
Him188
813ef2b1e6 Remove redundant tests 2021-06-19 17:41:32 +08:00
Him188
b4b25be626 Simplify setState 2021-06-19 17:16:07 +08:00
Him188
f229757395 Redesign BotInitProcessor to adjust force offline adjacently after login 2021-06-19 15:20:49 +08:00
Him188
3cc0973edd Revert "Add PacketInterceptor"
This reverts commit 04656d7a
2021-06-19 14:52:26 +08:00
Him188
d654e95f0f Revert "Fix fast login"
This reverts commit 77e5e91f
2021-06-19 14:52:23 +08:00
Karlatemp
77e5e91fc4
Fix fast login 2021-06-19 02:30:06 +08:00
Karlatemp
04656d7a03
Add PacketInterceptor 2021-06-19 02:28:16 +08:00
Karlatemp
e816755414
Fix state switching when switching to CLOSED 2021-06-19 02:26:47 +08:00
Karlatemp
627e9baa6f
Fix NettyNetworkHandler debug message 2021-06-19 02:25:38 +08:00
Karlatemp
8b5b76e32e
Run BaseStateImpl.setState with lock 2021-06-19 02:24:59 +08:00
Him188
b33d1edf03 Add SingleEntrantLock 2021-06-19 00:29:54 +08:00
Him188
833c9d2c97 Do not turn state into Connecting in handlePipelineException 2021-06-19 00:06:14 +08:00
Him188
faed38da9e Do not set state to CLOSED multiple times on close 2021-06-19 00:06:14 +08:00
Him188
99d232efe8 Remove redundant synchronization in NetworkHandlerSupport.setState 2021-06-19 00:05:50 +08:00
Him188
eba6706b47 Allow to change whether LoggingStateObserver is enabled in runtime 2021-06-19 00:04:39 +08:00
Him188
997c3ea2cf Remove SsoProcessor.createObserverChain 2021-06-19 00:04:32 +08:00
Him188
b8b8cb1fad Make LoggingStateObserver into use 2021-06-19 00:04:24 +08:00
Him188
44bfe3dbb6 Make NetworkHandlerFactory fun interface 2021-06-19 00:04:22 +08:00
Him188
c6d9825cf6 Add name to StateObverse 2021-06-19 00:04:20 +08:00
Him188
fbf7142eaf Improve performance of StateObserver.chainOfNotNull 2021-06-19 00:04:10 +08:00
Him188
f1d58c4953 Fix CombinedStateObserver.beforeStateChanged 2021-06-19 00:04:05 +08:00
Him188
951f3b2bc4 Reduce CombinedStateObserver hierarchy: use List 2021-06-19 00:03:45 +08:00
sandtechnology
48f9ca0d48
Fix #1334, update pb and fix private image upload issue (#1335)
* Fix #1334, update pb and fix private image upload issue

* Keeping consistent in annotation

* Restore old comment

* Let extendinfo default to null
2021-06-19 00:00:16 +08:00
Him188
4d10338815 Do not add BotOfflineEventMonitor in SetStateTest 2021-06-17 00:20:41 +08:00
Him188
5efced6167 Move RECONNECT_DELAY to AbstractKeepAliveNetworkHandlerSelector and set it to 0 in tests 2021-06-16 19:49:17 +08:00
Him188
cde13062d9 Ensure network closed on initialization failure 2021-06-16 19:42:58 +08:00
Him188
fc477e0122 Do not wrap exception into ISE on reaching max attempts 2021-06-16 17:26:57 +08:00
Him188
a38f24cbe5 Redesign connection maintenance mechanism:
Reconnection is directed by `BotOfflineEvent`.

### Event Broadcasting

- PacketFactory `MessageSvcPushForceOffline` closes network with `ForceOfflineException`.
 - `network.close(cause)` pass the cause to state observer from `QQAndroidBot.stateObserverChain`, the observer broadcasts as follows:
   - Nothing if `cause` is `ForceOfflineException` or `BotClosedByEvent`(which is broadcast by user)
   - `BotOfflineEvent.Dropped` if cause is NetworkException and is recoverable(which is from Netty handlers)
   - `BotOfflineEvent.Force` if cause is `ForceOfflineException` is from the factory mentioned above.
   - `BotOfflineEvent.Active` otherwise(any other unexpected exceptions considered as an error)

### Deciding whether to reconnect

User can listen and change `BotOfflineEvent.reconnect` to decide. Default values are determined by `BotConfiguration`.

### Event listening

- Component `BotOfflineEventMonitor` listens `BotOfflineEvent`, logs the event for users, and launches a coroutine to do `network.resumeConnection` to notify the selector to renew an instance.
- `BotOnlineWatchdog` in `SelectorNetworkHandler` is removed.
- Selector now handles `maxAttempts` correctly in such a way that `awaitResumeInstance` does not throw exception until maximum attempts reached.
- On every attempt, new exceptions are logged to provide debugging information, and further duplications are ignored.
2021-06-16 16:58:20 +08:00
Him188
45ba713f73 Optimize HeartbeatFailedException.toString: show information of its cause 2021-06-16 03:09:21 +08:00
Him188
ab7c49a0d5 Remove log in BotClientHolderImpl 2021-06-16 03:06:54 +08:00
Him188
b219ba986e Review network ComponentStorage framework and improve connection logics, support reconnection on force offline (closes #1330, close #1331), and on bad network.
- Remove `FactoryKeepAliveNetworkHandlerSelector` and add `KeepAliveNetworkHandlerSelector`;
- Review the storage of `QQAndroidBotClient`, extract it as a `BotClientHolder`;
- Introduce bot-level components that lasts with the lifecycle of `Bot`, and network-level components accordingly;
- Dynamically re-create the context given to `NetworkHandler` in selector, to use network-level components, including `BotClientHolder`, that allows a simple reinitialization of `BotClient`;
- Handles the situation when physical network broken on logging in, giving a hint to user and halts the log-in process and transfer the responsibility of reconnecting to selector;
- Send logout only in `Bot.close` (manual close).
2021-06-16 03:00:50 +08:00
Him188
e65593b2af Add BeforeStateChangedObserver 2021-06-16 02:37:06 +08:00
Him188
23c1a67479 Add naming notes for StatSvc.Register in logging 2021-06-16 02:29:05 +08:00
Him188
ad4f7a6232 Show OutgoingPacket.displayName in logging 2021-06-16 02:28:51 +08:00
Him188
24ac4ffa95 Add ConcurrentComponentStorage builder 2021-06-16 01:52:42 +08:00
Him188
e6119e6301 Throw NoSuchComponentException with full details in CombinedComponentStorage.get 2021-06-16 01:52:27 +08:00
Him188
9933fab4c5 Add ComponentStorage?.withPrimary 2021-06-16 01:51:50 +08:00
Him188
f4ec905aff Make CombinedStateObserver.toString more readable 2021-06-16 01:51:26 +08:00
Him188
750ab0db37 Fix StackOverflowError on calling bot.client in tests with TestSsoProcessor, fix #1332 2021-06-15 20:47:50 +08:00
Him188
bebb786b9a Fix build 2021-06-13 11:10:12 +08:00
Him188
c9f98e46d7 Implement heartbeat periods and timeouts correctly, #1255 2021-06-13 10:59:11 +08:00
Him188
43b13d158f Implement HeartbeatStrategy, #1226 2021-06-13 10:50:55 +08:00
Karlatemp
e9d9d56489
Avoid network congestion 2021-06-11 21:19:35 +08:00
Karlatemp
05a8419fb7
Fix internal error in uploading private images; fix #1317 2021-06-10 22:49:24 +08:00
Him188
1e2ab736c2 Use bot.closeAndJoin() in tests 2021-06-08 17:13:37 +08:00
Him188
81258488cb Check isActive in BotOnlineWatchdog 2021-06-08 17:13:25 +08:00
Him188
300882ea18 Redesign ComponentStorage initialization for clearer tests 2021-06-08 17:13:15 +08:00
Him188
f9da72c136 Convert DEFAULT_BLACKLIST to function and initialize the immutable set only once 2021-06-08 16:16:01 +08:00
Him188
65a3ffc147 Rename ComponentScope.plus to .withFallback 2021-06-08 16:14:23 +08:00
Him188
c8def70594 Add bot.job as parent of NetworkHandlerSupport 2021-06-08 16:14:23 +08:00
Him188
5f7f350eb5 Close PacketDecodePipeline.channel on scope closure 2021-06-08 16:14:23 +08:00
Him188
038be54444 Remote pcap4j from jvmTest 2021-06-08 16:14:23 +08:00
Him188
19bc781854 Add kotlinx-coroutines-debug to jvmTest 2021-06-08 16:14:23 +08:00
Him188
ad3bd4cc0d Stop BotOnlineWatchdog if bot is closed 2021-06-08 12:19:05 +08:00
Him188
54a78313c8 Improve logging on exceptions and correctly handle CancellationException when Bot.close is invoked. 2021-06-08 12:18:40 +08:00
Him188
3e8fc8e1ec Do not pass failed IncomingPacket to PacketFactorys 2021-06-08 12:16:26 +08:00
Him188
725b502d9e Add notes for blacklist 2021-06-08 12:04:54 +08:00
Him188
a53f97cb6f Add OnlinePush.ReqPush to blacklist 2021-06-08 12:00:35 +08:00
Him188
56165c82aa Fix ignored friend message event logging, fix #1312 2021-06-08 12:00:20 +08:00
Him188
091906577a Add StatSvc.SimpleGet to DEFAULT_BLACKLIST 2021-06-08 11:25:36 +08:00
Him188
8312a5bc98 Temporarily disable NettyHandlerEventTest to make build success #1311 2021-06-07 22:03:12 +08:00
Him188
e0f9c311f2 Temporarily disable tests BotOffline from OK TO CLOSED and BotOfflineEvent after successful reconnection to make build success #1311 2021-06-07 22:00:22 +08:00
Him188
684b844b44 Move implementation of EventDispatcher.joinBroadcast to tests and mark it @TestOnly 2021-06-07 18:46:40 +08:00
Him188
9619338d5b Catch and forward event broadcasting to EventDispatcher 2021-06-07 18:18:07 +08:00
Him188
9cf45bd9ca Ignore MessageSvc.PushNotify in logging 2021-06-07 18:14:24 +08:00
Him188
271759b4c6 Fix ignorance of MultiPacket using blacklist 2021-06-07 18:14:10 +08:00
Him188
84fb928764 Add check for arguments of NetworkHandlerSupport.sendAndExpect 2021-06-07 17:47:40 +08:00
Him188
5ebd65e78d Change setStateImpl in the ordering:
1. Update current state
2. Close old state
3. Notify observer
4. Notify selector
2021-06-07 17:05:34 +08:00
Him188
02c9fd2fb0 Add SetStateTest 2021-06-07 13:36:27 +08:00
Him188
02681428c9 Review and migrate deprecated calls 2021-06-07 12:57:01 +08:00
Him188
b5db147985 Remove debugConf 2021-06-07 12:57:00 +08:00
Him188
e9c53eb5db Always close netty connection if StateLoading completed with an exception 2021-06-06 16:56:19 +08:00
Him188
91b5a5da58 Disable mirai.debug.network.state.observer.logging in tests 2021-06-06 16:35:56 +08:00
Him188
679e61e4d0 Use collectThrow instead of throw in SsoProcessor.SlowLoginImpl.login 2021-06-06 16:34:35 +08:00
Him188
756c805460 Fix typo 2021-06-06 16:21:50 +08:00
Him188
e7521028d1 Fix tests 2021-06-06 13:58:46 +08:00
Him188
dadff42718 Unwrap NetworkException on logon failure 2021-06-06 13:58:46 +08:00
Him188
7739c4db80 Close network in MessageSvcPushForceOffline properly by throwing ServerClosedException 2021-06-06 13:58:46 +08:00
Him188
0d28772275 Do not listen BotOfflineEvent to close network 2021-06-06 13:58:45 +08:00
Him188
137e1a1235 Fix network scopes and exception handling. Support recovering after system hibernation and network failure. 2021-06-05 16:05:41 +08:00
Him188
e788aa09f7 Add awaitStateChange 2021-06-05 16:05:41 +08:00
Him188
c6075ec299 Refine state observer for events 2021-06-05 16:05:41 +08:00
Him188
061023bc4d Rearrange NetworkHandlerSupport 2021-06-05 16:05:41 +08:00
Him188
8ae2e04f02 Improve implementation docs 2021-06-05 16:05:41 +08:00
Him188
083a3a1e00 Prefer value class 2021-06-05 16:05:41 +08:00
Him188
b7527a1b56 Extract HeartbeatScheduler and add HeartbeatFailedException and NetworkException 2021-06-05 16:05:41 +08:00
Him188
9f466c882e Improve syncMessageSvc:
- do not suspend logon and postpone suspension until sending message
- add MessageSvcSyncer

Fix #1253
2021-06-02 17:24:46 +08:00
Him188
4fd1b25838 Close network in-place in BotOfflineEventMonitorImpl.onEvent on BotOfflineEvent.Active 2021-05-31 17:05:20 +08:00
Him188
0c0c9d5dc2 Replace stateChanged with stateChannel for better performance and easier testing;
Add tests for `sendPacketImpl`;
2021-05-31 15:58:44 +08:00
Him188
00e2d2b77f Support refreshing instance in NetworkHandlerSelector 2021-05-31 15:03:12 +08:00
Him188
8c0f245da1 Simplify awaitState 2021-05-31 13:39:21 +08:00
Him188
db98862712 Initialize classes before tests 2021-05-31 13:38:21 +08:00
Him188
bdd390e774 Unify logging in ContactCacheService 2021-05-31 13:38:04 +08:00
Him188
9dfb46d704 Make tests faster 2021-05-31 01:46:02 +08:00
Him188
266d73f8a1 Improve SelectorNetworkHandler lifecycle: do not tolerant any exception thrown by states 2021-05-31 01:33:00 +08:00
Him188
0505dc41fa Stop SelectorNetworkHandler after manual close 2021-05-31 01:12:08 +08:00
Him188
e0c0a189dc Make NettyUtilsTest faster 2021-05-31 00:31:54 +08:00
Him188
ff6c63fafc EventDispatcher: launch Jobs UNDISPATCHED-ly 2021-05-31 00:15:02 +08:00
Karlatemp
76eaa34917 Fix tests
tests

Fix StateObserver error
2021-05-31 00:15:02 +08:00
Karlatemp
6f8d15ed37 Add test timeout 2021-05-31 00:15:02 +08:00
Karlatemp
7e94eb66d4 Fix StackOverflowError 2021-05-31 00:15:02 +08:00
Him188
b5f47d5f91 Fix network:
- fix `awaitState`
- improve `EventDispatcher`
- use `EventDispatcher` in components
- use  `eventDispatcher.joinBroadcast()` in tests to remove delays and make tests stable
2021-05-31 00:15:01 +08:00
Him188
c93d6aa608 Add ForwardRefineTest 2021-05-30 22:51:26 +08:00
Him188
301deadbd1 Add test for #1273 2021-05-30 21:16:43 +08:00
Him188
bcdff1336b
Kotlin 1.5 and dependencies updates (#1246)
* Kotlin 1.5 and dependencies updates

* Update mirai-console ref

* Use Kotlin 1.5.10

* 2.7-M1-dev-3

* Update console ref
2021-05-27 14:39:13 +08:00
Him188
5e25c0e25b Remove bintray 2021-05-25 12:25:53 +08:00
Him188
3584ca1e71 Improve performance of CombinedComponentStorage.size 2021-05-24 13:21:38 +08:00
Him188
e769130829 Improve ComponentStorage.plus: accept nullable arguments 2021-05-11 09:01:12 +08:00
Him188
1d2b2377cf Add ConcurrentComponentStorage.creationStacktrace 2021-05-10 13:13:58 +08:00
Him188
f7f4ccf4f5 Correct state transition logic:
- Linear lifecycle for NetworkHandler: no chance to change state back to previous ones
- No reconnection attempts in NetworkHandler but in NHSelector
- Ensure clashing checks performed in setState
- Print closure exception in TestNettyNH.setStateOK
2021-05-09 21:05:32 +08:00
Him188
d43a77b590 Update docs and improve source code readability 2021-05-09 15:31:50 +08:00
Him188
6bc5c1204e Use withExceptionCollector in sendAndExpect 2021-05-09 13:12:34 +08:00
Him188
c9a3bb23ee Minor improvements after rebase 2021-05-09 00:54:48 +08:00
Him188
e60dd20d7b Add AbstractNettyNHTest.setSsoProcessor 2021-05-09 00:54:48 +08:00
Him188
0584b44823 Fix imports 2021-05-09 00:54:48 +08:00
Karlatemp
b31ef37c8d Exception Handling; Normal login tests 2021-05-09 00:54:48 +08:00
Him188
d2f600f9bb Fix docs 2021-05-09 00:54:48 +08:00
Him188
e58db121dc Remove redundant properties 2021-05-09 00:54:48 +08:00
Karlatemp
361304b9f2 Fix NPE in StateConnecting 2021-05-09 00:54:48 +08:00
Him188
b53e546743 Prototype EventDispatcher 2021-05-09 00:54:48 +08:00
Him188
5d3130448c Add NHSupport.setState safe overload and fix tests 2021-05-09 00:54:48 +08:00
Him188
1bb1b18f98 Improve logging in components
- Fix duplicated event logs
- Specify logger name for AccountSecretsManager
- Fix OtherClientUpdater logger
- Unify ServerList logger
- SubLogger.isEnabled
2021-05-09 00:54:48 +08:00
Him188
060004644e Add writeAndFlushOrCloseAsync to handle exception on send properly 2021-05-09 00:54:48 +08:00
Him188
a77b52e7d3 Add bot argument to PushReqResponse and filter in ConfigPushProcessorImpl 2021-05-09 00:54:48 +08:00
Him188
d14ed0cecd Dispatch events in Bot scope 2021-05-09 00:54:48 +08:00
Him188
b62e39b4d1 Set state to CLOSED on failure during connecting 2021-05-09 00:54:48 +08:00
Him188
f684b148d3 Remove notes that was for rewrite 2021-05-09 00:54:48 +08:00
Him188
61bc657417 Extract some logic out of QQAndroidBot 2021-05-09 00:54:48 +08:00
Him188
35884182af Fix and improve event logging 2021-05-09 00:54:48 +08:00
Him188
d73f5a2692 Review BotConfiguration and implement relevant configs, implement alive heartbeat, fix behavior on resume 2021-05-09 00:54:48 +08:00
Him188
6e06406a3a Support network selector retry 2021-05-09 00:54:48 +08:00
Him188
83a81961ca Properly suspend coroutine is not available for send 2021-05-09 00:54:48 +08:00
Him188
eb80a4836b Remove all unstable kotlin.Duration usages 2021-05-09 00:54:48 +08:00
Him188
a7a4879d05 Improve logging 2021-05-09 00:54:48 +08:00
Him188
5fa54114c1 Fix sso and event logging 2021-05-09 00:54:48 +08:00
Him188
971685a2b0 Fix state resume 2021-05-09 00:54:48 +08:00
Him188
95d634233c Close bot if first login failed 2021-05-09 00:54:48 +08:00
Him188
35a6d12dde Test: network scope closed on bot close 2021-05-09 00:54:48 +08:00
Him188
062492c546 Test: NettyEndlessReconnectionTest 2021-05-09 00:54:48 +08:00
Him188
e584bc8ee8 Test: state tests 2021-05-09 00:54:48 +08:00
Him188
8db8e2fb03 Implement lifecycle management for network 2021-05-09 00:54:48 +08:00
Him188
f9ddf74d8e Extract sync logic 2021-05-09 00:54:48 +08:00
Him188
076cd4997d BotOfflineEventMonitor 2021-05-09 00:54:48 +08:00
Him188
3806d7ce78 fix componentName and smartToString 2021-05-09 00:54:48 +08:00
Him188
c35c2c97c8 CombinedStorageTest 2021-05-09 00:54:48 +08:00
Him188
b91bbfd2b8 Add NetworkHandlerFactory and tests for NetworkHandler 2021-05-09 00:54:48 +08:00
Him188
4f77abca87 Components misc implementations including (ABI changes):
- ComponentStorage and its impls
- ContactCacheService
- ContactUpdater
- HeartbeatProcessor
- SsoProcessor
- QQABot
2021-05-09 00:54:48 +08:00
Him188
7f2f1e9759 Rearrange network tests 2021-05-09 00:54:48 +08:00
Him188
9286d2124e Add utils for tests 2021-05-09 00:54:48 +08:00
Him188
035085cf45 Remove state CONNECTION_LOST 2021-05-09 00:54:48 +08:00
Him188
84fa460b32 BotOnlineEvent, BotReloginEvent, BotOfflineEvent 2021-05-09 00:54:48 +08:00
Him188
d70475b8ba Do not resume state while it is already closed 2021-05-09 00:54:48 +08:00
Him188
0e1b9da5e4 Fix test KeepAliveNetworkHandlerSelectorTest 2021-05-09 00:54:48 +08:00
Him188
79112bc98d Fix LongMessageInternal missing parameter (due to merge) 2021-05-09 00:54:48 +08:00
Him188
35b80dc700 Processors 2021-05-09 00:54:48 +08:00
Him188
dd1b7404ea IDEA removed my import 2021-05-09 00:54:48 +08:00
Him188
9db3a5ef4f Rearrange packages for component system 2021-05-09 00:54:48 +08:00
Him188
0443fe4576 Prefer generified outgoing packets in all factories 2021-05-09 00:54:48 +08:00
Him188
82ad953b2b Continuing implement states for NetworkHandler 2021-05-09 00:54:48 +08:00
Him188
03e12eb287 fix build 2021-05-09 00:54:48 +08:00
Him188
9ac0a8715c Integrate ServerList into component system 2021-05-09 00:54:48 +08:00
Him188
3ec8a94096 ContactUpdater and ContactCacheService 2021-05-09 00:54:48 +08:00
Him188
51c1450202 ComponentStorage 2021-05-09 00:54:48 +08:00
Him188
05b2bfe059 Rearrange packages 2021-05-09 00:54:48 +08:00
Him188
70551167ba States and connection impl 2021-05-09 00:54:48 +08:00
Him188
1fef89cf1c Add state observer 2021-05-09 00:54:48 +08:00
Him188
8786f12d5d Add NetworkHandler.isOk to avoid state == OK 2021-05-09 00:54:48 +08:00
Him188
4446479e80 Make QQAndroidClient lighter 2021-05-09 00:54:48 +08:00
Him188
f2b236341a Decouple SSO login processor 2021-05-09 00:54:48 +08:00
Him188
997ad1eb63 Rearrange QQAndroidBot 2021-05-09 00:54:48 +08:00
Him188
1d053bd1bd Extract netty utils 2021-05-09 00:54:48 +08:00
Him188
90f5e27b5f Add AbstractKeepAliveNetworkHandlerSelectorTest 2021-05-09 00:54:48 +08:00
Him188
382c351e08 Implement NetworkHandlerSelector, serverList, and implement them into Bot 2021-05-09 00:54:48 +08:00
Him188
ff80434d2d Migrate network logger and old sendWithoutExpect and sendAndExpect 2021-05-09 00:54:48 +08:00
Him188
840dd19dd0 Move EMPTY_BYTE_ARRAY to mirai-core-utils 2021-05-09 00:54:48 +08:00
Him188
097a478999 Relocates netty files to correct packages 2021-05-09 00:54:48 +08:00
Karlatemp
5f0b432220 NettyTestUnit 2021-05-09 00:54:48 +08:00
Him188
e293195391 Set state to StateClosed appropriately and update docs 2021-05-09 00:54:48 +08:00
Him188
a143340141 Buildscript: Fix test artifacts included in main sourceset 2021-05-09 00:54:48 +08:00
Him188
d01f71ff8b Remove rubbish; fix build; add todos 2021-05-09 00:54:48 +08:00
Him188
b844efb072 New network: framework infrastructure 2021-05-09 00:54:48 +08:00
sandtechnology
028bfa483c
Introduce MemberNick class and correct nameCard decoding, Fix #1151 (#1231)
* Introduce MemberNick class and correct nameCard decoding, Fix #1151

* Update comment for better understanding

Co-authored-by: Him188 <Him188@mamoe.net>

* Change var name in method for better understanding

Co-authored-by: Him188 <Him188@mamoe.net>

* Fix build

Co-authored-by: Him188 <Him188@mamoe.net>
2021-05-06 17:54:52 +08:00
sandtechnology
e459c76f92
OnlinePush.SidTicketExpired: Refresh token and register online (#1242)
* OnlinePush.SidTicketExpired: Refresh token and register online

* Also update key map

* Update package name to internal

Co-authored-by: Him188 <Him188@mamoe.net>

* Fix build

Co-authored-by: Him188 <Him188@mamoe.net>
2021-05-05 00:26:10 +08:00
Him188
6854252c77 Old network: re-init client on BotOfflineEvent.Force. #1205 for 2.7-M1 2021-05-04 12:47:27 +08:00
Him188
84d444843d Old network: delete account secrets on BotOfflineEvent.Force. #1205 for 2.7-M1 2021-05-04 12:47:22 +08:00
Him188
57eb716e31
Add inline BotFactory.newBot for Kotlin DSL. fix #1233 (#1234) 2021-05-02 13:51:32 +08:00
sandtechnology
0baaf9d587
Correct the seq logic, fix #1094 (#1232) 2021-05-02 13:51:21 +08:00
sandtechnology
db4c41f84a
Rework seq system (#1230)
* Rework seq system, should help #1209

* Use non-blocking (CAS) implement

* Making next seq code more clear for reading

* Fix mistake
2021-05-02 13:50:24 +08:00
Him188
70dc0a4da6
Remove kotlin.time.Duration usages (#1215)
* Remove kotlin.Duration usages

* Fix build

* update submodule console ref
2021-04-27 11:49:30 +08:00
sandtechnology
4e070baf34
Fix duplicate register packet (#1214) 2021-04-25 11:37:12 +08:00
Karlatemp
d3dc756a50
Drop empty UnsupportedMessage; fix #1210 2021-04-24 10:18:06 +08:00
Him188
5dcccd1402 Introduce base class for tests AbstractTest 2021-04-20 12:47:57 +08:00
Him188
6d58fb5514 Ensure fast login succeed, fix #1199 2021-04-18 14:37:16 +08:00
Karlatemp
28a8b8303a
Support receive nested ForwardMessages (#1196)
* Support receive nested ForwardMessages

* Tests
2021-04-17 16:09:32 +08:00
Karlatemp
0c93aeb425
Add RefineContext for refining (#1195)
* Add RefineContext for refining

* Add RefineContext argument

* Fix build
2021-04-17 11:45:02 +08:00
Karlatemp
83fa78b50d
Find nick from source; fix #1137 2021-04-17 09:28:11 +08:00
Hoshino Tented
1bf1e3686f
添加管理员修改功能 (#1178)
* add modifyAdmin

* 修复赋予相同权限时不会抛错并且仍然广播事件的 bug

* fix test failed

* fix test failed AGAIN

* fix myself

* 是这样吗

* i am so sorry :(

* fix fixed bug
2021-04-16 08:33:07 +08:00
Him188
f3d3130f2d Support login cache and login without password. close #1158 2021-04-10 18:46:39 +08:00
Karlatemp
509c0d3d06
Fix mute all not working; Fix #1181 2021-04-09 19:19:03 +08:00
Him188
8d3a4fbf5b
Deprecate RemoteFile.moveTo(String) for ambiguous behavior (#1180) 2021-04-09 18:33:12 +08:00
Him188
ce95d8fdce Fix RemoteFile.resolveById, fix #1177 2021-04-09 07:47:51 +08:00
Him188
d4ee81c79a Fix potential memory leak with struct ByteReadPacket 2021-04-08 22:42:24 +08:00
Him188
951ddc3138 Declare type explicitly for IDE inference issue 2021-04-08 18:07:21 +08:00
Him188
45c6adf956 Declare type explicitly for IDE inference issue 2021-04-08 13:15:24 +08:00
Him188
344c54531d Declare type explicitly for IDE inference issue 2021-04-08 13:13:23 +08:00
Him188
7be14f809c Fix build warnings 2021-04-08 12:44:58 +08:00
Him188
7feeaee1ca
Refining Messages without suspension (#1167)
* Introduce `RefinableMessage.tryRefine` to refine without suspension.

* Extract `RefinableMessage` to separate file

* Always use `Bot` on `List<MsgComm.Msg>.toMessageChain`

* Introduce `MessageRefiner` and ensure MessageChain refined after transformation. Fix #1156, fix #1157

* Add basic tests

* Refine forward message contents

* Refine long message contents

* Move refinement from message internals to MiraiImpl public APIs

* Comment out unused `toMessageChainOffline`

* refinement tests part

* refinement tests part

* Full tests and minor internal improv.s

* Fix tests

* Fix compile
2021-04-08 11:59:16 +08:00
Hoshino Tented
a085ab26c8
fix #1155 (#1170)
* fix #1155

* fix unmute

* add durationSeconds check for mute

* fix stupid code

* fix me
2021-04-07 17:34:45 +08:00
sandtechnology
5d1395a78c
Fix key refresh failed when refresh again and update dumped data (#1169)
* Fix key refresh failed when logged with fast login

* Update dumped data and remove outdated t511 list

* Fix key refresh again

* Fix naming and support multi bot case

* Remove useless code

* Fix key refresh again, remove useless default value (ksid)
2021-04-07 12:12:13 +08:00
Him188
bb5c85965a Simple test: MockBot 2021-04-07 00:59:08 +08:00
Karlatemp
b227f719a2
Fix kt compiler errors (#1159)
* Fix kt compiler errors

* Revert "Fix compiler bug, fix #1136"

This reverts commit 39f6c168

* Fix log style

Co-authored-by: Him188 <Him188@mamoe.net>
2021-04-05 22:41:26 +08:00
AdoptOSS
21e8852e0f
buildscript: fix task not found errors when android sdk not available (#1161)
* buildscript: fix task not found errors when android sdk not available

* fix: this shadowed by run

* cleanup: code style

* improve: avoid breaking index map
2021-04-05 22:35:38 +08:00
Him188
7521e6d17f
Rename RichMessageOrigin to MessageOrigin (#1116)
* Rename `RichMessageOrigin` to `MessageOrigin`

* apiDump

* Change `MessageOrigin.origin` parameter type from `RichMessage` to `SingleMessage`;
Rename `RichMessageKind` to `MessageOriginKind`

* Make MessageOriginKind serializable and update docs

* Ensure binary compatibility with <2.6 and provide migration helpers

* apiDump
2021-04-04 00:31:33 +08:00
Him188
39f6c1680c Fix compiler bug, fix #1136 2021-04-04 00:00:32 +08:00
Him188
caf9eb06ad Fix package name of StrangerImpl 2021-04-03 23:17:00 +08:00
Him188
50e60cc4fe Use system property mirai.unknown.image.type.logging to enable logging on unknown image type, helps #1111 2021-04-03 23:07:41 +08:00
Him188
cccdb3cdf2
Update docs for messages (#1142)
* Update docs for messages

* Update docs for messages

* Update docs for messages

* Update docs for messages

* Update docs/Messages.md

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>

* Update mirai-core-api/src/commonMain/kotlin/message/data/Message.kt

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>

* Update docs for messages

* Update docs for messages

* Revert inappropriate changes

* Fix doc

Co-authored-by: Karlatemp <karlatemp@vip.qq.com>
2021-04-03 22:39:55 +08:00
Him188
ea1f43b9c5
Fast login (#1154)
* wtlogin10

* Fast login Packet Implement (#1125)

* Correct group syncing logic again, Fix #1120

* Implement fast login packet, thanks to MiraiGo

* Delete duplicated tlv

* Refresh Token when exchanging and solve connection dropping issue (#1128)

* Correct group syncing logic again, Fix #1120

* Implement fast login packet, thanks to MiraiGo

* Delete duplicated tlv

* Schedule token exchanging every 10 minutes, solve connection dropping issue

* Refresh Token when exchanging, and correct token expire time

* Remove useless params for doFastLogin

* Fix missed register and tgt update (#1131)

* Correct group syncing logic again, Fix #1120

* Implement fast login packet, thanks to MiraiGo

* Delete duplicated tlv

* Schedule token exchanging every 10 minutes, solve connection dropping issue

* Refresh Token when exchanging, and correct token expire time

* Remove useless params for doFastLogin

* Fix missed register and tgt update

* Add login lock

* Add login lock

* Remove key refresh

* Remove heartbeat period override

* Login: Update tlv and solve constant connection dropping issue (#1150)

* Correct group syncing logic again, Fix #1120

* Implement fast login packet, thanks to MiraiGo

* Delete duplicated tlv

* Schedule token exchanging every 10 minutes, solve connection dropping issue

* Refresh Token when exchanging, and correct token expire time

* Remove useless params for doFastLogin

* Fix missed register and tgt update

* Update tlv, add tlv11d and tlv11a decoding

* Add stat heartbeat, solve constant connection dropping issue

* Update apidump for new configuration

* Add comment for statHeartbeatPeriodMillis

* Change old naming

* Add since version

Co-authored-by: Him188 <Him188@mamoe.net>

Co-authored-by: sandtechnology <20417547+sandtechnology@users.noreply.github.com>
2021-04-03 22:31:14 +08:00
Karlatemp
f6fd4de14b
Postpone error reporting in parsing in NewContact (#1147)
* Add `ParseErrorPacket` for postpone error report

* Continue to parse even if an error occurs
2021-04-03 22:17:49 +08:00
Karlatemp
6e914f6941
Fix forward display (#1148) 2021-04-03 22:12:14 +08:00
Him188
3f807353b3 Remove UNSUPPORTED_MERGED_MESSAGE_PLAIN, fix #1119 2021-03-30 12:16:08 +08:00