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
bd81c826
Commit
bd81c826
authored
Jan 11, 2026
by
nanamicat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
0da5fc8b
Pipeline
#42521
passed with stages
in 12 minutes and 8 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
src/router.rs
src/router.rs
+3
-10
src/shared/gateway_group.rs
src/shared/gateway_group.rs
+14
-0
No files found.
src/router.rs
View file @
bd81c826
use
crate
::
quality
::
Quality
;
use
crate
::
quality
::
Quality
;
use
crate
::
settings
::{
HALF_LIFE
,
PENALTY
,
PENALTY_MIN
};
use
crate
::
settings
::{
HALF_LIFE
,
PENALTY
,
PENALTY_MIN
};
use
crate
::
shared
::{
use
crate
::
shared
::{
data
::{
DATABASE
,
GatewayGroupID
,
GatewayID
,
RegionID
,
RouterID
},
data
::{
self
,
DATABASE
,
GatewayGroupID
,
GatewayID
,
RegionID
,
RouterID
},
protocol
::{
Downlink
,
MessageType
,
PeerQuality
,
Uplink
},
protocol
::{
Downlink
,
MessageType
,
PeerQuality
,
Uplink
},
};
};
use
crate
::{
UpdatingState
,
shared
};
use
crate
::{
UpdatingState
,
shared
};
...
@@ -73,13 +73,6 @@ impl Router {
...
@@ -73,13 +73,6 @@ impl Router {
self
.addr
.is_some
()
self
.addr
.is_some
()
}
}
pub
fn
apply
(
&
mut
self
,
via
:
&
mut
BTreeMap
<
RouterID
,
RouterID
>
,
plan
:
&
mut
BTreeMap
<
RegionID
,
BTreeMap
<
GatewayGroupID
,
GatewayID
>>
)
{
self
.via
.append
(
via
);
for
(
region
,
mut
plan
)
in
std
::
mem
::
take
(
plan
)
{
self
.plan
.entry
(
region
)
.or_default
()
.append
(
&
mut
plan
);
}
}
pub
fn
on_message
(
&
mut
self
,
uplink
:
&
mut
Uplink
,
addr
:
SocketAddr
,
updating
:
&
mut
UpdatingState
,
now
:
Instant
)
->
Option
<
Downlink
>
{
pub
fn
on_message
(
&
mut
self
,
uplink
:
&
mut
Uplink
,
addr
:
SocketAddr
,
updating
:
&
mut
UpdatingState
,
now
:
Instant
)
->
Option
<
Downlink
>
{
if
uplink
.peers
.len
()
==
self
.peers
.len
()
{
if
uplink
.peers
.len
()
==
self
.peers
.len
()
{
for
(
current
,
new
)
in
self
.peers
.values_mut
()
.zip
(
&
mut
uplink
.peers
)
{
for
(
current
,
new
)
in
self
.peers
.values_mut
()
.zip
(
&
mut
uplink
.peers
)
{
...
@@ -102,7 +95,7 @@ impl Router {
...
@@ -102,7 +95,7 @@ impl Router {
for
(
to
,
via
)
in
self
.via
.iter_mut
()
{
for
(
to
,
via
)
in
self
.via
.iter_mut
()
{
*
via
=
*
to
;
*
via
=
*
to
;
}
}
self
.apply
(
&
mut
uplink
.via
,
&
mut
uplink
.plan
);
data
::
GatewayGroup
::
apply
(
&
mut
self
.via
,
&
mut
uplink
.via
,
&
mut
self
.plan
,
&
mut
uplink
.plan
);
self
.online
(
addr
,
now
);
self
.online
(
addr
,
now
);
}
}
None
None
...
@@ -112,7 +105,7 @@ impl Router {
...
@@ -112,7 +105,7 @@ impl Router {
self
.online
(
addr
,
now
);
self
.online
(
addr
,
now
);
if
updating
.router_id
==
self
.id
{
if
updating
.router_id
==
self
.id
{
updating
.router_id
=
Default
::
default
();
updating
.router_id
=
Default
::
default
();
self
.apply
(
&
mut
updating
.message.via
,
&
mut
updating
.message.plan
);
data
::
GatewayGroup
::
apply
(
&
mut
self
.via
,
&
mut
updating
.message.via
,
&
mut
self
.plan
,
&
mut
updating
.message.plan
);
self
.last_update
=
now
;
self
.last_update
=
now
;
}
}
None
None
...
...
src/shared/gateway_group.rs
View file @
bd81c826
...
@@ -47,6 +47,20 @@ impl GatewayGroup {
...
@@ -47,6 +47,20 @@ impl GatewayGroup {
.collect
()
.collect
()
}
}
pub
fn
apply
(
self_via
:
&
mut
BTreeMap
<
RouterID
,
RouterID
>
,
new_via
:
&
mut
BTreeMap
<
RouterID
,
RouterID
>
,
self_plan
:
&
mut
BTreeMap
<
RegionID
,
BTreeMap
<
GatewayGroupID
,
GatewayID
>>
,
new_plan
:
&
mut
BTreeMap
<
RegionID
,
BTreeMap
<
GatewayGroupID
,
GatewayID
>>
,
)
{
self_via
.append
(
new_via
);
for
(
region
,
inner
)
in
new_plan
{
if
let
Some
(
p
)
=
self_plan
.get_mut
(
region
)
{
p
.append
(
inner
);
}
}
}
fn
guess
(
id
:
RouterID
,
gw
:
&
data
::
Gateway
,
region
:
usize
)
->
i32
{
fn
guess
(
id
:
RouterID
,
gw
:
&
data
::
Gateway
,
region
:
usize
)
->
i32
{
gw
.metrics
[
region
]
.saturating_add
(
gw
.cost_outbound
)
.saturating_add
(
if
gw
.router
==
id
{
0
}
else
{
100
})
gw
.metrics
[
region
]
.saturating_add
(
gw
.cost_outbound
)
.saturating_add
(
if
gw
.router
==
id
{
0
}
else
{
100
})
}
}
...
...
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