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
1f73ae2b
Commit
1f73ae2b
authored
Dec 20, 2025
by
nanamicat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BTreeMap
parent
dc2030f9
Pipeline
#42038
failed with stages
in 2 minutes and 13 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
122 deletions
+92
-122
src/main.rs
src/main.rs
+7
-10
src/router.rs
src/router.rs
+85
-112
No files found.
src/main.rs
View file @
1f73ae2b
...
...
@@ -2,7 +2,7 @@ mod config;
mod
router
;
use
crate
::
config
::{
Config
,
Schema
};
use
crate
::
router
::
{
Meta
,
Router
,
META_SIZE
}
;
use
crate
::
router
::
Router
;
use
anyhow
::{
Context
,
Result
};
use
crossbeam
::
epoch
::{
pin
,
Owned
};
use
crossbeam_utils
::
thread
;
...
...
@@ -11,7 +11,7 @@ use std::collections::BTreeMap;
use
std
::
net
::
Shutdown
;
use
std
::
sync
::
atomic
::
Ordering
;
use
std
::
time
::
Duration
;
use
std
::
{
env
,
mem
::
MaybeUninit
}
;
use
std
::
env
;
fn
main
()
->
Result
<
()
>
{
println!
(
"Starting"
);
...
...
@@ -75,16 +75,13 @@ fn main() -> Result<()> {
let
(
connection
,
_
)
=
socket
.accept
()
.unwrap
();
s
.spawn
(
move
|
_
|
{
connection
.set_tcp_nodelay
(
true
)
.unwrap
();
let
mut
meta_bytes
=
[
MaybeUninit
::
uninit
();
META_SIZE
];
let
mut
meta_bytes
=
[
0u8
;
2
];
Router
::
recv_exact_tcp
(
&
connection
,
&
mut
meta_bytes
)
.unwrap
();
let
meta
:
&
Meta
=
Meta
::
from_bytes
(
&
meta_bytes
)
;
if
meta
.reversed
==
0
&&
let
Some
(
router
)
=
routers
.get
(
&
meta
.
src_id
)
&&
meta
.
dst_id
==
router
.config.local_id
let
src_id
=
meta_bytes
[
0
]
;
let
dst_id
=
meta_bytes
[
1
];
if
let
Some
(
router
)
=
routers
.get
(
&
src_id
)
&&
dst_id
==
router
.config.local_id
{
// let connection = Arc::new(connection);
// tcp listener 只许一个连接,过来新连接就把前一个关掉。
{
let
guard
=
pin
();
...
...
src/router.rs
View file @
1f73ae2b
This diff is collapsed.
Click to expand it.
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