Skip to content

Commit

Permalink
local DNS uses mode tcp_and_udp by default
Browse files Browse the repository at this point in the history
- Fixes #1281
  • Loading branch information
spyophobia committed Aug 31, 2023
1 parent fbe81b7 commit 6464f37
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ use serde::{Deserialize, Serialize};
use shadowsocks::relay::socks5::Address;
use shadowsocks::{
config::{
ManagerAddr,
Mode,
ReplayAttackPolicy,
ServerAddr,
ServerConfig,
ServerUser,
ServerUserManager,
ServerWeight,
ManagerAddr, Mode, ReplayAttackPolicy, ServerAddr, ServerConfig, ServerUser, ServerUserManager, ServerWeight,
},
crypto::CipherKind,
plugin::PluginConfig,
Expand Down Expand Up @@ -891,12 +884,20 @@ pub struct LocalConfig {
impl LocalConfig {
/// Create a new `LocalConfig`
pub fn new(protocol: ProtocolType) -> LocalConfig {
// DNS server runs in `TcpAndUdp` mode by default to maintain backwards compatibility
// see https://github.com/shadowsocks/shadowsocks-rust/issues/1281
let mode = match protocol {
#[cfg(feature = "local-dns")]
ProtocolType::Dns => Mode::TcpAndUdp,
_ => Mode::TcpOnly,
};

LocalConfig {
addr: None,

protocol,

mode: Mode::TcpOnly,
mode,
udp_addr: None,

#[cfg(feature = "local-tunnel")]
Expand Down Expand Up @@ -1456,7 +1457,15 @@ impl Config {
}
},
None => {
local_config.mode = global_mode;
// DNS server runs in `TcpAndUdp` mode by default to maintain backwards compatibility
// see https://github.com/shadowsocks/shadowsocks-rust/issues/1281
let mode = match protocol {
#[cfg(feature = "local-dns")]
ProtocolType::Dns => Mode::TcpAndUdp,
_ => global_mode,
};

local_config.mode = mode;
}
}

Expand Down

0 comments on commit 6464f37

Please sign in to comment.