mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 05:03:02 +00:00
Add Username
This commit is contained in:
parent
6810483c8f
commit
06677431a0
11 changed files with 24 additions and 34 deletions
|
|
@ -745,11 +745,8 @@ public static class ConfigHandler
|
||||||
profileItem.CoreType = ECoreType.sing_box;
|
profileItem.CoreType = ECoreType.sing_box;
|
||||||
|
|
||||||
profileItem.Address = profileItem.Address.TrimEx();
|
profileItem.Address = profileItem.Address.TrimEx();
|
||||||
|
profileItem.Username = profileItem.Username.TrimEx();
|
||||||
profileItem.Password = profileItem.Password.TrimEx();
|
profileItem.Password = profileItem.Password.TrimEx();
|
||||||
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
|
||||||
{
|
|
||||||
Username = profileItem.GetProtocolExtra().Username?.TrimEx()
|
|
||||||
});
|
|
||||||
profileItem.Network = string.Empty;
|
profileItem.Network = string.Empty;
|
||||||
|
|
||||||
if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType))
|
if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType))
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class SocksFmt : BaseFmt
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
//new
|
//new
|
||||||
var pw = Utils.Base64Encode($"{item.GetProtocolExtra().Username}:{item.Password}", true);
|
var pw = Utils.Base64Encode($"{item.Username}:{item.Password}", true);
|
||||||
return ToUri(EConfigType.SOCKS, item.Address, item.Port, pw, null, remark);
|
return ToUri(EConfigType.SOCKS, item.Address, item.Port, pw, null, remark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class SocksFmt : BaseFmt
|
||||||
}
|
}
|
||||||
item.Address = arr1[1][..indexPort];
|
item.Address = arr1[1][..indexPort];
|
||||||
item.Port = arr1[1][(indexPort + 1)..].ToInt();
|
item.Port = arr1[1][(indexPort + 1)..].ToInt();
|
||||||
item.SetProtocolExtra(item.GetProtocolExtra() with { Username = arr21.First() });
|
item.Username = arr21.First();
|
||||||
item.Password = arr21[1];
|
item.Password = arr21[1];
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ public class SocksFmt : BaseFmt
|
||||||
var userInfoParts = userInfo.Split([':'], 2);
|
var userInfoParts = userInfo.Split([':'], 2);
|
||||||
if (userInfoParts.Length == 2)
|
if (userInfoParts.Length == 2)
|
||||||
{
|
{
|
||||||
item.SetProtocolExtra(item.GetProtocolExtra() with { Username = userInfoParts.First() });
|
item.Username = userInfoParts.First();
|
||||||
item.Password = userInfoParts[1];
|
item.Password = userInfoParts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class TuicFmt : BaseFmt
|
||||||
var userInfoParts = rawUserInfo.Split(new[] { ':' }, 2);
|
var userInfoParts = rawUserInfo.Split(new[] { ':' }, 2);
|
||||||
if (userInfoParts.Length == 2)
|
if (userInfoParts.Length == 2)
|
||||||
{
|
{
|
||||||
item.SetProtocolExtra(item.GetProtocolExtra() with { Username = userInfoParts.First() });
|
item.Username = userInfoParts.First();
|
||||||
item.Password = userInfoParts.Last();
|
item.Password = userInfoParts.Last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,6 +53,6 @@ public class TuicFmt : BaseFmt
|
||||||
|
|
||||||
dicQuery.Add("congestion_control", item.HeaderType);
|
dicQuery.Add("congestion_control", item.HeaderType);
|
||||||
|
|
||||||
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.GetProtocolExtra().Username ?? ""}:{item.Password}", dicQuery, remark);
|
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Username ?? ""}:{item.Password}", dicQuery, remark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -333,13 +333,14 @@ public sealed class AppManager
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case EConfigType.TUIC:
|
case EConfigType.TUIC:
|
||||||
extra = extra with
|
item.Username = item.Id;
|
||||||
{
|
|
||||||
Username = item.Id,
|
|
||||||
};
|
|
||||||
item.Id = item.Security;
|
item.Id = item.Security;
|
||||||
item.Password = item.Security;
|
item.Password = item.Security;
|
||||||
break;
|
break;
|
||||||
|
case EConfigType.HTTP:
|
||||||
|
case EConfigType.SOCKS:
|
||||||
|
item.Username = item.Security;
|
||||||
|
break;
|
||||||
case EConfigType.WireGuard:
|
case EConfigType.WireGuard:
|
||||||
extra = extra with
|
extra = extra with
|
||||||
{
|
{
|
||||||
|
|
@ -349,8 +350,6 @@ public sealed class AppManager
|
||||||
WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280
|
WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item.SetProtocolExtra(extra);
|
item.SetProtocolExtra(extra);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ public class ProfileItem : ReactiveObject
|
||||||
Address = string.Empty;
|
Address = string.Empty;
|
||||||
Port = 0;
|
Port = 0;
|
||||||
Password = string.Empty;
|
Password = string.Empty;
|
||||||
|
Username = string.Empty;
|
||||||
Network = string.Empty;
|
Network = string.Empty;
|
||||||
Remarks = string.Empty;
|
Remarks = string.Empty;
|
||||||
HeaderType = string.Empty;
|
HeaderType = string.Empty;
|
||||||
|
|
@ -151,6 +152,7 @@ public class ProfileItem : ReactiveObject
|
||||||
public string Address { get; set; }
|
public string Address { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
public string Username { get; set; }
|
||||||
public string Network { get; set; }
|
public string Network { get; set; }
|
||||||
public string Remarks { get; set; }
|
public string Remarks { get; set; }
|
||||||
public string HeaderType { get; set; }
|
public string HeaderType { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@ public record ProtocolExtraItem
|
||||||
//public string? PluginArgs { get; init; }
|
//public string? PluginArgs { get; init; }
|
||||||
public string? SsMethod { get; init; }
|
public string? SsMethod { get; init; }
|
||||||
|
|
||||||
// socks and http
|
|
||||||
public string? Username { get; init; }
|
|
||||||
|
|
||||||
// wireguard
|
// wireguard
|
||||||
public string? WgPublicKey { get; init; }
|
public string? WgPublicKey { get; init; }
|
||||||
public string? WgPresharedKey { get; init; }
|
public string? WgPresharedKey { get; init; }
|
||||||
|
|
|
||||||
|
|
@ -90,20 +90,20 @@ public partial class CoreConfigSingboxService
|
||||||
case EConfigType.SOCKS:
|
case EConfigType.SOCKS:
|
||||||
{
|
{
|
||||||
outbound.version = "5";
|
outbound.version = "5";
|
||||||
if (protocolExtra.Username.IsNotEmpty()
|
if (node.Username.IsNotEmpty()
|
||||||
&& node.Password.IsNotEmpty())
|
&& node.Password.IsNotEmpty())
|
||||||
{
|
{
|
||||||
outbound.username = protocolExtra.Username;
|
outbound.username = node.Username;
|
||||||
outbound.password = node.Password;
|
outbound.password = node.Password;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.HTTP:
|
case EConfigType.HTTP:
|
||||||
{
|
{
|
||||||
if (protocolExtra.Username.IsNotEmpty()
|
if (node.Username.IsNotEmpty()
|
||||||
&& node.Password.IsNotEmpty())
|
&& node.Password.IsNotEmpty())
|
||||||
{
|
{
|
||||||
outbound.username = protocolExtra.Username;
|
outbound.username = node.Username;
|
||||||
outbound.password = node.Password;
|
outbound.password = node.Password;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -190,7 +190,7 @@ public partial class CoreConfigSingboxService
|
||||||
}
|
}
|
||||||
case EConfigType.TUIC:
|
case EConfigType.TUIC:
|
||||||
{
|
{
|
||||||
outbound.uuid = protocolExtra.Username;
|
outbound.uuid = node.Username;
|
||||||
outbound.password = node.Password;
|
outbound.password = node.Password;
|
||||||
outbound.congestion_control = node.HeaderType;
|
outbound.congestion_control = node.HeaderType;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,12 @@ public partial class CoreConfigV2rayService
|
||||||
serversItem.method = null;
|
serversItem.method = null;
|
||||||
serversItem.password = null;
|
serversItem.password = null;
|
||||||
|
|
||||||
if (protocolExtra.Username.IsNotEmpty()
|
if (node.Username.IsNotEmpty()
|
||||||
&& node.Password.IsNotEmpty())
|
&& node.Password.IsNotEmpty())
|
||||||
{
|
{
|
||||||
SocksUsersItem4Ray socksUsersItem = new()
|
SocksUsersItem4Ray socksUsersItem = new()
|
||||||
{
|
{
|
||||||
user = protocolExtra.Username ?? "",
|
user = node.Username ?? "",
|
||||||
pass = node.Password,
|
pass = node.Password,
|
||||||
level = 1
|
level = 1
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,6 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string SsMethod { get; set; }
|
public string SsMethod { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Username { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string WgPublicKey { get; set; }
|
public string WgPublicKey { get; set; }
|
||||||
//[Reactive]
|
//[Reactive]
|
||||||
|
|
@ -119,7 +116,6 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
||||||
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
||||||
SsMethod = protocolExtra?.SsMethod ?? string.Empty;
|
SsMethod = protocolExtra?.SsMethod ?? string.Empty;
|
||||||
Username = protocolExtra?.Username ?? string.Empty;
|
|
||||||
WgPublicKey = protocolExtra?.WgPublicKey ?? string.Empty;
|
WgPublicKey = protocolExtra?.WgPublicKey ?? string.Empty;
|
||||||
WgInterfaceAddress = protocolExtra?.WgInterfaceAddress ?? string.Empty;
|
WgInterfaceAddress = protocolExtra?.WgInterfaceAddress ?? string.Empty;
|
||||||
WgReserved = protocolExtra?.WgReserved ?? string.Empty;
|
WgReserved = protocolExtra?.WgReserved ?? string.Empty;
|
||||||
|
|
@ -182,7 +178,6 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
VmessSecurity = VmessSecurity.NullIfEmpty(),
|
VmessSecurity = VmessSecurity.NullIfEmpty(),
|
||||||
VlessEncryption = VlessEncryption.NullIfEmpty(),
|
VlessEncryption = VlessEncryption.NullIfEmpty(),
|
||||||
SsMethod = SsMethod.NullIfEmpty(),
|
SsMethod = SsMethod.NullIfEmpty(),
|
||||||
Username = Username.NullIfEmpty(),
|
|
||||||
WgPublicKey = WgPublicKey.NullIfEmpty(),
|
WgPublicKey = WgPublicKey.NullIfEmpty(),
|
||||||
WgInterfaceAddress = WgInterfaceAddress.NullIfEmpty(),
|
WgInterfaceAddress = WgInterfaceAddress.NullIfEmpty(),
|
||||||
WgReserved = WgReserved.NullIfEmpty(),
|
WgReserved = WgReserved.NullIfEmpty(),
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
case EConfigType.SOCKS:
|
case EConfigType.SOCKS:
|
||||||
case EConfigType.HTTP:
|
case EConfigType.HTTP:
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId4.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId4.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.Username, v => v.txtSecurity4.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Username, v => v.txtSecurity4.Text).DisposeWith(disposables);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EConfigType.VLESS:
|
case EConfigType.VLESS:
|
||||||
|
|
@ -152,7 +152,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EConfigType.TUIC:
|
case EConfigType.TUIC:
|
||||||
this.Bind(ViewModel, vm => vm.Username, v => v.txtId8.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Username, v => v.txtId8.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtSecurity8.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtSecurity8.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.SelectedValue).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.SelectedValue).DisposeWith(disposables);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ public partial class AddServerWindow
|
||||||
case EConfigType.SOCKS:
|
case EConfigType.SOCKS:
|
||||||
case EConfigType.HTTP:
|
case EConfigType.HTTP:
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId4.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtId4.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.Username, v => v.txtSecurity4.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Username, v => v.txtSecurity4.Text).DisposeWith(disposables);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EConfigType.VLESS:
|
case EConfigType.VLESS:
|
||||||
|
|
@ -147,7 +147,7 @@ public partial class AddServerWindow
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EConfigType.TUIC:
|
case EConfigType.TUIC:
|
||||||
this.Bind(ViewModel, vm => vm.Username, v => v.txtId8.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Username, v => v.txtId8.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtSecurity8.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtSecurity8.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.Text).DisposeWith(disposables);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue