mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-15 17:05:03 +03:00
refactor(masque): allow empty credentials and enable TLS by default (#10601)
- Accept empty username/password, which is common in MASQUE + WARP setups where credentials are optional. - Enable TLS by default, as forced by Xray and sing-box.
This commit is contained in:
@@ -777,10 +777,6 @@ public static class ConfigDbHandler
|
|||||||
{
|
{
|
||||||
profileItem.StreamSecurity = Global.StreamSecurity;
|
profileItem.StreamSecurity = Global.StreamSecurity;
|
||||||
}
|
}
|
||||||
if (profileItem.Password.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
await AddServerCommon(profileItem, toFile);
|
await AddServerCommon(profileItem, toFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -656,8 +656,11 @@ public partial class CoreConfigV2rayService
|
|||||||
|
|
||||||
case "masque":
|
case "masque":
|
||||||
var headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
var headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
var authValue = $"Basic {Utils.Base64Encode($"{_node.Username}:{_node.Password}")}";
|
if (!string.IsNullOrEmpty(_node.Username) || !string.IsNullOrEmpty(_node.Password))
|
||||||
headers.Add("Authorization", authValue);
|
{
|
||||||
|
var authValue = $"Basic {Utils.Base64Encode($"{_node.Username}:{_node.Password}")}";
|
||||||
|
headers.Add("Authorization", authValue);
|
||||||
|
}
|
||||||
if (!string.IsNullOrEmpty(protocolExtra?.MasqueHeaders))
|
if (!string.IsNullOrEmpty(protocolExtra?.MasqueHeaders))
|
||||||
{
|
{
|
||||||
var userHeaders = Utils.ParseHeaders(protocolExtra.MasqueHeaders)
|
var userHeaders = Utils.ParseHeaders(protocolExtra.MasqueHeaders)
|
||||||
|
|||||||
@@ -501,7 +501,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SelectedSource.ConfigType is not EConfigType.SOCKS and not EConfigType.HTTP)
|
if (SelectedSource.ConfigType is not EConfigType.SOCKS and not EConfigType.HTTP and not EConfigType.MASQUE)
|
||||||
{
|
{
|
||||||
if (SelectedSource.Password.IsNullOrEmpty())
|
if (SelectedSource.Password.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -311,6 +311,11 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
|||||||
gridMasque.IsVisible = true;
|
gridMasque.IsVisible = true;
|
||||||
sepa2.IsVisible = false;
|
sepa2.IsVisible = false;
|
||||||
gridTransport.IsVisible = false;
|
gridTransport.IsVisible = false;
|
||||||
|
lstStreamSecurity.Remove(string.Empty);
|
||||||
|
if (string.IsNullOrEmpty(profileItem.StreamSecurity))
|
||||||
|
{
|
||||||
|
profileItem.StreamSecurity = lstStreamSecurity.First();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmbStreamSecurity.ItemsSource = lstStreamSecurity;
|
cmbStreamSecurity.ItemsSource = lstStreamSecurity;
|
||||||
@@ -334,7 +339,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
|||||||
|
|
||||||
private void CmbStreamSecurity_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
private void CmbStreamSecurity_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var security = cmbStreamSecurity.SelectedItem.ToString();
|
var security = cmbStreamSecurity.SelectedItem?.ToString();
|
||||||
if (security == Global.StreamSecurityReality)
|
if (security == Global.StreamSecurityReality)
|
||||||
{
|
{
|
||||||
gridRealityMore.IsVisible = true;
|
gridRealityMore.IsVisible = true;
|
||||||
|
|||||||
@@ -299,6 +299,11 @@ public partial class AddServerWindow
|
|||||||
gridMasque.Visibility = Visibility.Visible;
|
gridMasque.Visibility = Visibility.Visible;
|
||||||
sepa2.Visibility = Visibility.Collapsed;
|
sepa2.Visibility = Visibility.Collapsed;
|
||||||
gridTransport.Visibility = Visibility.Collapsed;
|
gridTransport.Visibility = Visibility.Collapsed;
|
||||||
|
lstStreamSecurity.Remove(string.Empty);
|
||||||
|
if (string.IsNullOrEmpty(profileItem.StreamSecurity))
|
||||||
|
{
|
||||||
|
profileItem.StreamSecurity = lstStreamSecurity.First();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmbStreamSecurity.ItemsSource = lstStreamSecurity;
|
cmbStreamSecurity.ItemsSource = lstStreamSecurity;
|
||||||
@@ -322,7 +327,7 @@ public partial class AddServerWindow
|
|||||||
|
|
||||||
private void CmbStreamSecurity_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void CmbStreamSecurity_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var security = cmbStreamSecurity.SelectedItem.ToString();
|
var security = cmbStreamSecurity.SelectedItem?.ToString();
|
||||||
if (security == Global.StreamSecurityReality)
|
if (security == Global.StreamSecurityReality)
|
||||||
{
|
{
|
||||||
gridRealityMore.Visibility = Visibility.Visible;
|
gridRealityMore.Visibility = Visibility.Visible;
|
||||||
|
|||||||
Reference in New Issue
Block a user