Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
railgun-routing-server
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
Railgun
railgun-routing-server
Commits
04e5cac1
You need to sign in or sign up before continuing.
Commit
04e5cac1
authored
Dec 25, 2025
by
nanamicat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
e3f0c8fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
22 deletions
+19
-22
src/main.rs
src/main.rs
+9
-12
src/router.rs
src/router.rs
+10
-10
No files found.
src/main.rs
View file @
04e5cac1
...
...
@@ -2,9 +2,9 @@ use crate::api::create_app;
use
crate
::
data
::{
ConnectionData
,
RouterData
};
use
crate
::
protocol
::{
Change
,
Report
};
use
crate
::
router
::
Router
;
use
crate
::
settings
::{
INTERVAL
,
Settings
,
TIMEOUT
};
use
::
config
::
Config
;
use
crate
::
settings
::{
Settings
,
INTERVAL
,
TIMEOUT
};
use
anyhow
::
Result
;
use
::
config
::
Config
;
use
config
::
Environment
;
use
net
::
SocketAddr
;
use
serde
::
Serialize
;
...
...
@@ -96,21 +96,18 @@ async fn main() -> Result<()> {
now
=
interval
.tick
()
=>
{
let
mut
routers
=
routers
.write
()
.await
;
if
updating
.router_id
!=
0
{
let
router
=
routers
.get_mut
(
&
updating
.router_id
)
.expect
(
"updating router_id should exist"
);
if
now
.duration_since
(
router
.time
)
<
TIMEOUT
{
send
(
&
updating
.change
,
&
mut
buf
,
&
socket
,
&
router
.addr
.unwrap
())
.await
?
;
}
else
{
for
router
in
routers
.values_mut
()
{
if
router
.addr
!=
None
&&
now
.duration_since
(
router
.time
)
>
TIMEOUT
{
router
.offline
();
router
.finish
(
&
mut
updating
);
}
}
if
updating
.router_id
!=
0
{
let
router
=
routers
.get_mut
(
&
updating
.router_id
)
.expect
(
"updating router_id should exist"
);
send
(
&
updating
.change
,
&
mut
buf
,
&
socket
,
&
router
.addr
.unwrap
())
.await
?
;
}
if
updating
.router_id
==
0
{
for
router
in
routers
.values_mut
()
{
if
router
.addr
!=
None
&&
now
.duration_since
(
router
.time
)
>
TIMEOUT
{
router
.offline
();
}
}
tick
(
&
mut
routers
,
&
mut
cursor
,
&
socket
,
&
mut
buf
,
&
mut
updating
,
&
connections
)
.await
?
}
}
...
...
src/router.rs
View file @
04e5cac1
...
...
@@ -83,16 +83,7 @@ impl Router {
pub
fn
on_message
(
&
mut
self
,
data
:
Report
,
addr
:
SocketAddr
,
updating
:
&
mut
UpdatingState
)
->
Option
<
Change
>
{
// 不带 syn, 序号正确:已经在线的,或者是上线流程走完
// 有 syn:客户端新上线;无 addr, 服务端新上线新上线,先把客户端标记为离线来走登录流程
if
data
.syn
||
self
.addr
==
None
{
self
.offline
();
self
.finish
(
updating
);
Some
(
Change
{
seq
:
self
.seq
,
via
:
self
.via
.clone
(),
plan
:
self
.plan
.clone
(),
rst
:
true
,
})
}
else
if
data
.ack
==
self
.seq
.wrapping_add
(
1
)
{
if
!
data
.syn
&&
data
.ack
==
self
.seq
.wrapping_add
(
1
)
{
self
.online
(
addr
);
for
(
current
,
new
)
in
self
.peers
.values_mut
()
.zip
(
data
.peers
)
{
*
current
=
new
...
...
@@ -102,6 +93,15 @@ impl Router {
self
.finish
(
updating
);
}
None
}
else
if
data
.syn
||
self
.addr
==
None
{
self
.offline
();
self
.finish
(
updating
);
Some
(
Change
{
seq
:
self
.seq
,
via
:
self
.via
.clone
(),
plan
:
self
.plan
.clone
(),
rst
:
true
,
})
}
else
{
tracing
::
info!
(
"router {} wrong ack ack={}, seq={}"
,
self
.id
,
data
.ack
,
self
.seq
);
// 序号不对的,忽略
...
...
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