Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
railgun-routing-client
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-client
Commits
7013baf0
Commit
7013baf0
authored
Jan 07, 2026
by
nanamicat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean
parent
6928eebe
Pipeline
#42457
passed with stages
in 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
22 deletions
+28
-22
src/main.rs
src/main.rs
+14
-14
src/router.rs
src/router.rs
+14
-8
No files found.
src/main.rs
View file @
7013baf0
use
crate
::
connection
::
Connection
;
use
crate
::
data
::
Router
as
RouterData
;
use
crate
::
protocol
::{
Hello
,
MessageType
,
Uplink
};
use
crate
::
router
::
Router
;
use
crate
::
server
::
Server
;
use
crate
::
settings
::{
Settings
,
INTERVAL
,
WINDOW
};
use
config
::
Config
;
use
std
::
collections
::
BTreeMap
;
use
std
::
fs
;
use
std
::
time
::
SystemTime
;
use
tokio
::
net
::
UdpSocket
;
use
tokio
::
time
;
mod
connection
;
mod
connection
;
mod
data
;
mod
data
;
mod
gateway_group
;
mod
gateway_group
;
...
@@ -19,8 +6,21 @@ mod router;
...
@@ -19,8 +6,21 @@ mod router;
mod
server
;
mod
server
;
mod
settings
;
mod
settings
;
use
crate
::{
connection
::
Connection
,
data
::
Router
as
RouterData
,
protocol
::{
Hello
,
MessageType
,
Uplink
},
router
::
Router
,
server
::
Server
,
settings
::{
Settings
,
INTERVAL
,
WINDOW
},
};
use
config
::
Config
;
use
hickory_resolver
::
Resolver
;
use
hickory_resolver
::
Resolver
;
use
tokio
::
time
::
Instant
;
use
std
::{
collections
::
BTreeMap
,
fs
,
time
::
SystemTime
};
use
tokio
::{
net
::
UdpSocket
,
time
::{
self
,
Instant
},
};
#[tokio::main]
#[tokio::main]
async
fn
main
()
->
anyhow
::
Result
<
()
>
{
async
fn
main
()
->
anyhow
::
Result
<
()
>
{
...
...
src/router.rs
View file @
7013baf0
use
crate
::
data
::
Router
as
RouterData
;
use
crate
::{
use
crate
::
protocol
::{
Hello
,
PeerQuality
};
data
::
Router
as
RouterData
,
use
crate
::
settings
::{
INTERVAL
,
Settings
,
WINDOW
};
protocol
::{
Hello
,
PeerQuality
},
settings
::{
Settings
,
INTERVAL
,
WINDOW
},
};
use
saturating_cast
::
SaturatingCast
;
use
saturating_cast
::
SaturatingCast
;
use
std
::
collections
::
BTreeMap
;
use
std
::{
use
std
::
net
::{
IpAddr
,
Ipv4Addr
,
SocketAddr
};
collections
::
BTreeMap
,
use
std
::
time
::
SystemTime
;
net
::{
IpAddr
,
Ipv4Addr
,
SocketAddr
},
time
::
SystemTime
,
};
use
tokio
::
time
::
Instant
;
use
tokio
::
time
::
Instant
;
pub
struct
Router
{
pub
struct
Router
{
...
@@ -48,16 +52,18 @@ impl Router {
...
@@ -48,16 +52,18 @@ impl Router {
const
WINDOW_MIN
:
i32
=
1
-
WINDOW_MAX
;
const
WINDOW_MIN
:
i32
=
1
-
WINDOW_MAX
;
match
delta
{
match
delta
{
WINDOW_MIN
..
0
=>
{
WINDOW_MIN
..
0
=>
{
// 旧报文,可能是乱序
self
.receive
|
=
1
<<
(
-
delta
);
self
.receive
|
=
1
<<
(
-
delta
);
return
;
return
;
}
}
0
=>
return
,
0
..
WINDOW_MAX
=>
{
1
..
WINDOW_MAX
=>
{
// 0 可能是重启
self
.receive
=
(
self
.receive
<<
delta
)
|
1
;
self
.receive
=
(
self
.receive
<<
delta
)
|
1
;
self
.remote_time
=
data
.time
;
self
.remote_time
=
data
.time
;
self
.local_time
=
Instant
::
now
();
self
.local_time
=
Instant
::
now
();
}
}
_
=>
{
_
=>
{
// 可能是下线很久之后上线,也可能是别的异常情况,先承认这个报文,但是不计算丢包和延迟
self
.remote_time
=
data
.time
;
self
.remote_time
=
data
.time
;
self
.local_time
=
Instant
::
now
();
self
.local_time
=
Instant
::
now
();
return
;
return
;
...
...
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