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
18326b58
Commit
18326b58
authored
Dec 25, 2025
by
nanamicat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
5f4d9da0
Pipeline
#42144
passed with stages
in 3 minutes and 25 seconds
Changes
2
Pipelines
1
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 @
18326b58
...
@@ -2,9 +2,9 @@ use crate::api::create_app;
...
@@ -2,9 +2,9 @@ use crate::api::create_app;
use
crate
::
data
::{
ConnectionData
,
RouterData
};
use
crate
::
data
::{
ConnectionData
,
RouterData
};
use
crate
::
protocol
::{
Change
,
Report
};
use
crate
::
protocol
::{
Change
,
Report
};
use
crate
::
router
::
Router
;
use
crate
::
router
::
Router
;
use
crate
::
settings
::{
INTERVAL
,
Settings
,
TIMEOUT
};
use
crate
::
settings
::{
Settings
,
INTERVAL
,
TIMEOUT
};
use
::
config
::
Config
;
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
::
config
::
Config
;
use
config
::
Environment
;
use
config
::
Environment
;
use
net
::
SocketAddr
;
use
net
::
SocketAddr
;
use
serde
::
Serialize
;
use
serde
::
Serialize
;
...
@@ -96,21 +96,18 @@ async fn main() -> Result<()> {
...
@@ -96,21 +96,18 @@ async fn main() -> Result<()> {
now
=
interval
.tick
()
=>
{
now
=
interval
.tick
()
=>
{
let
mut
routers
=
routers
.write
()
.await
;
let
mut
routers
=
routers
.write
()
.await
;
if
updating
.router_id
!=
0
{
for
router
in
routers
.values_mut
()
{
let
router
=
routers
.get_mut
(
&
updating
.router_id
)
.expect
(
"updating router_id should exist"
);
if
router
.addr
!=
None
&&
now
.duration_since
(
router
.time
)
>
TIMEOUT
{
if
now
.duration_since
(
router
.time
)
<
TIMEOUT
{
send
(
&
updating
.change
,
&
mut
buf
,
&
socket
,
&
router
.addr
.unwrap
())
.await
?
;
}
else
{
router
.offline
();
router
.offline
();
router
.finish
(
&
mut
updating
);
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
{
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
?
tick
(
&
mut
routers
,
&
mut
cursor
,
&
socket
,
&
mut
buf
,
&
mut
updating
,
&
connections
)
.await
?
}
}
}
}
...
...
src/router.rs
View file @
18326b58
...
@@ -83,16 +83,7 @@ impl Router {
...
@@ -83,16 +83,7 @@ impl Router {
pub
fn
on_message
(
&
mut
self
,
data
:
Report
,
addr
:
SocketAddr
,
updating
:
&
mut
UpdatingState
)
->
Option
<
Change
>
{
pub
fn
on_message
(
&
mut
self
,
data
:
Report
,
addr
:
SocketAddr
,
updating
:
&
mut
UpdatingState
)
->
Option
<
Change
>
{
// 不带 syn, 序号正确:已经在线的,或者是上线流程走完
// 不带 syn, 序号正确:已经在线的,或者是上线流程走完
// 有 syn:客户端新上线;无 addr, 服务端新上线新上线,先把客户端标记为离线来走登录流程
// 有 syn:客户端新上线;无 addr, 服务端新上线新上线,先把客户端标记为离线来走登录流程
if
data
.syn
||
self
.addr
==
None
{
if
!
data
.syn
&&
data
.ack
==
self
.seq
.wrapping_add
(
1
)
{
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
)
{
self
.online
(
addr
);
self
.online
(
addr
);
for
(
current
,
new
)
in
self
.peers
.values_mut
()
.zip
(
data
.peers
)
{
for
(
current
,
new
)
in
self
.peers
.values_mut
()
.zip
(
data
.peers
)
{
*
current
=
new
*
current
=
new
...
@@ -102,6 +93,15 @@ impl Router {
...
@@ -102,6 +93,15 @@ impl Router {
self
.finish
(
updating
);
self
.finish
(
updating
);
}
}
None
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
{
}
else
{
tracing
::
info!
(
"router {} wrong ack ack={}, seq={}"
,
self
.id
,
data
.ack
,
self
.seq
);
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