Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
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
sheteng
com.ccwangluo.accelerator
Commits
72201d5f
Commit
72201d5f
authored
Aug 05, 2021
by
chenhuaqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed configuration without token
parent
51f9f415
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
29 deletions
+38
-29
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/config.rs
...shadowsocks-rust/crates/shadowsocks-service/src/config.rs
+2
-2
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/server.rs
...s-rust/crates/shadowsocks-service/src/local/dns/server.rs
+1
-0
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs
...rust/crates/shadowsocks-service/src/local/dns/upstream.rs
+4
-1
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/mod.rs
...dowsocks-rust/crates/shadowsocks-service/src/local/mod.rs
+19
-22
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs
...owsocks-service/src/local/socks/server/socks5/tcprelay.rs
+1
-1
core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs
...s-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs
+6
-0
core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs
...tes/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs
+2
-2
core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/crypto_io.rs
...s-rust/crates/shadowsocks/src/relay/udprelay/crypto_io.rs
+3
-1
No files found.
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/config.rs
View file @
72201d5f
...
...
@@ -1220,8 +1220,8 @@ impl Config {
nsvr
.set_timeout
(
timeout
);
}
if
method
.is_none
()
{
nsvr
.set_token
(
config
.token
.expect
(
"token"
)
);
if
let
Some
(
token
)
=
config
.token
{
nsvr
.set_token
(
token
);
nsvr
.set_retry_limit
(
config
.retry_limit
.expect
(
"retry_limit"
));
nsvr
.set_auth_timeout
(
config
.auth_timeout
.expect
(
"auth_timeout"
));
nsvr
.set_beats_interval
(
config
.beats_interval
.expect
(
"beats_interval"
));
...
...
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/server.rs
View file @
72201d5f
...
...
@@ -503,6 +503,7 @@ impl DnsClient {
message
=
result
;
message
.set_id
(
request
.id
());
}
else
{
error!
(
"acl_lookup error {:?}"
,
r
);
message
.set_response_code
(
ResponseCode
::
ServFail
);
}
}
...
...
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs
View file @
72201d5f
...
...
@@ -79,10 +79,12 @@ impl DnsClient {
connect_opts
:
&
ConnectOpts
,
flow_stat
:
Arc
<
FlowStat
>
,
)
->
io
::
Result
<
DnsClient
>
{
let
stream
=
ProxyClientStream
::
connect_with_opts_map
(
context
,
svr_cfg
,
ns
,
connect_opts
,
|
s
|
{
let
auth_context
=
context
.auth_context
()
.clone
();
let
mut
stream
=
ProxyClientStream
::
connect_with_opts_map
(
context
,
svr_cfg
,
ns
,
connect_opts
,
|
s
|
{
MonProxyStream
::
from_stream
(
s
,
flow_stat
)
})
.await
?
;
stream
.write_buf
(
&
mut
auth_context
.get_token
()
.as_bytes
())
.await
?
;
Ok
(
DnsClient
::
TcpRemote
{
stream
})
}
...
...
@@ -135,6 +137,7 @@ impl DnsClient {
DnsClient
::
UnixStream
{
ref
mut
stream
}
=>
stream_query
(
stream
,
msg
)
.await
,
DnsClient
::
TcpRemote
{
ref
mut
stream
}
=>
stream_query
(
stream
,
msg
)
.await
,
DnsClient
::
UdpRemote
{
ref
mut
socket
,
ref
ns
}
=>
{
trace!
(
"send dns query to remote server {}"
,
ns
);
let
bytes
=
msg
.to_vec
()
?
;
socket
.send
(
ns
,
&
bytes
)
.await
?
;
...
...
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/mod.rs
View file @
72201d5f
...
...
@@ -117,13 +117,6 @@ pub async fn run(mut config: Config) -> io::Result<()> {
assert
!
(
!
config
.local
.is_empty
(),
"no valid local server configuration"
);
if
let
Some
(
svr_cfg
)
=
config
.server
.first
()
{
context
.context_ref
()
.auth_context
()
.update_token
(
svr_cfg
.token
()
.expect
(
"token"
));
}
let
context
=
Arc
::
new
(
context
);
let
vfut
=
FuturesUnordered
::
new
();
...
...
@@ -157,22 +150,26 @@ pub async fn run(mut config: Config) -> io::Result<()> {
if
let
Some
(
watched_config
)
=
config
.watched_config
{
for
server
in
&
config
.server
{
// Start monitor for token based server
if
let
Some
(
auth_stream
)
=
authenticate_server
(
&
server
,
context
.clone
())
.await
?
{
if
let
Some
(
token
)
=
server
.token
()
{
context
.context_ref
()
.auth_context
()
.update_token
(
token
);
// Start monitor for token based server
if
let
Some
(
auth_stream
)
=
authenticate_server
(
&
server
,
context
.clone
())
.await
?
{
vfut
.push
(
create_auth_stream_monitor
(
auth_stream
,
server
.retry_limit
(),
server
.auth_timeout
(),
server
.beats_interval
(),
)
.boxed
(),
);
}
vfut
.push
(
create_auth_stream_monitor
(
auth_stream
,
server
.retry_limit
(),
server
.auth_timeout
(),
server
.beats_interval
(),
)
.boxed
(),
config_notify_update_token
(
watched_config
.clone
(),
context
.context_ref
()
.auth_context
())
.boxed
(),
);
}
vfut
.push
(
config_notify_update_token
(
watched_config
.clone
(),
context
.context_ref
()
.auth_context
())
.boxed
(),
);
}
}
...
...
@@ -379,7 +376,7 @@ async fn authenticate_server(
use
tokio
::
time
;
// connect to remote server
if
svr_cfg
.
method
()
.is_non
e
()
{
if
svr_cfg
.
token
()
.is_som
e
()
{
let
context
=
svr_context
.clone
()
.context
();
debug!
(
"connect to {}"
,
svr_cfg
.addr
());
let
mut
auth_stream
=
OutboundTcpStream
::
connect_server_with_opts
(
...
...
@@ -446,7 +443,7 @@ async fn create_auth_stream_monitor(
debug!
(
"prepare send packet to remote server"
);
while
retry_count
>
0
{
let
mut
req_buf
=
BytesMut
::
with_capacity
(
1
);
req_buf
.put_
i32
(
1
);
req_buf
.put_
u8
(
1
);
match
time
::
timeout
(
auth_timeout
,
stream
.write_buf
(
&
mut
req_buf
.freeze
()))
.await
{
Ok
(
res
)
=>
{
if
let
Err
(
err
)
=
res
{
...
...
core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs
View file @
72201d5f
...
...
@@ -160,7 +160,7 @@ impl Socks5TcpHandler {
}
};
if
svr_cfg
.
method
()
.is_non
e
()
{
if
svr_cfg
.
token
()
.is_som
e
()
{
let
token
=
self
.context
.context_ref
()
.auth_context
()
.get_token
();
trace!
(
"stream send token {} to remote server"
,
token
);
remote
.write_buf
(
&
mut
token
.as_bytes
())
.await
?
;
...
...
core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs
View file @
72201d5f
...
...
@@ -228,6 +228,12 @@ where
self
.enc
.poll_write_encrypted
(
cx
,
&
mut
self
.stream
,
buf
)
}
/// Attempt to write data to `stream`
#[inline]
pub
fn
poll_write
(
&
mut
self
,
cx
:
&
mut
task
::
Context
<
'_
>
,
buf
:
&
[
u8
])
->
Poll
<
io
::
Result
<
usize
>>
{
Pin
::
new
(
&
mut
self
.stream
)
.poll_write
(
cx
,
buf
)
}
/// Polls `flush` on the underlying stream
#[inline]
pub
fn
poll_flush
(
&
mut
self
,
cx
:
&
mut
task
::
Context
<
'_
>
)
->
Poll
<
io
::
Result
<
()
>>
{
...
...
core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs
View file @
72201d5f
...
...
@@ -184,9 +184,9 @@ where
fn
poll_write
(
self
:
Pin
<&
mut
Self
>
,
cx
:
&
mut
task
::
Context
<
'_
>
,
buf
:
&
[
u8
])
->
Poll
<
Result
<
usize
,
io
::
Error
>>
{
let
mut
this
=
self
.project
();
if
!*
this
.authed
{
if
this
.context
.auth_context
()
.get_token_len
()
>
0
&&
!*
this
.authed
{
*
this
.authed
=
true
;
return
this
.stream
.poll_write
_encrypted
(
cx
,
buf
);
return
this
.stream
.poll_write
(
cx
,
buf
);
}
loop
{
...
...
core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/crypto_io.rs
View file @
72201d5f
...
...
@@ -42,7 +42,9 @@ pub fn encrypt_payload(
)
{
match
method
.category
()
{
CipherCategory
::
None
=>
{
dst
.reserve
(
addr
.serialized_len
()
+
payload
.len
());
let
auth_ctx
=
context
.auth_context
();
dst
.reserve
(
auth_ctx
.get_token_len
()
+
addr
.serialized_len
()
+
payload
.len
());
dst
.put_slice
(
auth_ctx
.get_token
()
.as_bytes
());
addr
.write_to_buf
(
dst
);
dst
.put_slice
(
payload
);
}
...
...
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