Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tun
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
tun
Commits
70f6dc3a
Commit
70f6dc3a
authored
Aug 01, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ext
parent
9f7e5412
Pipeline
#39789
passed with stages
in 1 minute and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/main.rs
src/main.rs
+8
-8
No files found.
src/main.rs
View file @
70f6dc3a
...
...
@@ -11,8 +11,8 @@ use std::sync::Arc;
#[repr(C)]
pub
struct
Meta
{
pub
src_id
:
u
8
,
pub
dst_id
:
u
8
,
pub
src_id
:
u
16
,
pub
dst_id
:
u
16
,
pub
reversed
:
u16
,
}
...
...
@@ -20,7 +20,7 @@ use serde::Deserialize;
#[derive(Deserialize)]
pub
struct
ConfigRouter
{
pub
remote_id
:
u
8
,
pub
remote_id
:
u
16
,
pub
proto
:
i32
,
pub
family
:
u8
,
pub
mark
:
u32
,
...
...
@@ -32,7 +32,7 @@ pub struct ConfigRouter {
#[derive(Deserialize)]
pub
struct
Config
{
pub
local_id
:
u
8
,
pub
local_id
:
u
16
,
pub
local_secret
:
String
,
pub
routers
:
Vec
<
ConfigRouter
>
,
}
...
...
@@ -45,14 +45,14 @@ fn main() -> Result<(), Box<dyn Error>> {
let
config
:
Config
=
serde_json
::
from_str
(
env
::
args
()
.nth
(
1
)
.ok_or
(
"need param"
)
?
.as_str
())
?
;
let
local_secret
:
[
u8
;
SECRET_LENGTH
]
=
Router
::
create_secret
(
config
.local_secret
.as_str
())
?
;
let
mut
sockets
:
HashMap
<
u16
,
Arc
<
Socket
>>
=
HashMap
::
new
();
let
routers
:
HashMap
<
u
8
,
Router
>
=
config
let
routers
:
HashMap
<
u
16
,
Router
>
=
config
.routers
.iter
()
.map
(|
c
|
Router
::
new
(
c
,
&
mut
sockets
)
.map
(|
router
|
(
c
.remote_id
,
router
)))
.collect
::
<
Result
<
_
,
_
>>
()
?
;
let
(
mut
router_readers
,
router_writers
):
(
HashMap
<
u
8
,
RouterReader
>
,
HashMap
<
u
8
,
RouterWriter
>
,
HashMap
<
u
16
,
RouterReader
>
,
HashMap
<
u
16
,
RouterWriter
>
,
)
=
routers
.into_iter
()
.map
(|(
id
,
router
)|
{
...
...
@@ -60,7 +60,7 @@ fn main() -> Result<(), Box<dyn Error>> {
((
id
,
reader
),
(
id
,
writer
))
})
.unzip
();
let
router_writers3
:
Vec
<
(
Arc
<
Socket
>
,
HashMap
<
u
8
,
RouterWriter
>
)
>
=
router_writers
let
router_writers3
:
Vec
<
(
Arc
<
Socket
>
,
HashMap
<
u
16
,
RouterWriter
>
)
>
=
router_writers
.into_iter
()
.grouping_by
(|(
_
,
v
)|
v
.key
())
.into_iter
()
...
...
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